tc211-termbase 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/Gemfile.lock +1 -1
- data/lib/tc211/termbase/term.rb +89 -2
- data/lib/tc211/termbase/version.rb +1 -1
- metadata +1 -1
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: 76f28b674292d0635730a89b8b2ce2d474d7c89025461e6617a06bcdb456c5d0
|
4
|
+
data.tar.gz: 22b29329630f7c9c33f4ac0488ce449665950b2ed988a628c427265986bdccbe
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: 4108f4b967b3d95aebd2c93e20b57a45f9af634b3851a1c052ddb66e3fe34c925db6a257249fae2b18351c5b03c1222ab5ff712ff5404e01c2a5f790de1f1a87
|
7
|
+
data.tar.gz: e24326cb32164e923f19db96d4cb4fbb516e02f1509cda8da52e04dd4004385c7327fae9a8a275c926e32ad4a7f8479d351d4a2d1f5c0a0f6e0bbf7249d7c6b1
|
data/Gemfile.lock
CHANGED
data/lib/tc211/termbase/term.rb
CHANGED
@@ -39,9 +39,9 @@ class Term
|
|
39
39
|
next unless v
|
40
40
|
case k
|
41
41
|
when /^example/
|
42
|
-
|
42
|
+
add_example(v)
|
43
43
|
when /^note/
|
44
|
-
|
44
|
+
add_note(v)
|
45
45
|
else
|
46
46
|
# puts"Key #{k}"
|
47
47
|
key = k.gsub("-", "_")
|
@@ -51,6 +51,93 @@ class Term
|
|
51
51
|
self
|
52
52
|
end
|
53
53
|
|
54
|
+
STRIP_PUNCTUATION = [
|
55
|
+
":",
|
56
|
+
":",
|
57
|
+
".",
|
58
|
+
"–",
|
59
|
+
" "
|
60
|
+
]
|
61
|
+
|
62
|
+
# WARNING
|
63
|
+
# Always put the longer Regexp match in front!
|
64
|
+
EXAMPLE_PREFIXES = {
|
65
|
+
# TODO: fix this, we should not have "EXAMPLES"
|
66
|
+
eng: ["EXAMPLES", "EXAMPLE"],
|
67
|
+
ara: "مثال",
|
68
|
+
chi: "示例",
|
69
|
+
dan: "EKSEMPEL",
|
70
|
+
dut: "VOORBEELD",
|
71
|
+
fin: "ESIM",
|
72
|
+
fre: "Exemple",
|
73
|
+
# ger: "",
|
74
|
+
jpn: "例",
|
75
|
+
kor: "보기",
|
76
|
+
pol: "PRZYKŁAD",
|
77
|
+
may: "Contoh",
|
78
|
+
rus: "Пример",
|
79
|
+
spa: "Ejemplo",
|
80
|
+
swe: "Exempel"
|
81
|
+
}
|
82
|
+
|
83
|
+
# WARNING
|
84
|
+
# Always put the longer Regexp match in front!
|
85
|
+
NOTE_PREFIXES = {
|
86
|
+
eng: ["Note \\d to entry", "NOTE"],
|
87
|
+
ara: "ملاحظة",
|
88
|
+
chi: "注",
|
89
|
+
dan: "Note",
|
90
|
+
dut: "OPMERKING",
|
91
|
+
fin: "HUOM\\.?", # Matches "HUOM", "HUOM.", "HUOM 1." and "HUOM. 1." (numeral added by the method)
|
92
|
+
fre: "A noter",
|
93
|
+
# ger: "",
|
94
|
+
jpn: "備考",
|
95
|
+
kor: "비고",
|
96
|
+
pol: "UWAGA",
|
97
|
+
may: "catatan",
|
98
|
+
rus: "нота",
|
99
|
+
spa: "Nota",
|
100
|
+
swe: ["Anm. \\d till termpost", "Anm. \\d till terpost", "Anm."]
|
101
|
+
}
|
102
|
+
|
103
|
+
# To match Chinese and Japanese numerals
|
104
|
+
ALL_FULL_HALF_WIDTH_NUMBERS = "[0-90-9]"
|
105
|
+
|
106
|
+
def add_example(example)
|
107
|
+
c = clean_prefixed_string(example, EXAMPLE_PREFIXES)
|
108
|
+
@examples << c
|
109
|
+
end
|
110
|
+
|
111
|
+
def add_note(note)
|
112
|
+
c = clean_prefixed_string(note, NOTE_PREFIXES)
|
113
|
+
@notes << c
|
114
|
+
end
|
115
|
+
|
116
|
+
def clean_prefixed_string(string, criterion_map)
|
117
|
+
carry = string.strip
|
118
|
+
criterion_map.values.flatten.each do |mat|
|
119
|
+
# puts "example string: #{carry}, mat: #{mat}"
|
120
|
+
|
121
|
+
# puts "note string: #{carry}, mat: #{mat}"
|
122
|
+
# if @id == 318 and mat == "Nota" and string == "NOTA 1 Una operación tiene un nombre y una lista de parámetros."
|
123
|
+
# require "pry"
|
124
|
+
# binding.pry
|
125
|
+
# end
|
126
|
+
|
127
|
+
carry = carry.sub(
|
128
|
+
Regexp.new(
|
129
|
+
"^#{mat}\s*[#{STRIP_PUNCTUATION.join('')}]?" +
|
130
|
+
"\s*#{ALL_FULL_HALF_WIDTH_NUMBERS}*\s*"+
|
131
|
+
"[#{STRIP_PUNCTUATION.join('')}]?\s*",
|
132
|
+
Regexp::IGNORECASE
|
133
|
+
),
|
134
|
+
'')
|
135
|
+
end
|
136
|
+
|
137
|
+
carry
|
138
|
+
end
|
139
|
+
|
140
|
+
|
54
141
|
# The termid should ALWAYS be an integer.
|
55
142
|
# https://github.com/riboseinc/tc211-termbase/issues/1
|
56
143
|
def id=(newid)
|