voxbi 0.1.8 → 0.1.9

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
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
- texte = texte.downcase
22
- texte.gsub(SPE, "").split.map do |mot|
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")