apion 0.1.7 → 0.1.8
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.
- checksums.yaml +4 -4
- data/apion.gemspec +1 -1
- data/lib/apion.rb +2 -45
- data/lib/ipa.rb +45 -0
- data/lib/string.rb +1 -1
- metadata +2 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA1:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: f7c8924c7d6f31b3b7215d09e42dd140a0950a99
|
4
|
+
data.tar.gz: cc9bbd740ccaecbc2d2822dd91716b51556e2992
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 85355a9f375ad7668f9e6f95c93ee61ed432b726ecca403a6c707564348021c9c4af9bd19e6b9a69f9345370c4c33729f5bf67c5637d27be08316bab053e1c29
|
7
|
+
data.tar.gz: fef28e9ff97459da3169718ef53fdea106be757068433b3b43e722e3a4ae20934ec65101679b5ae314071ae7a29d212dbf1f94ffdc42b2f4cad89a49fd528f82
|
data/apion.gemspec
CHANGED
data/lib/apion.rb
CHANGED
@@ -1,45 +1,2 @@
|
|
1
|
-
|
2
|
-
|
3
|
-
class Apion
|
4
|
-
|
5
|
-
require "json"
|
6
|
-
require "timeout"
|
7
|
-
|
8
|
-
ROOT = File.expand_path("../..", __FILE__)
|
9
|
-
eval(File.read("#{ROOT}/lib/special_chars.rb"))
|
10
|
-
attr_accessor :timeout
|
11
|
-
|
12
|
-
def initialize
|
13
|
-
@timeout = 0.2
|
14
|
-
end
|
15
|
-
|
16
|
-
def parseCSV(path)
|
17
|
-
Hash[File.open("#{ROOT}/data/#{path}.csv").read.split("\n").map {|ligne| ligne.split("#")}]
|
18
|
-
end
|
19
|
-
|
20
|
-
def exceptions
|
21
|
-
@exceptions ||= JSON.parse(File.read("#{ROOT}/data/dict.json"))
|
22
|
-
end
|
23
|
-
|
24
|
-
def conversion
|
25
|
-
@conversion ||= parseCSV "conversion"
|
26
|
-
end
|
27
|
-
|
28
|
-
def apion(texte)
|
29
|
-
texte = texte.downcase
|
30
|
-
texte.gsub(SPE, "").split.map do |mot|
|
31
|
-
exceptions[mot] || "".tap do |result|
|
32
|
-
Timeout::timeout(timeout) do
|
33
|
-
conversion.select { |regle| mot =~ /#{regle}/ }.first.tap do |regle, api|
|
34
|
-
mot.sub! /#{regle}/, ""
|
35
|
-
result << api.to_s
|
36
|
-
end until mot.empty?
|
37
|
-
end
|
38
|
-
end
|
39
|
-
end
|
40
|
-
rescue Timeout::Error
|
41
|
-
return []
|
42
|
-
end
|
43
|
-
|
44
|
-
end
|
45
|
-
|
1
|
+
root = File.expand_path("../..", __FILE__)
|
2
|
+
require "#{root}/lib/string.rb"
|
data/lib/ipa.rb
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
class IPA
|
4
|
+
|
5
|
+
require "json"
|
6
|
+
require "timeout"
|
7
|
+
|
8
|
+
ROOT = File.expand_path("../..", __FILE__)
|
9
|
+
eval(File.read("#{ROOT}/lib/special_chars.rb"))
|
10
|
+
attr_accessor :timeout
|
11
|
+
|
12
|
+
def initialize
|
13
|
+
@timeout = 0.2
|
14
|
+
end
|
15
|
+
|
16
|
+
def parseCSV(path)
|
17
|
+
Hash[File.open("#{ROOT}/data/#{path}.csv").read.split("\n").map {|ligne| ligne.split("#")}]
|
18
|
+
end
|
19
|
+
|
20
|
+
def exceptions
|
21
|
+
@exceptions ||= JSON.parse(File.read("#{ROOT}/data/dict.json"))
|
22
|
+
end
|
23
|
+
|
24
|
+
def conversion
|
25
|
+
@conversion ||= parseCSV "conversion"
|
26
|
+
end
|
27
|
+
|
28
|
+
def convert_to_ipa(texte)
|
29
|
+
texte = texte.downcase
|
30
|
+
texte.gsub(SPE, "").split.map do |mot|
|
31
|
+
exceptions[mot] || "".tap do |result|
|
32
|
+
Timeout::timeout(timeout) do
|
33
|
+
conversion.select { |regle| mot =~ /#{regle}/ }.first.tap do |regle, api|
|
34
|
+
mot.sub! /#{regle}/, ""
|
35
|
+
result << api.to_s
|
36
|
+
end until mot.empty?
|
37
|
+
end
|
38
|
+
end
|
39
|
+
end
|
40
|
+
rescue Timeout::Error
|
41
|
+
return []
|
42
|
+
end
|
43
|
+
|
44
|
+
end
|
45
|
+
|
data/lib/string.rb
CHANGED
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: apion
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.1.
|
4
|
+
version: 0.1.8
|
5
5
|
platform: ruby
|
6
6
|
authors:
|
7
7
|
- Galaad Gauthier
|
@@ -34,6 +34,7 @@ files:
|
|
34
34
|
- Gemfile
|
35
35
|
- apion.gemspec
|
36
36
|
- lib/special_chars.rb
|
37
|
+
- lib/ipa.rb
|
37
38
|
- lib/string.rb
|
38
39
|
- lib/apion.rb
|
39
40
|
- data/dict.json
|