lingo 1.8.6 → 1.8.7

Sign up to get free protection for your applications and to get access to all the features.
Files changed (75) hide show
  1. checksums.yaml +4 -4
  2. data/ChangeLog +40 -4
  3. data/README +22 -51
  4. data/Rakefile +3 -17
  5. data/config/lingo.cfg +24 -15
  6. data/config/lir.cfg +25 -16
  7. data/dict/de/test_muh.txt +6 -0
  8. data/dict/en/lingo-dic.txt +2 -3
  9. data/lang/de.lang +10 -9
  10. data/lang/en.lang +1 -1
  11. data/lib/lingo.rb +4 -4
  12. data/lib/lingo/attendee.rb +27 -7
  13. data/lib/lingo/attendee/analysis_filter.rb +81 -0
  14. data/lib/lingo/attendee/debug_filter.rb +42 -0
  15. data/lib/lingo/attendee/debugger.rb +2 -11
  16. data/lib/lingo/attendee/decomposer.rb +6 -3
  17. data/lib/lingo/attendee/formatter.rb +6 -6
  18. data/lib/lingo/attendee/hal_filter.rb +94 -0
  19. data/lib/lingo/attendee/lsi_filter.rb +99 -0
  20. data/lib/lingo/attendee/multi_worder.rb +69 -43
  21. data/lib/lingo/attendee/sequencer.rb +32 -19
  22. data/lib/lingo/attendee/synonymer.rb +2 -2
  23. data/lib/lingo/attendee/text_reader.rb +63 -92
  24. data/lib/lingo/attendee/text_writer.rb +12 -21
  25. data/lib/lingo/attendee/tokenizer.rb +32 -21
  26. data/lib/lingo/attendee/variator.rb +3 -3
  27. data/lib/lingo/attendee/vector_filter.rb +7 -9
  28. data/lib/lingo/attendee/word_searcher.rb +3 -3
  29. data/lib/lingo/buffered_attendee.rb +3 -36
  30. data/lib/lingo/config.rb +1 -1
  31. data/lib/lingo/ctl.rb +7 -155
  32. data/lib/lingo/ctl/analysis.rb +136 -0
  33. data/lib/lingo/ctl/files.rb +86 -0
  34. data/lib/lingo/ctl/other.rb +140 -0
  35. data/lib/lingo/database.rb +64 -60
  36. data/lib/lingo/database/crypter.rb +7 -5
  37. data/lib/lingo/error.rb +5 -4
  38. data/lib/lingo/language.rb +13 -5
  39. data/lib/lingo/language/grammar.rb +13 -7
  40. data/lib/lingo/language/token.rb +6 -0
  41. data/lib/lingo/language/word.rb +23 -36
  42. data/lib/lingo/language/word_form.rb +5 -1
  43. data/lib/lingo/srv.rb +2 -2
  44. data/lib/lingo/text_utils.rb +96 -0
  45. data/lib/lingo/version.rb +1 -1
  46. data/lib/lingo/web/views/index.erb +1 -1
  47. data/test/attendee/ts_decomposer.rb +23 -5
  48. data/test/attendee/ts_multi_worder.rb +66 -0
  49. data/test/attendee/ts_sequencer.rb +28 -4
  50. data/test/attendee/ts_text_reader.rb +20 -0
  51. data/test/attendee/ts_tokenizer.rb +20 -0
  52. data/test/attendee/ts_variator.rb +1 -1
  53. data/test/attendee/ts_word_searcher.rb +39 -3
  54. data/test/lir3.txt +12 -0
  55. data/test/ref/artikel.non +1 -12
  56. data/test/ref/artikel.seq +3 -1
  57. data/test/ref/artikel.vec +1 -0
  58. data/test/ref/artikel.vef +35 -34
  59. data/test/ref/artikel.ven +8 -7
  60. data/test/ref/artikel.ver +34 -33
  61. data/test/ref/artikel.vet +2573 -2563
  62. data/test/ref/lir.non +77 -78
  63. data/test/ref/lir.seq +9 -7
  64. data/test/ref/lir.syn +1 -1
  65. data/test/ref/lir.vec +41 -41
  66. data/test/ref/lir.vef +210 -210
  67. data/test/ref/lir.ven +46 -46
  68. data/test/ref/lir.ver +72 -72
  69. data/test/ref/lir.vet +329 -329
  70. data/test/ts_database.rb +166 -62
  71. data/test/ts_language.rb +23 -23
  72. metadata +53 -34
  73. data/lib/lingo/attendee/dehyphenizer.rb +0 -120
  74. data/lib/lingo/attendee/noneword_filter.rb +0 -115
  75. data/test/attendee/ts_noneword_filter.rb +0 -15
@@ -1,120 +0,0 @@
1
- # encoding: utf-8
2
-
3
- #--
4
- ###############################################################################
5
- # #
6
- # Lingo -- A full-featured automatic indexing system #
7
- # #
8
- # Copyright (C) 2005-2007 John Vorhauer #
9
- # Copyright (C) 2007-2014 John Vorhauer, Jens Wille #
10
- # #
11
- # Lingo is free software; you can redistribute it and/or modify it under the #
12
- # terms of the GNU Affero General Public License as published by the Free #
13
- # Software Foundation; either version 3 of the License, or (at your option) #
14
- # any later version. #
15
- # #
16
- # Lingo is distributed in the hope that it will be useful, but WITHOUT ANY #
17
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
18
- # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for #
19
- # more details. #
20
- # #
21
- # You should have received a copy of the GNU Affero General Public License #
22
- # along with Lingo. If not, see <http://www.gnu.org/licenses/>. #
23
- # #
24
- ###############################################################################
25
- #++
26
-
27
- class Lingo
28
-
29
- class Attendee
30
-
31
- #--
32
- # Der Dehyphenizer ... muss noch dokumentiert werden
33
- #
34
- # === Mögliche Verlinkung
35
- # Erwartet:: Daten vom Typ *Word* z.B. von Wordsearcher, Decomposer, Ocr_variator, Multiworder
36
- # Erzeugt:: Daten vom Typ *Word* (mit Attribut WA_MULTIWORD). Je erkannter Mehrwortgruppe wird ein zusätzliches Word-Objekt in den Datenstrom eingefügt. Z.B. für Ocr_variator, Sequencer, Noneword_filter, Vector_filter
37
- #
38
- # === Parameter
39
- # Kursiv dargestellte Parameter sind optional (ggf. mit Angabe der Voreinstellung).
40
- # Alle anderen Parameter müssen zwingend angegeben werden.
41
- # <b>in</b>:: siehe allgemeine Beschreibung des Attendee
42
- # <b>out</b>:: siehe allgemeine Beschreibung des Attendee
43
- # <b>source</b>:: siehe allgemeine Beschreibung des Dictionary
44
- # <b><i>mode</i></b>:: (Standard: all) siehe allgemeine Beschreibung des Dictionary
45
- #
46
- # === Beispiele
47
- # Bei der Verarbeitung einer normalen Textdatei mit der Ablaufkonfiguration <tt>t1.cfg</tt>
48
- # meeting:
49
- # attendees:
50
- # - text_reader: { out: lines, files: '$(files)' }
51
- # - tokenizer: { in: lines, out: token }
52
- # - abbreviator: { in: token, out: abbrev, source: 'sys-abk' }
53
- # - word_searcher: { in: abbrev, out: words, source: 'sys-dic' }
54
- # - decomposer: { in: words, out: comps, source: 'sys-dic' }
55
- # - multi_worder: { in: comps, out: multi, source: 'sys-mul' }
56
- # - debugger: { in: multi, prompt: 'out>' }
57
- # ergibt die Ausgabe über den Debugger: <tt>lingo -c t1 test.txt</tt>
58
- # out> *FILE('test.txt')
59
- # out> <Sein = [(sein/s), (sein/v)]>
60
- # out> <Name = [(name/s)]>
61
- # out> <ist = [(sein/v)]>
62
- # out> <johann van siegen|MUL = [(johann van siegen/m)]>
63
- # out> <Johann = [(johann/e)]>
64
- # out> <van = [(van/w)]>
65
- # out> <Siegen = [(sieg/s), (siegen/v), (siegen/e)]>
66
- # out> :./PUNC:
67
- # out> *EOL('test.txt')
68
- # out> *EOF('test.txt')
69
- #++
70
-
71
- class Dehyphenizer < BufferedAttendee
72
-
73
- def init
74
- set_dic
75
- set_gra
76
-
77
- @skip = get_array('skip', '', :downcase)
78
-
79
- @expected_tokens_in_buffer, @eof_handling = 2, false
80
- end
81
-
82
- def control(cmd, *)
83
- control_multi(cmd)
84
- end
85
-
86
- def process_buffer
87
- a, b, h = *ab = @buffer.values_at(0, 1), '-'
88
-
89
- if ab.all? { |i| i.is_a?(Word) } && a.form[-1, 1] == h && !(
90
- (c = b.get_class(/./).first) && @skip.include?(c.attr)
91
- )
92
- a, b = ab.map! { |i| i.form }
93
-
94
- word = dehyphenize(a.chomp(h) + b)
95
- word = dehyphenize(a + b) unless dehyphenized?(word)
96
-
97
- if dehyphenized?(word)
98
- @buffer[0] = word
99
- @buffer.delete_at(1)
100
- end
101
- end
102
-
103
- forward_number_of_token(1, false)
104
- end
105
-
106
- private
107
-
108
- def dehyphenize(form)
109
- find_word(form) { |i| i.identified? }
110
- end
111
-
112
- def dehyphenized?(word)
113
- word.identified? || word.full_compound?
114
- end
115
-
116
- end
117
-
118
- end
119
-
120
- end
@@ -1,115 +0,0 @@
1
- # encoding: utf-8
2
-
3
- #--
4
- ###############################################################################
5
- # #
6
- # Lingo -- A full-featured automatic indexing system #
7
- # #
8
- # Copyright (C) 2005-2007 John Vorhauer #
9
- # Copyright (C) 2007-2014 John Vorhauer, Jens Wille #
10
- # #
11
- # Lingo is free software; you can redistribute it and/or modify it under the #
12
- # terms of the GNU Affero General Public License as published by the Free #
13
- # Software Foundation; either version 3 of the License, or (at your option) #
14
- # any later version. #
15
- # #
16
- # Lingo is distributed in the hope that it will be useful, but WITHOUT ANY #
17
- # WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS #
18
- # FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for #
19
- # more details. #
20
- # #
21
- # You should have received a copy of the GNU Affero General Public License #
22
- # along with Lingo. If not, see <http://www.gnu.org/licenses/>. #
23
- # #
24
- ###############################################################################
25
- #++
26
-
27
- class Lingo
28
-
29
- class Attendee
30
-
31
- #--
32
- # Der NonewordFilter ermöglicht es, alle nicht erkannten Wörter aus dem Datenstrom zu
33
- # selektieren und weiterzuleiten. Im Prinzip werden alle erkannten Wörter gefiltert.
34
- # Bei einem Indexierungslauf können so alle nicht durch den Wordsearcher erkannten Wörter,
35
- # also die, die im Wörterbuch nicht enthalten sind, separat ausgegeben werden und als Grundlage für
36
- # die Wörterbuchpflege dienen.
37
- # Der NonewordFilter ist in einer frühen Entwicklungsphase entstanden. Die gleiche Funktion
38
- # kann auch mit dem universelleren Objectfilter mit dem Ausdruck 'obj.kind_of?(Word) && obj.attr==WA_UNKNOWN'
39
- # durchgeführt werden, mit dem einzigen Unterschied, dass der NonewordFilter nur die Wortform weiterleitet.
40
- # Der NonewordFilter verschluckt ebenfalls alle Kommandos, ausser dem Dateianfang (*FILE) und Ende (*EOF),
41
- # sowie dem LIR-Format-Spezifikum (*RECORD).
42
- #
43
- # *Hinweis* Dieser Attendee sammelt die auszugebenden Daten so lange, bis ein Dateiwechsel oder Record-Wechsel
44
- # angekündigt wird. Erst dann werden alle Daten auf einmal weitergeleitet.
45
- #
46
- # === Mögliche Verlinkung
47
- # Erwartet:: Daten vom Typ *Word*, z.B. von Abbreviator, Wordsearcher, Decomposer, Synonymer, Multiworder, Sequencer
48
- # Erzeugt:: Daten vom Typ *String*, z.B. für Textwriter
49
- #
50
- # === Parameter
51
- # Kursiv dargestellte Parameter sind optional (ggf. mit Angabe der Voreinstellung).
52
- # Alle anderen Parameter müssen zwingend angegeben werden.
53
- # <b>in</b>:: siehe allgemeine Beschreibung des Attendee
54
- # <b>out</b>:: siehe allgemeine Beschreibung des Attendee
55
- #
56
- # === Beispiele
57
- # Bei der Verarbeitung einer normalen Textdatei mit der Ablaufkonfiguration <tt>t1.cfg</tt>
58
- # meeting:
59
- # attendees:
60
- # - text_reader: { out: lines, files: '$(files)' }
61
- # - tokenizer: { in: lines, out: token }
62
- # - word_searcher: { in: token, out: words, source: 'sys-dic' }
63
- # - noneword_filter: { in: words, out: filtr }
64
- # - debugger: { in: filtr, prompt: 'out>' }
65
- # ergibt die Ausgabe über den Debugger: <tt>lingo -c t1 test.txt</tt>
66
- # out> *FILE('test.txt')
67
- # out> "lingo"
68
- # out> *EOF('test.txt')
69
- #++
70
-
71
- class NonewordFilter < self
72
-
73
- def init
74
- @sort = get_key('sort', !ENV['LINGO_NO_SORT'])
75
- @dict = get_key('dict', false)
76
- @dict = '=' if @dict == true
77
-
78
- @nonewords = []
79
- end
80
-
81
- def control(cmd, *)
82
- case cmd
83
- when :FILE then @nonewords.clear
84
- when :EOL then :skip_command
85
- when :RECORD then send_nonewords unless @dict
86
- when :EOF then send_nonewords
87
- end
88
- end
89
-
90
- def process(obj)
91
- if obj.is_a?(Word) && obj.unknown?
92
- non = Unicode.downcase(obj.form)
93
- non = "#{non}#{@dict}#{non} #?" if @dict
94
- @sort ? @nonewords << non : forward(non)
95
- end
96
- end
97
-
98
- private
99
-
100
- def send_nonewords
101
- unless @nonewords.empty?
102
- @nonewords.uniq!
103
- flush(@nonewords.sort!)
104
- end
105
- end
106
-
107
- end
108
-
109
- # For backwards compatibility.
110
- Nonewordfilter = NonewordFilter
111
- Noneword_filter = NonewordFilter
112
-
113
- end
114
-
115
- end
@@ -1,15 +0,0 @@
1
- # encoding: utf-8
2
-
3
- require_relative '../test_helper'
4
-
5
- class TestAttendeeNonewordFilter < AttendeeTestCase
6
-
7
- def test_basic
8
- meet({}, [
9
- wd('Eins|IDF'), wd('Zwei|?'), wd('Drei|IDF'), wd('Vier|?'), ai('EOF|'), ai('EOT|')
10
- ], [
11
- 'vier', 'zwei', ai('EOF|'), ai('EOT|')
12
- ])
13
- end
14
-
15
- end