tc211-termbase 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.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: '049c87340f58462f36a45c0978834fa683de647e72af78a55c2d555fc7ea09aa'
4
- data.tar.gz: 2b2c751263666da6a923c23e806b6c40cac19e341302d0de2a61033b53362894
3
+ metadata.gz: 76f28b674292d0635730a89b8b2ce2d474d7c89025461e6617a06bcdb456c5d0
4
+ data.tar.gz: 22b29329630f7c9c33f4ac0488ce449665950b2ed988a628c427265986bdccbe
5
5
  SHA512:
6
- metadata.gz: a2a74af7f537f2220380174f965fa83f3daedc837d19796c831ad7dcf4125cb3b654dfa9be6e2e8505e70431e0c2739efd2f148fae918506806aab26f79bda67
7
- data.tar.gz: ebc860160347076c9a14f1caaef7172e06a5c686d80524b18325ef23fd98782b2135f6643d60d0d9447ee9ff9757e50ec8b8acc961ebbd28178e50b6193863b0
6
+ metadata.gz: 4108f4b967b3d95aebd2c93e20b57a45f9af634b3851a1c052ddb66e3fe34c925db6a257249fae2b18351c5b03c1222ab5ff712ff5404e01c2a5f790de1f1a87
7
+ data.tar.gz: e24326cb32164e923f19db96d4cb4fbb516e02f1509cda8da52e04dd4004385c7327fae9a8a275c926e32ad4a7f8479d351d4a2d1f5c0a0f6e0bbf7249d7c6b1
@@ -1,7 +1,7 @@
1
1
  PATH
2
2
  remote: .
3
3
  specs:
4
- tc211-termbase (0.1.8)
4
+ tc211-termbase (0.1.9)
5
5
  creek
6
6
  iso-639
7
7
  relaton (~> 0.5)
@@ -39,9 +39,9 @@ class Term
39
39
  next unless v
40
40
  case k
41
41
  when /^example/
42
- @examples << v
42
+ add_example(v)
43
43
  when /^note/
44
- @notes << v
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)
@@ -1,5 +1,5 @@
1
1
  module Tc211
2
2
  module Termbase
3
- VERSION = "0.1.8"
3
+ VERSION = "0.1.9"
4
4
  end
5
5
  end
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: tc211-termbase
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.1.8
4
+ version: 0.1.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Ribose