voxbi 0.1.8 → 0.1.9
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/README.md +0 -3
- data/data/liaisons.csv +5 -0
- data/data/paires.wav +0 -0
- data/data/phono.json +1 -1
- data/lib/voxbi.rb +25 -2
- data/phono.json +1 -0
- data/voxbi.gemspec +2 -2
- metadata +4 -2
data/lib/voxbi.rb
CHANGED
@@ -17,9 +17,18 @@ def conversion
|
|
17
17
|
@conversion ||= parseCSV "conversion"
|
18
18
|
end
|
19
19
|
|
20
|
+
def liaisons
|
21
|
+
@liaisons ||= parseCSV "liaisons"
|
22
|
+
end
|
23
|
+
|
24
|
+
def clean(texte)
|
25
|
+
return texte.downcase.gsub(SPE, "").split
|
26
|
+
end
|
27
|
+
|
20
28
|
def apimatch(texte)
|
21
|
-
|
22
|
-
texte
|
29
|
+
graphie = clean(texte)
|
30
|
+
clean_text = clean(texte)
|
31
|
+
phono = clean_text.map do |mot|
|
23
32
|
exceptions[mot] || "".tap do |result|
|
24
33
|
conversion.select { |regle| mot =~ /#{regle}/ }.first.tap do |regle, api|
|
25
34
|
mot.sub! /#{regle}/, ""
|
@@ -27,7 +36,21 @@ def apimatch(texte)
|
|
27
36
|
end until mot.empty?
|
28
37
|
end
|
29
38
|
end
|
39
|
+
return liaison(graphie,phono)
|
40
|
+
end
|
41
|
+
|
42
|
+
def liaison(texte,phono)
|
43
|
+
texte.each_with_index do |mot,id|
|
44
|
+
if phono[id+1]
|
45
|
+
lien = mot[-1] + phono[id+1][0]
|
46
|
+
match = liaisons.select {|k,v| lien =~ /#{k}/ }.first
|
47
|
+
match ? phono[id+1] = match[1].to_s + phono[id+1] : next
|
48
|
+
end
|
49
|
+
end
|
50
|
+
return phono
|
30
51
|
end
|
52
|
+
|
53
|
+
|
31
54
|
|
32
55
|
def voxbi(texte)
|
33
56
|
paires_dispo = File.open("#{ROOT}/data/paires_disponibles.csv").read.split("\n")
|