@andalugeeks/andaluh
Advanced tools
Comparing version 1.1.4 to 1.1.5
{ | ||
"name": "@andalugeeks/andaluh", | ||
"version": "1.1.4", | ||
"version": "1.1.5", | ||
"description": "andaluh-js", | ||
@@ -28,3 +28,2 @@ "main": "dist/src/index.js", | ||
"mocha": "^5.2.0", | ||
"pre-commit": "^1.2.2", | ||
"ts-node": "^8.0.2", | ||
@@ -31,0 +30,0 @@ "tslint": "^5.12.1", |
@@ -79,3 +79,3 @@ /** | ||
export const WORDEND_CONST_RULES_EXCEPT = { | ||
'al': 'al', 'cual': 'cuâ', 'del': 'del', 'dél': 'dél', 'el':'el', 'él':'èl', 'tal': 'tal', 'bil': 'bîl', | ||
'al': 'al', 'cual': 'cuâ', 'del': 'del', 'dél': 'dél', 'el': 'el', 'él': 'èl', 'tal': 'tal', 'bil': 'bîl', | ||
// TODO: uir = huir. Maybe better to add the exceptions on h_rules? | ||
@@ -93,3 +93,3 @@ 'por': 'por', 'uir': 'huîh', | ||
// Ending with -ada | ||
'fabada': 'fabada', 'fabadas':'fabadas', 'fada': 'fada', 'ada': 'ada', 'lada': 'lada', 'rada': 'rada', | ||
'fabada': 'fabada', 'fabadas': 'fabadas', 'fada': 'fada', 'ada': 'ada', 'lada': 'lada', 'rada': 'rada', | ||
// Ending with -adas | ||
@@ -105,11 +105,11 @@ 'adas': 'adas', 'radas': 'radas', 'nadas': 'nadas', | ||
// Exceptions to digraph rules with nm | ||
'biêmmandao':'bienmandao', 'biêmmeçabe':'bienmeçabe', 'buêmmoço':'buenmoço', 'çiêmmiléçima':'çienmiléçima', 'çiêmmiléçimo':'çienmiléçimo', 'çiêmmilímetro':'çienmilímetro', 'çiêmmiyonéçima':'çienmiyonéçima', 'çiêmmiyonéçimo':'çienmiyonéçimo', 'çiêmmirmiyonéçima':'çienmirmiyonéçima', 'çiêmmirmiyonéçimo':'çienmirmiyonéçimo', | ||
'biêmmandao': 'bienmandao', 'biêmmeçabe': 'bienmeçabe', 'buêmmoço': 'buenmoço', 'çiêmmiléçima': 'çienmiléçima', 'çiêmmiléçimo': 'çienmiléçimo', 'çiêmmilímetro': 'çienmilímetro', 'çiêmmiyonéçima': 'çienmiyonéçima', 'çiêmmiyonéçimo': 'çienmiyonéçimo', 'çiêmmirmiyonéçima': 'çienmirmiyonéçima', 'çiêmmirmiyonéçimo': 'çienmirmiyonéçimo', | ||
// Exceptions to l rules | ||
'marrotadôh':'mârrotadôh', 'marrotâh':'mârrotâh', 'mirrayâ':'mîrrayâ', | ||
'marrotadôh': 'mârrotadôh', 'marrotâh': 'mârrotâh', 'mirrayâ': 'mîrrayâ', | ||
// Exceptions to psico pseudo rules | ||
'herôççiquiatría':'heroçiquiatría', 'herôççiquiátrico':'heroçiquiátrico', 'farmacôççiquiatría':'farmacoçiquiatría', 'metempçícoçî':'metemçícoçî', 'necróçico':'necróççico', 'pampçiquîmmo':'pamçiquîmmo', | ||
'herôççiquiatría': 'heroçiquiatría', 'herôççiquiátrico': 'heroçiquiátrico', 'farmacôççiquiatría': 'farmacoçiquiatría', 'metempçícoçî': 'metemçícoçî', 'necróçico': 'necróççico', 'pampçiquîmmo': 'pamçiquîmmo', | ||
// Other exceptions | ||
'antîççerôttármico':'antiçerôttármico', 'eclampçia':'eclampçia', 'pôttoperatorio':'pôççoperatorio', 'çáccrito':'çánccrito', 'manbîh':'mambîh', 'cômmelináçeo':'commelináçeo', 'dîmmneçia':'dînneçia', 'todo': 'tó', 'todô': 'tôh', 'toda': 'toa', 'todâ': 'toâ', | ||
'antîççerôttármico': 'antiçerôttármico', 'eclampçia': 'eclampçia', 'pôttoperatorio': 'pôççoperatorio', 'çáccrito': 'çánccrito', 'manbîh': 'mambîh', 'cômmelináçeo': 'commelináçeo', 'dîmmneçia': 'dînneçia', 'todo': 'tó', 'todô': 'tôh', 'toda': 'toa', 'todâ': 'toâ', | ||
// Other exceptions monosyllables | ||
'as':'âh', 'clown':'claun', 'crack':'crâh', 'down':'daun', 'es':'êh', 'ex':'êh', 'ir':'îh', 'miss':'mîh', 'muy':'mu', 'ôff':'off', 'os':'ô', 'para':'pa', 'ring':'rin', 'rock':'rôh', 'spray':'êppray', 'sprint':'êpprín', 'wa':'gua' | ||
'as': 'âh', 'clown': 'claun', 'crack': 'crâh', 'down': 'daun', 'es': 'êh', 'ex': 'êh', 'ir': 'îh', 'miss': 'mîh', 'muy': 'mu', 'ôff': 'off', 'os': 'ô', 'para': 'pa', 'ring': 'rin', 'rock': 'rôh', 'spray': 'êppray', 'sprint': 'êpprín', 'wa': 'gua' | ||
} | ||
@@ -121,2 +121,23 @@ | ||
private tags = []; | ||
ignore_rules = (text: string) => { | ||
const patterns = [ | ||
/(https?:\/\/)?(?:www\.)?(?:[-a-zA-Z0-9@:%._\+~#=]{1,256}\.[a-zA-Z0-9()]{1,6})/gi, | ||
this.xRegExp('(?:@([\\p{L}])+)', 'gi'), | ||
this.xRegExp('(?:#([\\p{L}])+)', 'gi'), | ||
/(?=\b[MCDXLVI]{1,8}\b)M{0,4}(?:CM|CD|D?C{0,3})(?:XC|XL|L?X{0,3})(?:IX|IV|V?I{0,3})/g, | ||
]; | ||
return patterns.reduce((text, pattern) => { | ||
const matches = text.match(pattern); | ||
if (matches) { | ||
const randomInt = Math.floor(Math.random() * 999999999).toString(); | ||
matches.forEach(match => this.tags.push([randomInt, match])); | ||
return text.replace(pattern, randomInt); | ||
} | ||
return text; | ||
}, text); | ||
}; | ||
h_rules = (text: string) => { | ||
@@ -137,3 +158,3 @@ // chihuahua => chiguagua | ||
(word) => { | ||
if (word && H_RULES_EXCEPT[word.toLowerCase()]) { | ||
if (word && H_RULES_EXCEPT[word.toLowerCase()]) { | ||
return keep_case(word, H_RULES_EXCEPT[word.toLowerCase()]); | ||
@@ -156,3 +177,3 @@ } | ||
.replace( | ||
this.xRegExp('(a|e|i|o|u|á|é|í|ó|ú)(x)(a|e|i|o|u|á|é|í|ó|ú)', 'gi'), | ||
this.xRegExp('(a|e|i|o|u|á|é|í|ó|ú)(x)(a|e|i|o|u|y|á|é|í|ó|ú)', 'gi'), | ||
(_, prev_char, x_char, next_char) => get_vowel_circumflex(prev_char) + keep_case(x_char, vaf).repeat(2) + next_char | ||
@@ -244,3 +265,3 @@ ) | ||
this.xRegExp('(c(?=e|i|é|í|ê|î)|z|s)(a|e|i|o|u|á|é|í|ó|ú|Á|É|Í|Ó|Ú|â|ê|î|ô|û|Â|Ê|Î|Ô|Û)', 'gi'), | ||
(_, cons_char, suffix) => keep_case(cons_char, vaf) + suffix | ||
(_, cons_char, suffix) => keep_case(cons_char, vaf) + suffix | ||
); | ||
@@ -287,3 +308,3 @@ } | ||
case 'ido': | ||
case'ído': | ||
case 'ído': | ||
return prefix + keep_case(suffix_vowel_a, 'í') + suffix_vowel_b; | ||
@@ -367,3 +388,3 @@ default: | ||
const isrs = cons_char.toLowerCase() === 'r' && s_char.toLowerCase() === 's'; | ||
return (isrs ? vowel_char + cons_char : get_vowel_circumflex(vowel_char)) + digraph_char.repeat(2); | ||
return (isrs ? vowel_char + cons_char : get_vowel_circumflex(vowel_char)) + digraph_char.repeat(2); | ||
} | ||
@@ -399,3 +420,9 @@ ) | ||
transcript = (text: string, vaf = VAF, vvf = VVF) => { | ||
transcript = (text: string, vaf = VAF, vvf = VVF, scapeLinks = false) => { | ||
let substitutedText = text; | ||
if (scapeLinks) { | ||
substitutedText = this.ignore_rules(text); | ||
} | ||
const rules = [ | ||
@@ -417,9 +444,11 @@ this.h_rules, | ||
return rules.reduce((text, rule) => { | ||
if (rule === this.x_rules) return this.x_rules(text, vaf); | ||
if (rule === this.vaf_rules) return this.vaf_rules(text, vaf); | ||
if (rule === this.gj_rules) return this.gj_rules(text, vvf); | ||
return rule(text); | ||
}, text); | ||
const finalText = rules.reduce((substitutedText, rule) => { | ||
if (rule === this.x_rules) return this.x_rules(substitutedText, vaf); | ||
if (rule === this.vaf_rules) return this.vaf_rules(substitutedText, vaf); | ||
if (rule === this.gj_rules) return this.gj_rules(substitutedText, vvf); | ||
return rule(substitutedText); | ||
}, substitutedText); | ||
return this.tags.reduce((text, tags) => text.replace(tags[0], tags[1]), finalText); | ||
} | ||
} |
@@ -9,4 +9,9 @@ /** | ||
import EPA from '../src/transcripts/epa'; | ||
import EPA, { VAF, VVF } from '../src/transcripts/epa'; | ||
import { expect } from 'chai'; | ||
import { readFileSync, } from 'fs'; | ||
import { resolve } from 'path'; | ||
import { csvToArray } from './util'; | ||
const lemarioCsv = readFileSync(resolve(__dirname, 'lemario.csv'), 'utf-8'); | ||
const lemarioArr = csvToArray(lemarioCsv, ',', false); | ||
@@ -26,5 +31,11 @@ describe('Andalugeeks - EPA transcription Tests', () => { | ||
'Una comida fabada con fado, y sin descuido será casada y amarrada al acolchado roido.': 'Una comida fabada con fado, y çin dêccuido çerá caçá y amarrá al acorxao roío.', | ||
'Los SABuesos ChiHuaHUA comían cacaHuETes, FramBuESas y Heno, ¡y HABLAN ESPANGLISH!': 'Lô ÇAGueçô XiGuaGUA comían cacaGuETê, FramBuEÇâ y Eno, ¡y ABLAN ÊPPANGLÎ!' | ||
'Los SABuesos ChiHuaHUA comían cacaHuETes, FramBuESas y Heno, ¡y HABLAN ESPANGLISH!': 'Lô ÇAGueçô XiGuaGUA comían cacaGuETê, FramBuEÇâ y Eno, ¡y ABLAN ÊPPANGLÎ!', | ||
}; | ||
const testScapeLinks = { | ||
'Oye hermano @miguel, la web HTTPS://andaluh.es no sale en google.es pero si en http://google.com #porqueseñor': 'Oye ermano @miguel, la wêh HTTPS://andaluh.es no çale en google.es pero çi en http://google.com #porqueseñor', | ||
'Bienvenidos al Siglo XXI a los nuevos integrantes @Karlos_30 y @usuario2342 #bienvenida #saludos': 'Biembeníô ar Çiglo XXI a lô nuebô integrantê @Karlos_30 y @usuario2342 #bienvenida #saludos', | ||
'El otro día ConoCí a UNa seXY señorita': 'El otro día ConoÇí a UNa çêÇÇY çeñorita' | ||
}; | ||
for (const key of Object.keys(transcriptionsTest)) { | ||
@@ -36,2 +47,14 @@ it('should transcipt "' + key.substring(0, 20) + '..." correctly', () => { | ||
for (const key of Object.keys(testScapeLinks)) { | ||
it('should transcipt "' + key.substring(0, 20) + '..." correctly', () => { | ||
expect(epa.transcript(key, VAF, VVF, true)).to.equal(testScapeLinks[key]); | ||
}); | ||
} | ||
lemarioArr.forEach(line => { | ||
it(`should transcript ${line[0]} correctly`, () => { | ||
expect(epa.transcript(line[0])).to.equal(line[1]); | ||
}); | ||
}); | ||
it('should pass h_rules', () => { | ||
@@ -127,2 +150,2 @@ // rule 1 | ||
}); | ||
}); |
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
2699513
10
32
2295
4