lingo 1.8.4.2 → 1.8.5
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/ChangeLog +413 -325
- data/README +380 -131
- data/Rakefile +19 -21
- data/de/lingo-abk.txt +15 -17
- data/de/lingo-dic.txt +20210 -20659
- data/de/lingo-mul.txt +5 -13
- data/de/lingo-syn.txt +5 -8
- data/de/test_dic.txt +2 -0
- data/de/test_gen.txt +8 -0
- data/de/{test_mul2.txt → test_mu2.txt} +0 -0
- data/de/{test_singleword.txt → test_sgw.txt} +0 -0
- data/de/user-dic.txt +5 -7
- data/de.lang +64 -49
- data/en/lingo-dic.txt +6398 -6404
- data/en/lingo-irr.txt +2 -3
- data/en/lingo-mul.txt +6 -7
- data/en/lingo-wdn.txt +881 -1762
- data/en/user-dic.txt +2 -5
- data/en.lang +39 -39
- data/lib/lingo/app.rb +10 -6
- data/lib/lingo/attendee/abbreviator.rb +1 -0
- data/lib/lingo/attendee/decomposer.rb +2 -1
- data/lib/lingo/attendee/multi_worder.rb +5 -6
- data/lib/lingo/attendee/stemmer.rb +1 -1
- data/lib/lingo/attendee/synonymer.rb +4 -2
- data/lib/lingo/attendee/text_reader.rb +77 -57
- data/lib/lingo/attendee/text_writer.rb +1 -1
- data/lib/lingo/attendee/tokenizer.rb +101 -50
- data/lib/lingo/attendee/variator.rb +2 -1
- data/lib/lingo/attendee/vector_filter.rb +28 -6
- data/lib/lingo/attendee/word_searcher.rb +2 -1
- data/lib/lingo/attendee.rb +8 -4
- data/lib/lingo/call.rb +7 -3
- data/lib/lingo/cli.rb +8 -16
- data/lib/lingo/config.rb +11 -6
- data/lib/lingo/ctl.rb +54 -3
- data/lib/lingo/database/crypter.rb +8 -14
- data/lib/lingo/database/hash_store.rb +1 -1
- data/lib/lingo/database/{show_progress.rb → progress.rb} +7 -8
- data/lib/lingo/database/source/key_value.rb +6 -5
- data/lib/lingo/database/source/multi_key.rb +5 -2
- data/lib/lingo/database/source/multi_value.rb +6 -4
- data/lib/lingo/database/source/single_word.rb +2 -3
- data/lib/lingo/database/source/word_class.rb +24 -5
- data/lib/lingo/database/source.rb +5 -3
- data/lib/lingo/database.rb +102 -41
- data/lib/lingo/error.rb +24 -2
- data/lib/lingo/language/dictionary.rb +26 -54
- data/lib/lingo/language/grammar.rb +19 -23
- data/lib/lingo/language/lexical.rb +5 -1
- data/lib/lingo/language/lexical_hash.rb +7 -12
- data/lib/lingo/language/token.rb +10 -1
- data/lib/lingo/language/word.rb +35 -23
- data/lib/lingo/language/word_form.rb +5 -4
- data/lib/lingo/{show_progress.rb → progress.rb} +43 -30
- data/lib/lingo/srv/lingosrv.cfg +1 -1
- data/lib/lingo/srv/public/.gitkeep +0 -0
- data/lib/lingo/srv.rb +11 -6
- data/lib/lingo/version.rb +2 -2
- data/lib/lingo/web/lingoweb.cfg +1 -1
- data/lib/lingo/web/views/index.erb +4 -4
- data/lib/lingo/web.rb +4 -6
- data/lib/lingo.rb +4 -12
- data/lingo.cfg +1 -1
- data/lir.cfg +1 -1
- data/ru/lingo-dic.txt +33473 -2113
- data/ru/lingo-mul.txt +8430 -1913
- data/ru/lingo-syn.txt +1634 -0
- data/ru/user-dic.txt +6 -0
- data/ru.lang +49 -47
- data/spec/spec_helper.rb +4 -0
- data/test/attendee/ts_decomposer.rb +2 -2
- data/test/attendee/ts_synonymer.rb +3 -3
- data/test/attendee/ts_tokenizer.rb +215 -2
- data/test/attendee/ts_variator.rb +2 -2
- data/test/attendee/ts_word_searcher.rb +10 -6
- data/test/ref/artikel.seq +2 -2
- data/test/ref/artikel.vec +5 -5
- data/test/ref/artikel.ven +11 -11
- data/test/ref/artikel.ver +11 -11
- data/test/ref/lir.seq +13 -13
- data/test/ref/lir.vec +31 -31
- data/test/test_helper.rb +19 -5
- data/test/ts_database.rb +206 -77
- data/test/ts_language.rb +86 -26
- metadata +93 -49
- data/.rspec +0 -1
- data/de/test_syn2.txt +0 -1
@@ -6,7 +6,7 @@
|
|
6
6
|
# Lingo -- A full-featured automatic indexing system #
|
7
7
|
# #
|
8
8
|
# Copyright (C) 2005-2007 John Vorhauer #
|
9
|
-
# Copyright (C) 2007-
|
9
|
+
# Copyright (C) 2007-2013 John Vorhauer, Jens Wille #
|
10
10
|
# #
|
11
11
|
# Lingo is free software; you can redistribute it and/or modify it under the #
|
12
12
|
# terms of the GNU Affero General Public License as published by the Free #
|
@@ -46,7 +46,7 @@ class Lingo
|
|
46
46
|
def initialize(config, lingo)
|
47
47
|
@dic, @suggestions = Dictionary.new(config, lingo), []
|
48
48
|
|
49
|
-
lingo.deprecate(:compositum, :compound, self) if lingo.dictionary_config.
|
49
|
+
lingo.deprecate(:compositum, :compound, self) if lingo.dictionary_config.key?('compositum')
|
50
50
|
|
51
51
|
cfg = lingo.dictionary_config['compound'] ||
|
52
52
|
lingo.dictionary_config['compositum'] # DEPRECATE compositum
|
@@ -79,16 +79,9 @@ class Lingo
|
|
79
79
|
# find_compound arbeitet in verschiedenen Leveln, da die Methode auch rekursiv aufgerufen wird. Ein Level größer 1
|
80
80
|
# entspricht daher einem rekursiven Aufruf
|
81
81
|
def find_compound(str, level = 1, tail = false)
|
82
|
-
|
83
|
-
|
84
|
-
|
85
|
-
com = Word.new(str, WA_UNKNOWN), str, level, tail
|
86
|
-
) { |lex|
|
87
|
-
com.attr = WA_COMPOUND
|
88
|
-
com.lexicals = lex.each { |l|
|
89
|
-
l.attr += @append_wc unless l.attr == LA_COMPOUND
|
90
|
-
}
|
91
|
-
}
|
82
|
+
level == 1 ? (@_compound ||= {})[str] ||=
|
83
|
+
permute_compound(Word.new(str, WA_UNKNOWN), str, level, tail) :
|
84
|
+
permute_compound([[], [], ''], str, level, tail)
|
92
85
|
end
|
93
86
|
|
94
87
|
private
|
@@ -115,7 +108,9 @@ class Lingo
|
|
115
108
|
}
|
116
109
|
end
|
117
110
|
|
118
|
-
|
111
|
+
level > 1 ? ret = res : ret.identify(lex.each { |l|
|
112
|
+
l.attr += @append_wc unless l.attr == LA_COMPOUND
|
113
|
+
}, WA_COMPOUND) if !lex.empty? &&
|
119
114
|
sta.size <= @max_parts &&
|
120
115
|
sta.min >= @min_part_size &&
|
121
116
|
str.length / sta.size >= @min_avg_part_size &&
|
@@ -131,16 +126,16 @@ class Lingo
|
|
131
126
|
def test_compound(fstr, infix, bstr, level = 1, tail = false)
|
132
127
|
sta, seq, empty = [fstr.length, bstr.length], %w[? ?], [[], [], '']
|
133
128
|
|
134
|
-
if !
|
129
|
+
if !(blex = @dic.select_with_suffix(bstr)).empty?
|
135
130
|
# 1. Word w/ suffix
|
136
131
|
bform, seq[1] = tail ? bstr : blex.first.form, blex.first.attr
|
137
|
-
elsif tail && !
|
132
|
+
elsif tail && !(blex = @dic.select_with_infix(bstr)).empty?
|
138
133
|
# 2. Word w/ infix, unless tail part
|
139
134
|
bform, seq[1] = bstr, blex.first.attr
|
140
135
|
elsif infix == '-'
|
141
136
|
blex, bsta, bseq = find_compound(bstr, level + 1, tail)
|
142
137
|
|
143
|
-
if !
|
138
|
+
if !blex.empty?
|
144
139
|
# 3. Compound
|
145
140
|
bform, seq[1], sta[1..-1] = blex.first.form, bseq, bsta
|
146
141
|
else
|
@@ -151,13 +146,13 @@ class Lingo
|
|
151
146
|
return empty
|
152
147
|
end
|
153
148
|
|
154
|
-
if !
|
149
|
+
if !(flex = @dic.select_with_infix(fstr)).empty?
|
155
150
|
# 1. Word w/ infix
|
156
151
|
fform, seq[0] = fstr, flex.first.attr
|
157
152
|
else
|
158
153
|
flex, fsta, fseq = find_compound(fstr, level + 1, true)
|
159
154
|
|
160
|
-
if !
|
155
|
+
if !flex.empty?
|
161
156
|
# 2. Compound
|
162
157
|
fform, seq[0], sta[0..0] = flex.first.form, fseq, fsta
|
163
158
|
elsif infix == '-'
|
@@ -168,14 +163,15 @@ class Lingo
|
|
168
163
|
end
|
169
164
|
end
|
170
165
|
|
171
|
-
|
172
|
-
|
166
|
+
forms = [[flex, fform], [blex, bform]].each { |ary|
|
167
|
+
ary.shift.each { |lex| lex.src ||= ary.first }
|
173
168
|
}
|
174
169
|
|
175
|
-
flex.concat(blex).delete_if { |
|
176
|
-
push(Lexical.new(fform + infix + bform, LA_COMPOUND))
|
170
|
+
flex.concat(blex).delete_if { |lex| lex.attr == LA_COMPOUND }
|
177
171
|
|
178
|
-
[
|
172
|
+
[forms.shift.product(*forms).map { |front, back|
|
173
|
+
Lexical.new(front + infix + back, LA_COMPOUND)
|
174
|
+
}.concat(flex), sta, seq.join]
|
179
175
|
end
|
180
176
|
|
181
177
|
end
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Lingo -- A full-featured automatic indexing system #
|
7
7
|
# #
|
8
8
|
# Copyright (C) 2005-2007 John Vorhauer #
|
9
|
-
# Copyright (C) 2007-
|
9
|
+
# Copyright (C) 2007-2014 John Vorhauer, Jens Wille #
|
10
10
|
# #
|
11
11
|
# Lingo is free software; you can redistribute it and/or modify it under the #
|
12
12
|
# terms of the GNU Affero General Public License as published by the Free #
|
@@ -36,6 +36,10 @@ class Lingo
|
|
36
36
|
|
37
37
|
class Lexical < WordForm
|
38
38
|
|
39
|
+
def attr?(attr)
|
40
|
+
self.attr.start_with?(attr)
|
41
|
+
end
|
42
|
+
|
39
43
|
def <=>(other)
|
40
44
|
return 1 unless other.is_a?(self.class)
|
41
45
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Lingo -- A full-featured automatic indexing system #
|
7
7
|
# #
|
8
8
|
# Copyright (C) 2005-2007 John Vorhauer #
|
9
|
-
# Copyright (C) 2007-
|
9
|
+
# Copyright (C) 2007-2014 John Vorhauer, Jens Wille #
|
10
10
|
# #
|
11
11
|
# Lingo is free software; you can redistribute it and/or modify it under the #
|
12
12
|
# terms of the GNU Affero General Public License as published by the Free #
|
@@ -34,6 +34,8 @@ class Lingo
|
|
34
34
|
|
35
35
|
class LexicalHash
|
36
36
|
|
37
|
+
KEY_REF_RE = %r{\A#{Regexp.escape(Database::KEY_REF)}(\d+)\z}o
|
38
|
+
|
37
39
|
def self.open(*args)
|
38
40
|
yield lexical_hash = new(*args)
|
39
41
|
ensure
|
@@ -41,7 +43,6 @@ class Lingo
|
|
41
43
|
end
|
42
44
|
|
43
45
|
def initialize(id, lingo)
|
44
|
-
@wc = lingo.database_config(id).fetch('def-wc', LA_UNKNOWN)
|
45
46
|
@src = Database.open(id, lingo)
|
46
47
|
end
|
47
48
|
|
@@ -50,22 +51,16 @@ class Lingo
|
|
50
51
|
end
|
51
52
|
|
52
53
|
def [](key)
|
53
|
-
rec = @src[
|
54
|
+
rec = @src[Unicode.downcase(key)] or return
|
54
55
|
|
55
56
|
res = rec.map { |str|
|
56
|
-
|
57
|
-
|
58
|
-
|
59
|
-
when /^([^#]+?)\s*#(.)$/ then Lexical.new($1, $2)
|
60
|
-
when /^([^#]+)$/ then Lexical.new($1, @wc)
|
61
|
-
else str
|
57
|
+
str =~ KEY_REF_RE ? $1.to_i : begin
|
58
|
+
k, *w = str.split('#')
|
59
|
+
Lexical.new(k.strip, w)
|
62
60
|
end
|
63
61
|
}
|
64
62
|
|
65
|
-
res.compact!
|
66
|
-
res.sort!
|
67
63
|
res.uniq!
|
68
|
-
|
69
64
|
res
|
70
65
|
end
|
71
66
|
|
data/lib/lingo/language/token.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Lingo -- A full-featured automatic indexing system #
|
7
7
|
# #
|
8
8
|
# Copyright (C) 2005-2007 John Vorhauer #
|
9
|
-
# Copyright (C) 2007-
|
9
|
+
# Copyright (C) 2007-2014 John Vorhauer, Jens Wille #
|
10
10
|
# #
|
11
11
|
# Lingo is free software; you can redistribute it and/or modify it under the #
|
12
12
|
# terms of the GNU Affero General Public License as published by the Free #
|
@@ -37,6 +37,15 @@ class Lingo
|
|
37
37
|
|
38
38
|
class Token < WordForm
|
39
39
|
|
40
|
+
def self.clean(attr)
|
41
|
+
attr.sub(/:.*/, '')
|
42
|
+
end
|
43
|
+
|
44
|
+
def initialize(*)
|
45
|
+
super
|
46
|
+
@attr = self.class.clean(attr)
|
47
|
+
end
|
48
|
+
|
40
49
|
def word?
|
41
50
|
attr == TA_WORD
|
42
51
|
end
|
data/lib/lingo/language/word.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Lingo -- A full-featured automatic indexing system #
|
7
7
|
# #
|
8
8
|
# Copyright (C) 2005-2007 John Vorhauer #
|
9
|
-
# Copyright (C) 2007-
|
9
|
+
# Copyright (C) 2007-2013 John Vorhauer, Jens Wille #
|
10
10
|
# #
|
11
11
|
# Lingo is free software; you can redistribute it and/or modify it under the #
|
12
12
|
# terms of the GNU Affero General Public License as published by the Free #
|
@@ -43,6 +43,20 @@ class Lingo
|
|
43
43
|
new_lexicals(form, attr, Lexical.new(form, lex_attr))
|
44
44
|
end
|
45
45
|
|
46
|
+
def new_compound_head(lex, attr = WA_UNSET)
|
47
|
+
form, head_lex = nil, []
|
48
|
+
|
49
|
+
lex.reverse_each { |l|
|
50
|
+
src = l.src ||= l.form
|
51
|
+
form ||= src
|
52
|
+
form != src ? break : head_lex.unshift(l.dup)
|
53
|
+
}
|
54
|
+
|
55
|
+
head_lex.each { |l| l.attr = l.attr[/\w+/] }.uniq!
|
56
|
+
|
57
|
+
new_lexicals(form, attr, head_lex) if form
|
58
|
+
end
|
59
|
+
|
46
60
|
end
|
47
61
|
|
48
62
|
# Exakte Representation der originären Zeichenkette, so wie sie im Satz
|
@@ -63,6 +77,8 @@ class Lingo
|
|
63
77
|
@lexicals = []
|
64
78
|
end
|
65
79
|
|
80
|
+
attr_writer :lexicals
|
81
|
+
|
66
82
|
def lexicals(compound_parts = true)
|
67
83
|
if !compound_parts && attr == WA_COMPOUND
|
68
84
|
@lexicals.select { |lex| lex.attr == LA_COMPOUND }
|
@@ -71,31 +87,30 @@ class Lingo
|
|
71
87
|
end
|
72
88
|
end
|
73
89
|
|
74
|
-
def
|
75
|
-
|
76
|
-
@lexicals = Lingo.sort(lex).uniq
|
77
|
-
else
|
78
|
-
raise TypeError, "wrong argument type #{lex.class} (expected Array)"
|
79
|
-
end
|
90
|
+
def add_lexicals(lex)
|
91
|
+
@lexicals.concat(lex - @lexicals)
|
80
92
|
end
|
81
93
|
|
82
|
-
def
|
83
|
-
|
84
|
-
@lexicals.concat(lex).uniq!
|
85
|
-
Lingo.sort!(@lexicals)
|
86
|
-
end
|
94
|
+
def attr?(*attr)
|
95
|
+
!(attrs & attr).empty?
|
87
96
|
end
|
88
97
|
|
89
98
|
def attrs(compound_parts = true)
|
90
99
|
lexicals(compound_parts).map { |i| i.attr }
|
91
100
|
end
|
92
101
|
|
93
|
-
def
|
94
|
-
|
102
|
+
def genders(compound_parts = true)
|
103
|
+
lexicals(compound_parts).map { |i| i.gender }
|
95
104
|
end
|
96
105
|
|
97
|
-
def
|
98
|
-
|
106
|
+
def identify(lex, wc = nil)
|
107
|
+
return self if lex.empty?
|
108
|
+
|
109
|
+
self.lexicals = lex
|
110
|
+
self.attr = wc ||= attr?(LA_COMPOUND) ? WA_COMPOUND : WA_IDENTIFIED
|
111
|
+
self.head = self.class.new_compound_head(lex) if wc == WA_COMPOUND
|
112
|
+
|
113
|
+
self
|
99
114
|
end
|
100
115
|
|
101
116
|
# Gibt genau die Grundform der Wortklasse zurück, die der RegExp des Übergabe-Parameters
|
@@ -103,11 +118,8 @@ class Lingo
|
|
103
118
|
def get_class(wc_re)
|
104
119
|
wc_re = Regexp.new(wc_re) unless wc_re.is_a?(Regexp)
|
105
120
|
|
106
|
-
|
121
|
+
lexicals.empty? ? attr =~ wc_re ? [self] : [] :
|
107
122
|
lexicals.select { |lex| lex.attr =~ wc_re }
|
108
|
-
else
|
109
|
-
attr =~ wc_re ? [self] : []
|
110
|
-
end
|
111
123
|
end
|
112
124
|
|
113
125
|
def norm
|
@@ -126,9 +138,9 @@ class Lingo
|
|
126
138
|
lex = get_class(wc_re).first and lex.form.count(' ') + 1
|
127
139
|
end
|
128
140
|
|
129
|
-
def <<(*
|
130
|
-
|
131
|
-
lexicals.concat(
|
141
|
+
def <<(*lex)
|
142
|
+
lex.flatten!
|
143
|
+
@lexicals.concat(lex)
|
132
144
|
self
|
133
145
|
end
|
134
146
|
|
@@ -6,7 +6,7 @@
|
|
6
6
|
# Lingo -- A full-featured automatic indexing system #
|
7
7
|
# #
|
8
8
|
# Copyright (C) 2005-2007 John Vorhauer #
|
9
|
-
# Copyright (C) 2007-
|
9
|
+
# Copyright (C) 2007-2013 John Vorhauer, Jens Wille #
|
10
10
|
# #
|
11
11
|
# Lingo is free software; you can redistribute it and/or modify it under the #
|
12
12
|
# terms of the GNU Affero General Public License as published by the Free #
|
@@ -36,12 +36,13 @@ class Lingo
|
|
36
36
|
|
37
37
|
include Comparable
|
38
38
|
|
39
|
-
attr_accessor :form, :attr, :src
|
40
|
-
|
41
39
|
def initialize(form, attr = WA_UNSET, src = nil)
|
40
|
+
attr, @gender = attr
|
42
41
|
@form, @attr, @src = form || '', attr || '', src
|
43
42
|
end
|
44
43
|
|
44
|
+
attr_accessor :form, :attr, :gender, :src, :head
|
45
|
+
|
45
46
|
def unknown?
|
46
47
|
[WA_UNKNOWN, WA_UNKMULPART].include?(attr)
|
47
48
|
end
|
@@ -55,7 +56,7 @@ class Lingo
|
|
55
56
|
end
|
56
57
|
|
57
58
|
def to_a
|
58
|
-
[form, attr]
|
59
|
+
[form, attr, gender].compact
|
59
60
|
end
|
60
61
|
|
61
62
|
def to_s
|
@@ -26,53 +26,66 @@
|
|
26
26
|
|
27
27
|
class Lingo
|
28
28
|
|
29
|
-
class
|
29
|
+
class Progress
|
30
30
|
|
31
|
-
def initialize(obj, max, name = nil, doit = true, text = 'progress', nl = true)
|
32
|
-
|
31
|
+
def initialize(obj, max, name = nil, doit = true, text = 'progress', nl = true, &block)
|
32
|
+
@doit, @out = doit, obj.lingo.config.stderr
|
33
33
|
|
34
|
-
|
34
|
+
if max && doit
|
35
|
+
format = ' [%3d%%]'
|
36
|
+
length = (format % 0).length
|
35
37
|
|
36
|
-
|
37
|
-
|
38
|
-
fmt = ' [%3d%%]'
|
39
|
-
len = (fmt % 0).length
|
38
|
+
erase = "\b" * length
|
39
|
+
@format = format + erase
|
40
40
|
|
41
|
-
|
42
|
-
|
43
|
-
back = "\b" * len
|
41
|
+
print name, ': ' if name
|
42
|
+
print text
|
44
43
|
|
45
|
-
|
46
|
-
@clr = ' ' * len + back
|
44
|
+
init(max)
|
47
45
|
|
48
|
-
|
46
|
+
msg = %w[done aborted]
|
47
|
+
end
|
48
|
+
|
49
|
+
suc = false
|
50
|
+
|
51
|
+
res = catch(:cancel) {
|
52
|
+
int = trap(:INT) { throw(:cancel) }
|
49
53
|
|
50
|
-
|
51
|
-
|
52
|
-
|
54
|
+
begin
|
55
|
+
yield self
|
56
|
+
ensure
|
57
|
+
trap(:INT, &int)
|
58
|
+
end
|
53
59
|
|
54
|
-
|
60
|
+
suc = true
|
61
|
+
nil
|
62
|
+
}
|
55
63
|
|
56
|
-
print
|
57
|
-
print "\n" if
|
64
|
+
print ' ' * length + erase, ' ', msg[suc ? 0 : 1], '.' if msg
|
65
|
+
print "\n" if msg && res
|
66
|
+
|
67
|
+
print Array(res).join("\n") if res
|
68
|
+
print "\n" if nl && (msg || res)
|
58
69
|
end
|
59
70
|
|
60
|
-
def
|
61
|
-
if
|
62
|
-
@
|
63
|
-
|
71
|
+
def init(max, doit = @doit)
|
72
|
+
if max && doit
|
73
|
+
@ratio, @next = max / 100.0, 0
|
74
|
+
self << @count = 0
|
64
75
|
end
|
65
76
|
end
|
66
77
|
|
67
|
-
|
78
|
+
def <<(value)
|
79
|
+
if defined?(@count) && (@count = value) >= @next
|
80
|
+
percent = @count / @ratio
|
81
|
+
@next = (percent + 1) * @ratio
|
68
82
|
|
69
|
-
|
70
|
-
|
71
|
-
@next = (percent + 1) * @rat
|
72
|
-
|
73
|
-
print @fmt % percent if percent.finite?
|
83
|
+
print @format % percent if percent.finite?
|
84
|
+
end
|
74
85
|
end
|
75
86
|
|
87
|
+
private
|
88
|
+
|
76
89
|
def print(*args)
|
77
90
|
@out.print(*args)
|
78
91
|
end
|
data/lib/lingo/srv/lingosrv.cfg
CHANGED
File without changes
|
data/lib/lingo/srv.rb
CHANGED
@@ -42,6 +42,11 @@ class Lingo
|
|
42
42
|
get('/') { doit }
|
43
43
|
post('/') { doit }
|
44
44
|
|
45
|
+
post('/raw') {
|
46
|
+
content_type :text
|
47
|
+
LINGO.talk(request.body, true)
|
48
|
+
}
|
49
|
+
|
45
50
|
def doit
|
46
51
|
to_json(q = params[:q], case q
|
47
52
|
when String then talk(q)
|
@@ -53,14 +58,14 @@ class Lingo
|
|
53
58
|
r = LINGO.talk(q) unless q.empty?
|
54
59
|
return r unless r && SRC_SEP
|
55
60
|
|
56
|
-
|
57
|
-
|
61
|
+
s = Hash.new { |h, k| h[k] = [] }
|
62
|
+
|
63
|
+
r.each { |t|
|
64
|
+
a, b = t.split(SRC_SEP, 2)
|
65
|
+
s[b] << a
|
58
66
|
}
|
59
|
-
end
|
60
67
|
|
61
|
-
|
62
|
-
alias_method :_talk, :talk
|
63
|
-
def talk(q) _talk(q).to_a end
|
68
|
+
ENV['LINGO_NO_SORT'] ? s.to_a : s
|
64
69
|
end
|
65
70
|
|
66
71
|
end
|
data/lib/lingo/version.rb
CHANGED
data/lib/lingo/web/lingoweb.cfg
CHANGED
@@ -41,18 +41,18 @@
|
|
41
41
|
<form action="<%= url_for '/' %>" method="post">
|
42
42
|
<div>
|
43
43
|
<fieldset><legend><strong><%= t 'Input', 'Eingabe', 'ввод данных' %></strong></legend>
|
44
|
-
<textarea name="q" rows="20" cols="50"><%= @q %></textarea>
|
44
|
+
<textarea name="q" rows="20" cols="50"><%=h @q %></textarea>
|
45
45
|
</fieldset>
|
46
46
|
|
47
47
|
<fieldset><legend><strong><%= t 'Output', 'Ausgabe', 'вывод данных' %></strong></legend>
|
48
|
-
<textarea readonly="readonly" rows="20" cols="50"><%= @r %></textarea>
|
48
|
+
<textarea readonly="readonly" rows="20" cols="50"><%=h @r %></textarea>
|
49
49
|
</fieldset>
|
50
50
|
|
51
51
|
<br />
|
52
52
|
|
53
53
|
<strong><%= t 'Language', 'Sprache', 'язык' %></strong> = <select name="l">
|
54
54
|
<% for l in L %>
|
55
|
-
<option value="<%= l %>"<%= ' selected="selected"' if l == @l %>><%= l %></option>
|
55
|
+
<option value="<%=h l %>"<%= ' selected="selected"' if l == @l %>><%=h l %></option>
|
56
56
|
<% end %>
|
57
57
|
</select>
|
58
58
|
|
@@ -144,7 +144,7 @@
|
|
144
144
|
<div id="footer">
|
145
145
|
<em>powered by</em> <a href="http://lex-lingo.de">Lingo</a>
|
146
146
|
<em>and</em> <a href="http://www.sinatrarb.com">Sinatra</a>
|
147
|
-
|
147
|
+
— <strong>v<%=h Lingo::VERSION %></strong>
|
148
148
|
</div>
|
149
149
|
</body>
|
150
150
|
</html>
|
data/lib/lingo/web.rb
CHANGED
@@ -6,7 +6,7 @@
|
|
6
6
|
# Lingo -- A full-featured automatic indexing system #
|
7
7
|
# #
|
8
8
|
# Copyright (C) 2005-2007 John Vorhauer #
|
9
|
-
# Copyright (C) 2007-
|
9
|
+
# Copyright (C) 2007-2014 John Vorhauer, Jens Wille #
|
10
10
|
# #
|
11
11
|
# Lingo is free software; you can redistribute it and/or modify it under the #
|
12
12
|
# terms of the GNU Affero General Public License as published by the Free #
|
@@ -50,8 +50,8 @@ class Lingo
|
|
50
50
|
|
51
51
|
LINGO = Hash.new { |h, k| h[k] = Lingo.call(cfg, ['-l', k]) }
|
52
52
|
|
53
|
-
CFG, s = '', StringScanner.new('')
|
54
|
-
c = lambda { |n| %Q{<span style="color:#{n}">#{s.matched}</span>} }
|
53
|
+
CFG, s, h = '', StringScanner.new(''), ERB::Util.method(:h)
|
54
|
+
c = lambda { |n| %Q{<span style="color:#{n}">#{h[s.matched]}</span>} }
|
55
55
|
|
56
56
|
File.foreach(cfg) { |line|
|
57
57
|
s.string = line.chomp
|
@@ -79,13 +79,11 @@ class Lingo
|
|
79
79
|
}
|
80
80
|
|
81
81
|
before do
|
82
|
-
@hl = if v = params[:hl] ||
|
82
|
+
@hl = if v = params[:hl] || env['HTTP_ACCEPT_LANGUAGE']
|
83
83
|
v = v.split(',').map { |l| l.split('-').first.strip }
|
84
84
|
(v & HL).first
|
85
85
|
end || HL.first
|
86
86
|
|
87
|
-
cookies[:hl] = @hl unless cookies[:hl] == @hl
|
88
|
-
|
89
87
|
@q = params[:q]
|
90
88
|
@l = params[:l] || @hl
|
91
89
|
@l = L.first unless L.include?(@l)
|
data/lib/lingo.rb
CHANGED
@@ -65,14 +65,6 @@ class Lingo
|
|
65
65
|
|
66
66
|
class << self
|
67
67
|
|
68
|
-
if ENV['LINGO_NO_SORT']
|
69
|
-
def sort!(x) x end
|
70
|
-
def sort(x) x.dup end
|
71
|
-
else
|
72
|
-
def sort!(x) x.sort! end
|
73
|
-
def sort(x) x.sort end
|
74
|
-
end
|
75
|
-
|
76
68
|
def talk(*args)
|
77
69
|
new(*args).talk
|
78
70
|
end
|
@@ -242,18 +234,18 @@ class Lingo
|
|
242
234
|
|
243
235
|
def config
|
244
236
|
@config ||= Config.new(*@config_args)
|
237
|
+
rescue => err
|
238
|
+
raise ConfigLoadError.new(err)
|
245
239
|
end
|
246
240
|
|
247
241
|
def dictionary_config
|
248
242
|
@dictionary_config ||= config['language/dictionary']
|
249
|
-
rescue => err
|
250
|
-
raise ConfigLoadError.new(err)
|
251
243
|
end
|
252
244
|
|
253
245
|
def database_config(id)
|
254
246
|
dictionary_config['databases'][id].tap { |cfg|
|
255
247
|
raise NoDatabaseConfigError.new(id) unless cfg
|
256
|
-
raise InvalidDatabaseConfigError.new(id) unless cfg.
|
248
|
+
raise InvalidDatabaseConfigError.new(id) unless cfg.key?('name')
|
257
249
|
}
|
258
250
|
end
|
259
251
|
|
@@ -327,7 +319,7 @@ require_relative 'lingo/error'
|
|
327
319
|
require_relative 'lingo/debug'
|
328
320
|
require_relative 'lingo/config'
|
329
321
|
require_relative 'lingo/agenda_item'
|
330
|
-
require_relative 'lingo/
|
322
|
+
require_relative 'lingo/progress'
|
331
323
|
require_relative 'lingo/database'
|
332
324
|
require_relative 'lingo/language'
|
333
325
|
require_relative 'lingo/attendee'
|
data/lingo.cfg
CHANGED
@@ -52,7 +52,7 @@ meeting:
|
|
52
52
|
########################################
|
53
53
|
# Datenstrom anzeigen
|
54
54
|
#
|
55
|
-
# - debugger: { eval: 'true', ceval: 'cmd!="EOL"', prompt: 'lex:) ' }
|
55
|
+
# - debugger: { eval: 'true', ceval: 'obj.cmd!="EOL"', prompt: 'lex:) ' }
|
56
56
|
|
57
57
|
|
58
58
|
########################################
|
data/lir.cfg
CHANGED
@@ -57,7 +57,7 @@ meeting:
|
|
57
57
|
########################################
|
58
58
|
# Datenstrom anzeigen
|
59
59
|
#
|
60
|
-
# - debugger: { eval: 'true', ceval: 'cmd!="EOL"', prompt: 'lex:) ' }
|
60
|
+
# - debugger: { eval: 'true', ceval: 'obj.cmd!="EOL"', prompt: 'lex:) ' }
|
61
61
|
|
62
62
|
|
63
63
|
########################################
|