apion 0.1.0
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 +7 -0
- data/Gemfile +1 -0
- data/Gemfile.lock +9 -0
- data/README.md +41 -0
- data/apion-0.1.0.gem +0 -0
- data/apion.gemspec +16 -0
- data/bin/apion +6 -0
- data/data/conversion.csv +178 -0
- data/data/dict.json +1 -0
- data/lib/apion.rb +30 -0
- data/lib/apion.rb~ +30 -0
- metadata +68 -0
data/lib/apion.rb
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
ROOT = File.expand_path("../..", __FILE__)
|
6
|
+
SPE = /([(0-9)|•|—|–|\-|,|?|!|^|\r|°|“|”|...|\u00a0|«|»|…|\\|\/|!|?|\"|\'|\[|\]|\(|\)|\]|<|>|=|+|%|$|&|#|;|*|:|}|{|`])/
|
7
|
+
|
8
|
+
def parseCSV(path)
|
9
|
+
Hash[File.open("#{ROOT}/data/#{path}.csv").read.split("\n").map {|ligne| ligne.split("#")}]
|
10
|
+
end
|
11
|
+
|
12
|
+
def exceptions
|
13
|
+
@exceptions ||= JSON.parse(File.read("#{ROOT}/data/dict.json"))
|
14
|
+
end
|
15
|
+
|
16
|
+
def conversion
|
17
|
+
@conversion ||= parseCSV "conversion"
|
18
|
+
end
|
19
|
+
|
20
|
+
def apion(texte)
|
21
|
+
texte = texte.downcase
|
22
|
+
texte.gsub(SPE, "").split.map do |mot|
|
23
|
+
exceptions[mot] || "".tap do |result|
|
24
|
+
conversion.select { |regle| mot =~ /#{regle}/ }.first.tap do |regle, api|
|
25
|
+
mot.sub! /#{regle}/, ""
|
26
|
+
result << api.to_s
|
27
|
+
end until mot.empty?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
data/lib/apion.rb~
ADDED
@@ -0,0 +1,30 @@
|
|
1
|
+
#!/usr/bin/env ruby
|
2
|
+
|
3
|
+
require "json"
|
4
|
+
|
5
|
+
ROOT = File.expand_path("../..", __FILE__)
|
6
|
+
SPE = /([(0-9)|•|—|–|\-|,|?|!|^|\r|°|“|”|...|\u00a0|«|»|…|\\|\/|!|?|\"|\'|\[|\]|\(|\)|\]|<|>|=|+|%|$|&|#|;|*|:|}|{|`])/
|
7
|
+
|
8
|
+
def parseCSV(path)
|
9
|
+
Hash[File.open("#{ROOT}/data/#{path}.csv").read.split("\n").map {|ligne| ligne.split("#")}]
|
10
|
+
end
|
11
|
+
|
12
|
+
def exceptions
|
13
|
+
@exceptions ||= JSON.parse(File.read("#{ROOT}/data/dict.json"))
|
14
|
+
end
|
15
|
+
|
16
|
+
def conversion
|
17
|
+
@conversion ||= parseCSV "conversion"
|
18
|
+
end
|
19
|
+
|
20
|
+
def apion(texte)
|
21
|
+
texte = texte.downcase
|
22
|
+
texte.gsub(SPE, "").split.map do |mot|
|
23
|
+
exceptions[mot] || "".tap do |result|
|
24
|
+
conversion.select { |regle| mot =~ /#{regle}/ }.first.tap do |regle, api|
|
25
|
+
mot.sub! /#{regle}/, ""
|
26
|
+
result << api.to_s
|
27
|
+
end until mot.empty?
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
metadata
ADDED
@@ -0,0 +1,68 @@
|
|
1
|
+
--- !ruby/object:Gem::Specification
|
2
|
+
name: apion
|
3
|
+
version: !ruby/object:Gem::Version
|
4
|
+
version: 0.1.0
|
5
|
+
platform: ruby
|
6
|
+
authors:
|
7
|
+
- Galaad Gauthier
|
8
|
+
autorequire:
|
9
|
+
bindir: bin
|
10
|
+
cert_chain: []
|
11
|
+
date: 2013-08-21 00:00:00.000000000 Z
|
12
|
+
dependencies:
|
13
|
+
- !ruby/object:Gem::Dependency
|
14
|
+
name: json
|
15
|
+
requirement: !ruby/object:Gem::Requirement
|
16
|
+
requirements:
|
17
|
+
- - '>='
|
18
|
+
- !ruby/object:Gem::Version
|
19
|
+
version: '0'
|
20
|
+
type: :runtime
|
21
|
+
prerelease: false
|
22
|
+
version_requirements: !ruby/object:Gem::Requirement
|
23
|
+
requirements:
|
24
|
+
- - '>='
|
25
|
+
- !ruby/object:Gem::Version
|
26
|
+
version: '0'
|
27
|
+
description: Easy-to-use Fr/Api translator
|
28
|
+
email: coontail7@gmail.com
|
29
|
+
executables:
|
30
|
+
- apion
|
31
|
+
extensions: []
|
32
|
+
extra_rdoc_files: []
|
33
|
+
files:
|
34
|
+
- Gemfile
|
35
|
+
- apion-0.1.0.gem
|
36
|
+
- apion.gemspec
|
37
|
+
- lib/apion.rb~
|
38
|
+
- lib/apion.rb
|
39
|
+
- data/dict.json
|
40
|
+
- data/conversion.csv
|
41
|
+
- bin/apion
|
42
|
+
- Gemfile.lock
|
43
|
+
- README.md
|
44
|
+
homepage: https://github.com/Galaad-Gauthier/Apion
|
45
|
+
licenses:
|
46
|
+
- MIT
|
47
|
+
metadata: {}
|
48
|
+
post_install_message:
|
49
|
+
rdoc_options: []
|
50
|
+
require_paths:
|
51
|
+
- lib
|
52
|
+
required_ruby_version: !ruby/object:Gem::Requirement
|
53
|
+
requirements:
|
54
|
+
- - '>='
|
55
|
+
- !ruby/object:Gem::Version
|
56
|
+
version: '0'
|
57
|
+
required_rubygems_version: !ruby/object:Gem::Requirement
|
58
|
+
requirements:
|
59
|
+
- - '>='
|
60
|
+
- !ruby/object:Gem::Version
|
61
|
+
version: '0'
|
62
|
+
requirements: []
|
63
|
+
rubyforge_project:
|
64
|
+
rubygems_version: 2.0.5
|
65
|
+
signing_key:
|
66
|
+
specification_version: 4
|
67
|
+
summary: Apion
|
68
|
+
test_files: []
|