lingo 1.8.0 → 1.8.1
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.
- data/ChangeLog +13 -0
- data/README +49 -29
- data/Rakefile +28 -4
- data/TODO +2 -9
- data/bin/lingo +24 -0
- data/bin/lingoctl +24 -0
- data/de/lingo-dic.txt +559 -74
- data/info/gpl-hdr.txt +21 -24
- data/lib/lingo.rb +83 -112
- data/lib/lingo/agenda_item.rb +53 -0
- data/lib/lingo/attendee.rb +261 -0
- data/lib/lingo/attendee/abbreviator.rb +95 -97
- data/lib/lingo/attendee/debugger.rb +94 -93
- data/lib/lingo/attendee/decomposer.rb +76 -83
- data/lib/lingo/attendee/dehyphenizer.rb +141 -144
- data/lib/lingo/attendee/formatter.rb +65 -0
- data/lib/lingo/attendee/multi_worder.rb +302 -0
- data/lib/lingo/attendee/noneword_filter.rb +89 -84
- data/lib/lingo/attendee/object_filter.rb +91 -0
- data/lib/lingo/attendee/sequencer.rb +159 -158
- data/lib/lingo/attendee/synonymer.rb +81 -84
- data/lib/lingo/attendee/text_reader.rb +242 -0
- data/lib/lingo/attendee/text_writer.rb +169 -0
- data/lib/lingo/attendee/tokenizer.rb +192 -191
- data/lib/lingo/attendee/variator.rb +152 -156
- data/lib/lingo/attendee/vector_filter.rb +140 -135
- data/lib/lingo/attendee/word_searcher.rb +98 -0
- data/lib/lingo/buffered_attendee.rb +69 -0
- data/lib/lingo/cachable.rb +58 -0
- data/lib/lingo/call.rb +72 -0
- data/lib/lingo/cli.rb +26 -0
- data/lib/lingo/config.rb +23 -26
- data/lib/lingo/core_ext.rb +42 -0
- data/lib/lingo/ctl.rb +239 -173
- data/lib/lingo/database.rb +148 -496
- data/lib/lingo/database/crypter.rb +85 -0
- data/lib/lingo/database/gdbm_store.rb +49 -0
- data/lib/lingo/database/hash_store.rb +67 -0
- data/lib/lingo/database/libcdb_store.rb +58 -0
- data/lib/lingo/database/sdbm_store.rb +64 -0
- data/lib/lingo/database/show_progress.rb +81 -0
- data/lib/lingo/database/source.rb +134 -0
- data/lib/lingo/database/source/key_value.rb +62 -0
- data/lib/lingo/database/source/multi_key.rb +65 -0
- data/lib/lingo/database/source/multi_value.rb +65 -0
- data/lib/lingo/database/source/single_word.rb +60 -0
- data/lib/lingo/database/source/word_class.rb +64 -0
- data/lib/lingo/error.rb +122 -0
- data/lib/lingo/language.rb +78 -518
- data/lib/lingo/language/dictionary.rb +173 -0
- data/lib/lingo/language/grammar.rb +211 -0
- data/lib/lingo/language/lexical.rb +66 -0
- data/lib/lingo/language/lexical_hash.rb +88 -0
- data/lib/lingo/language/token.rb +48 -0
- data/lib/lingo/language/word.rb +130 -0
- data/lib/lingo/language/word_form.rb +83 -0
- data/lib/lingo/reportable.rb +59 -0
- data/lib/lingo/version.rb +1 -1
- data/lingo-all.cfg +14 -10
- data/lingo-call.cfg +5 -5
- data/lingo.cfg +14 -12
- data/lingo.rb +26 -0
- data/lir.cfg +13 -9
- data/spec/spec_helper.rb +1 -0
- data/test.cfg +11 -11
- data/test/attendee/ts_abbreviator.rb +0 -6
- data/test/attendee/ts_decomposer.rb +0 -6
- data/test/attendee/{ts_multiworder.rb → ts_multi_worder.rb} +1 -7
- data/test/attendee/ts_noneword_filter.rb +1 -7
- data/test/attendee/{ts_objectfilter.rb → ts_object_filter.rb} +1 -7
- data/test/attendee/ts_sequencer.rb +0 -6
- data/test/attendee/ts_synonymer.rb +0 -6
- data/test/attendee/{ts_textreader.rb → ts_text_reader.rb} +1 -7
- data/test/attendee/{ts_textwriter.rb → ts_text_writer.rb} +1 -7
- data/test/attendee/ts_tokenizer.rb +0 -6
- data/test/attendee/ts_variator.rb +0 -6
- data/test/attendee/ts_vector_filter.rb +1 -7
- data/test/attendee/{ts_wordsearcher.rb → ts_word_searcher.rb} +1 -7
- data/test/ref/artikel.non +2 -29
- data/test/ref/artikel.seq +13 -8
- data/test/ref/artikel.vec +30 -15
- data/test/ref/artikel.ven +29 -14
- data/test/ref/artikel.ver +58 -43
- data/test/ref/lir.csv +146 -145
- data/test/ref/lir.non +186 -210
- data/test/ref/lir.seq +54 -50
- data/test/test_helper.rb +41 -36
- data/test/ts_database.rb +12 -11
- data/test/ts_language.rb +118 -68
- metadata +67 -29
- data/lib/lingo/attendee/multiworder.rb +0 -301
- data/lib/lingo/attendee/objectfilter.rb +0 -86
- data/lib/lingo/attendee/textreader.rb +0 -237
- data/lib/lingo/attendee/textwriter.rb +0 -196
- data/lib/lingo/attendee/wordsearcher.rb +0 -96
- data/lib/lingo/attendees.rb +0 -289
- data/lib/lingo/const.rb +0 -131
- data/lib/lingo/modules.rb +0 -98
- data/lib/lingo/types.rb +0 -285
- data/lib/lingo/utilities.rb +0 -40
|
@@ -1,96 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
#--
|
|
4
|
-
# LINGO ist ein Indexierungssystem mit Grundformreduktion, Kompositumzerlegung,
|
|
5
|
-
# Mehrworterkennung und Relationierung.
|
|
6
|
-
#
|
|
7
|
-
# Copyright (C) 2005-2007 John Vorhauer
|
|
8
|
-
# Copyright (C) 2007-2011 John Vorhauer, Jens Wille
|
|
9
|
-
#
|
|
10
|
-
# This program is free software; you can redistribute it and/or modify it under
|
|
11
|
-
# the terms of the GNU Affero General Public License as published by the Free
|
|
12
|
-
# Software Foundation; either version 3 of the License, or (at your option)
|
|
13
|
-
# any later version.
|
|
14
|
-
#
|
|
15
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
16
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
17
|
-
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
18
|
-
# details.
|
|
19
|
-
#
|
|
20
|
-
# You should have received a copy of the GNU Affero General Public License along
|
|
21
|
-
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
22
|
-
# 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
|
|
23
|
-
#
|
|
24
|
-
# For more information visit http://www.lex-lingo.de or contact me at
|
|
25
|
-
# welcomeATlex-lingoDOTde near 50°55'N+6°55'E.
|
|
26
|
-
#
|
|
27
|
-
# Lex Lingo rules from here on
|
|
28
|
-
#++
|
|
29
|
-
|
|
30
|
-
class Lingo
|
|
31
|
-
|
|
32
|
-
# Der Wordsearcher ist das Herzstück von Lingo. Er macht die Hauptarbeit und versucht
|
|
33
|
-
# alle Token die nach einem sinnvollen Wort aussehen, in den ihm angegebenen
|
|
34
|
-
# Wörterbüchern zu finden und aufzulösen. Dabei werden die im Wörterbuch gefundenen
|
|
35
|
-
# Grundformen inkl. Wortklassen an das Word-Objekt angehängt.
|
|
36
|
-
#
|
|
37
|
-
# === Mögliche Verlinkung
|
|
38
|
-
# Erwartet:: Daten vom Typ *Token* (andere werden einfach durchgereicht) z.B. von Tokenizer, Abbreviator
|
|
39
|
-
# Erzeugt:: Daten vom Typ *Word* für erkannte Wörter z.B. für Synonymer, Decomposer, Ocr_variator, Multiworder, Sequencer, Noneword_filter, Vector_filter
|
|
40
|
-
#
|
|
41
|
-
# === Parameter
|
|
42
|
-
# Kursiv dargestellte Parameter sind optional (ggf. mit Angabe der Voreinstellung).
|
|
43
|
-
# Alle anderen Parameter müssen zwingend angegeben werden.
|
|
44
|
-
# <b>in</b>:: siehe allgemeine Beschreibung des Attendee
|
|
45
|
-
# <b>out</b>:: siehe allgemeine Beschreibung des Attendee
|
|
46
|
-
# <b>source</b>:: siehe allgemeine Beschreibung des Dictionary
|
|
47
|
-
# <b><i>mode</i></b>:: (Standard: all) siehe allgemeine Beschreibung des Dictionary
|
|
48
|
-
#
|
|
49
|
-
# === Beispiele
|
|
50
|
-
# Bei der Verarbeitung einer normalen Textdatei mit der Ablaufkonfiguration <tt>t1.cfg</tt>
|
|
51
|
-
# meeting:
|
|
52
|
-
# attendees:
|
|
53
|
-
# - textreader: { out: lines, files: '$(files)' }
|
|
54
|
-
# - tokenizer: { in: lines, out: token }
|
|
55
|
-
# - abbreviator: { in: token, out: abbrev, source: 'sys-abk' }
|
|
56
|
-
# - wordsearcher: { in: abbrev, out: words, source: 'sys-dic' }
|
|
57
|
-
# - debugger: { in: words, prompt: 'out>' }
|
|
58
|
-
# ergibt die Ausgabe über den Debugger: <tt>lingo -c t1 test.txt</tt>
|
|
59
|
-
# out> *FILE('test.txt')
|
|
60
|
-
# out> <Dies = [(dies/w)]>
|
|
61
|
-
# out> <ist = [(sein/v)]>
|
|
62
|
-
# out> <ggf. = [(gegebenenfalls/w)]>
|
|
63
|
-
# out> <eine = [(einen/v), (ein/w)]>
|
|
64
|
-
# out> <Abk³rzung = [(abk³rzung/s)]>
|
|
65
|
-
# out> :./PUNC:
|
|
66
|
-
# out> *EOL('test.txt')
|
|
67
|
-
# out> *EOF('test.txt')
|
|
68
|
-
|
|
69
|
-
class Attendee::Wordsearcher < Attendee
|
|
70
|
-
|
|
71
|
-
def init
|
|
72
|
-
# Wörterbuch bereitstellen
|
|
73
|
-
src = get_array('source')
|
|
74
|
-
mod = get_key('mode', 'all')
|
|
75
|
-
@dic = Dictionary.new({'source'=>src, 'mode'=>mod}, @lingo)
|
|
76
|
-
end
|
|
77
|
-
|
|
78
|
-
def control(cmd, par)
|
|
79
|
-
@dic.report.each_pair { |key, value|
|
|
80
|
-
set(key, value)
|
|
81
|
-
} if cmd == STR_CMD_STATUS
|
|
82
|
-
end
|
|
83
|
-
|
|
84
|
-
def process(obj)
|
|
85
|
-
if obj.is_a?(Token) && obj.attr == TA_WORD
|
|
86
|
-
inc('Anzahl gesuchter Wörter')
|
|
87
|
-
word = @dic.find_word(obj.form)
|
|
88
|
-
inc('Anzahl gefundener Wörter') unless word.attr == WA_UNKNOWN
|
|
89
|
-
obj = word
|
|
90
|
-
end
|
|
91
|
-
forward(obj)
|
|
92
|
-
end
|
|
93
|
-
|
|
94
|
-
end
|
|
95
|
-
|
|
96
|
-
end
|
data/lib/lingo/attendees.rb
DELETED
|
@@ -1,289 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
#--
|
|
4
|
-
# LINGO ist ein Indexierungssystem mit Grundformreduktion, Kompositumzerlegung,
|
|
5
|
-
# Mehrworterkennung und Relationierung.
|
|
6
|
-
#
|
|
7
|
-
# Copyright (C) 2005-2007 John Vorhauer
|
|
8
|
-
# Copyright (C) 2007-2011 John Vorhauer, Jens Wille
|
|
9
|
-
#
|
|
10
|
-
# This program is free software; you can redistribute it and/or modify it under
|
|
11
|
-
# the terms of the GNU Affero General Public License as published by the Free
|
|
12
|
-
# Software Foundation; either version 3 of the License, or (at your option)
|
|
13
|
-
# any later version.
|
|
14
|
-
#
|
|
15
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
16
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
17
|
-
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
18
|
-
# details.
|
|
19
|
-
#
|
|
20
|
-
# You should have received a copy of the GNU Affero General Public License along
|
|
21
|
-
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
22
|
-
# 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
|
|
23
|
-
#
|
|
24
|
-
# For more information visit http://www.lex-lingo.de or contact me at
|
|
25
|
-
# welcomeATlex-lingoDOTde near 50°55'N+6°55'E.
|
|
26
|
-
#
|
|
27
|
-
# Lex Lingo rules from here on
|
|
28
|
-
#++
|
|
29
|
-
|
|
30
|
-
require_relative 'modules'
|
|
31
|
-
require_relative 'language'
|
|
32
|
-
require_relative 'const'
|
|
33
|
-
require_relative 'types'
|
|
34
|
-
|
|
35
|
-
class Lingo
|
|
36
|
-
|
|
37
|
-
# Lingo ist als universelles Indexierungssystem entworfen worden. Seine Stärke liegt in der einfachen Konfigurierbarkeit für
|
|
38
|
-
# spezifische Aufgaben und in der schnelle Entwicklung weiterer Funktionen durch systematischen Kapselung der Komplexität auf
|
|
39
|
-
# kleine Verarbeitungseinheiten. Die kleinste Verarbeitungseinheit wird Attendee genannt. Um ein gewünschtes Verarbeitungsergebnis
|
|
40
|
-
# zu bekommen, werden die benötigten Attendees einfach in einer Reihe hinter einander geschaltet. Ein einfaches Beispiel hierfür ist
|
|
41
|
-
# eine direkte Verbindung zwischen einem Textreader, einem Tokenizer und einem Textwriter. Alle drei Klassen sind von der Klasse
|
|
42
|
-
# Attendee abgeleitet.
|
|
43
|
-
#
|
|
44
|
-
# Der Textreader liest beispielsweise Zeilen aus einer Textdatei und leitet sie weiter an den Tokenizer. Der Tokenizer zerlegt eine
|
|
45
|
-
# Textzeile in einzelne Wörter und gibt diese weiter an den Textwriter, der diese in eine (andere) Datei schreibt. Über vielfältige
|
|
46
|
-
# Konfigurationsmöglichkeiten kann das Verhalten der Attendees an die eigenen Bedürfnisse angepasst werden.
|
|
47
|
-
#
|
|
48
|
-
# Die Verkettung einzelner Attendees findet über die Schnittstellen +listen+ und +talk+ statt. An +listen+ können beliebige Objekte
|
|
49
|
-
# zur Ver- und Bearbeitung übergeben werden. Nach der Verarbeitung werden sie mittels +talk+ an die verketteten Attendees weiter
|
|
50
|
-
# gegeben. Objekte der Klasse AgendaItem dienen dabei der Steuerung der Verarbeitung und sind nicht Bestandteil der normalen
|
|
51
|
-
# Verarbeitung. Beispiele für AgendaItems sind die Kommandos TALK (Aufforderung zum Start der Verarbeitung), WARN (zur Ausgabe von
|
|
52
|
-
# Warnungen eines Attendees) und EOL (End of Line, Ende einer Textzeile nach Zerlegung in einzelne Wörter). Eine vollständige
|
|
53
|
-
# Übersicht benutzer AgendaItems (oder auf Stream Commands) steht in lib/const.rb mit dem Prefix STR_CMD_.
|
|
54
|
-
#
|
|
55
|
-
# Um die Entwicklung von neuen Attendees zu beschleunigen, wird durch die Vererbung sind bei wird die gesammte sind in der Regel nur
|
|
56
|
-
# drei abstrakte Methoden zu implementieren: +init+, +control+ und +process+. Die Methode +init+ wird bei der Instanziierung eines
|
|
57
|
-
# Objektes einmalig aufgerufen. Sie dient der Vorbereitung der Verarbeitung, z.B. durch das Öffnen und Bereitstellen von
|
|
58
|
-
# Wörterbüchern zur linguistischen Analyse. An die Methode +control+ werden alle eingehenden AgendaItems weitergeleitet. Dort erfolgt
|
|
59
|
-
# die Verarbeitungssteuerung, also z.B. bei STR_CMD_FILE das Öffnen einer Datei und bei STR_CMD_EOF respektive das Schließen. Die
|
|
60
|
-
# echte Verarbeitung von Daten findet daher durch die Methode +process+ statt.
|
|
61
|
-
#
|
|
62
|
-
# was macht attendee
|
|
63
|
-
# - verkettung der attendees anhand von konfigurationsinformationen
|
|
64
|
-
# - bereitstellung von globalen und spezifischen konfigurationsinformationen
|
|
65
|
-
# - behandlung von bestimmten übergreifenden Kommandos, z.B. STR_CMD_TALK, STR_CMD_STATUS, STR_CMD_WARN, STR_CMD_ERR
|
|
66
|
-
# - separierung und routing von kommando bzw. datenobjekten
|
|
67
|
-
#
|
|
68
|
-
# was macht die abgeleitet klasse
|
|
69
|
-
# - verarbeitet und/oder transformiert datenobjekte
|
|
70
|
-
# - wird gesteuert durch kommandos
|
|
71
|
-
# - schreibt verarbeitungsstatistiken
|
|
72
|
-
|
|
73
|
-
class Attendee
|
|
74
|
-
|
|
75
|
-
include Reportable
|
|
76
|
-
|
|
77
|
-
def initialize(config, lingo)
|
|
78
|
-
@lingo = lingo
|
|
79
|
-
|
|
80
|
-
init_reportable
|
|
81
|
-
|
|
82
|
-
begin
|
|
83
|
-
lingo.dictionary_config
|
|
84
|
-
rescue
|
|
85
|
-
raise "Fehler in der .lang-Datei bei 'language/dictionary'"
|
|
86
|
-
end
|
|
87
|
-
|
|
88
|
-
@config, @subscriber = config, []
|
|
89
|
-
|
|
90
|
-
init if self.class.method_defined?(:init)
|
|
91
|
-
|
|
92
|
-
@attendee_can_control = self.class.method_defined?(:control)
|
|
93
|
-
@attendee_can_process = self.class.method_defined?(:process)
|
|
94
|
-
|
|
95
|
-
@skip_this_command, @start_of_processing = false, nil
|
|
96
|
-
end
|
|
97
|
-
|
|
98
|
-
def add_subscriber(subscriber)
|
|
99
|
-
@subscriber.concat(subscriber)
|
|
100
|
-
end
|
|
101
|
-
|
|
102
|
-
def listen(obj)
|
|
103
|
-
unless obj.is_a?(AgendaItem)
|
|
104
|
-
if @attendee_can_process
|
|
105
|
-
inc(STA_NUM_OBJECTS)
|
|
106
|
-
|
|
107
|
-
unless @lingo.report_time
|
|
108
|
-
process(obj)
|
|
109
|
-
else
|
|
110
|
-
@start_of_processing = Time.new
|
|
111
|
-
process(obj)
|
|
112
|
-
add(STA_TIM_OBJECTS, Time.new - @start_of_processing)
|
|
113
|
-
end
|
|
114
|
-
else
|
|
115
|
-
forward(obj)
|
|
116
|
-
end
|
|
117
|
-
else
|
|
118
|
-
# Neuen TOP verarbeiten
|
|
119
|
-
if @attendee_can_control
|
|
120
|
-
inc(STA_NUM_COMMANDS)
|
|
121
|
-
|
|
122
|
-
unless @lingo.report_time
|
|
123
|
-
control(obj.cmd, obj.param)
|
|
124
|
-
else
|
|
125
|
-
@start_of_processing = Time.new
|
|
126
|
-
control(obj.cmd, obj.param)
|
|
127
|
-
add(STA_TIM_COMMANDS, Time.new - @start_of_processing)
|
|
128
|
-
end
|
|
129
|
-
end
|
|
130
|
-
|
|
131
|
-
# Spezialbehandlung für einige TOPs nach Verarbeitung
|
|
132
|
-
case obj.cmd
|
|
133
|
-
when STR_CMD_TALK
|
|
134
|
-
# keine weitere Behandlung oder Weiterleitung
|
|
135
|
-
nil
|
|
136
|
-
when STR_CMD_STATUS
|
|
137
|
-
# Standardprotokollinformationen ausgeben
|
|
138
|
-
|
|
139
|
-
if @lingo.report_time
|
|
140
|
-
@lingo.config.stderr.puts 'Perf: %-15s => %7d commands in %s (%s/cmd), %8d objects in %s (%s/obj)' % [
|
|
141
|
-
@config['name'],
|
|
142
|
-
get(STA_NUM_COMMANDS),
|
|
143
|
-
seconds_to_str(get(STA_TIM_COMMANDS)),
|
|
144
|
-
seconds_to_str((get(STA_NUM_COMMANDS)==0) ? 0.0 : get(STA_TIM_COMMANDS) / get(STA_NUM_COMMANDS).to_f),
|
|
145
|
-
get(STA_NUM_OBJECTS),
|
|
146
|
-
seconds_to_str(get(STA_TIM_OBJECTS)),
|
|
147
|
-
seconds_to_str((get(STA_NUM_OBJECTS)==0) ? 0.0 : get(STA_TIM_OBJECTS) / get(STA_NUM_OBJECTS).to_f)
|
|
148
|
-
]
|
|
149
|
-
end
|
|
150
|
-
|
|
151
|
-
if @lingo.report_status
|
|
152
|
-
@lingo.config.stderr.puts "Attendee <%s> was connected from '%s' to '%s' reporting...\n" % @config.values_at(*%w[name in out]),
|
|
153
|
-
report.sort.map { |info| " #{info[0]} = #{info[1]}" }, nil
|
|
154
|
-
end
|
|
155
|
-
|
|
156
|
-
forward(obj.cmd, obj.param)
|
|
157
|
-
else
|
|
158
|
-
if @skip_this_command
|
|
159
|
-
@skip_this_command = false
|
|
160
|
-
else
|
|
161
|
-
forward(obj.cmd, obj.param)
|
|
162
|
-
end
|
|
163
|
-
end
|
|
164
|
-
end
|
|
165
|
-
end
|
|
166
|
-
|
|
167
|
-
def talk(obj)
|
|
168
|
-
time_for_sub = Time.new if @lingo.report_time
|
|
169
|
-
@subscriber.each { |attendee| attendee.listen(obj) }
|
|
170
|
-
@start_of_processing += (Time.new - time_for_sub) if @lingo.report_time
|
|
171
|
-
end
|
|
172
|
-
|
|
173
|
-
private
|
|
174
|
-
|
|
175
|
-
# ---------------------------------------------------
|
|
176
|
-
# Create intelligent output of performance times
|
|
177
|
-
# measured with command line option -p
|
|
178
|
-
# ---------------------------------------------------
|
|
179
|
-
|
|
180
|
-
def seconds_to_str(float)
|
|
181
|
-
if float < 0.001
|
|
182
|
-
"%9.3f µs" % [float * 1000000.0]
|
|
183
|
-
elsif float < 1.0
|
|
184
|
-
"%9.3f ms" % [float * 1000.0]
|
|
185
|
-
elsif float < 60.0
|
|
186
|
-
"%9.3f s " % [float]
|
|
187
|
-
elsif float < 3600.0
|
|
188
|
-
"%9.3f m " % [float / 60.0]
|
|
189
|
-
else
|
|
190
|
-
"%9.3f h " % [float / 3600.0]
|
|
191
|
-
end
|
|
192
|
-
end
|
|
193
|
-
|
|
194
|
-
def deleteCmd
|
|
195
|
-
@skip_this_command = true
|
|
196
|
-
end
|
|
197
|
-
|
|
198
|
-
def forward(obj, param=nil)
|
|
199
|
-
if param.nil?
|
|
200
|
-
# Information weiterreichen
|
|
201
|
-
talk(obj)
|
|
202
|
-
else
|
|
203
|
-
# TOP weiterreichen (wenn keine Warnung oder Fehler)
|
|
204
|
-
case obj
|
|
205
|
-
when STR_CMD_WARN then printf "+%s\n| %s: %s\n+%s\n", '-'*60, @config['name'], param, '-'*60
|
|
206
|
-
when STR_CMD_ERR then printf "%s\n= %s: %s\n%s\n", '='*61, @config['name'], param, '='*61; exit( 1 )
|
|
207
|
-
else
|
|
208
|
-
talk(AgendaItem.new(obj, param))
|
|
209
|
-
end
|
|
210
|
-
end
|
|
211
|
-
end
|
|
212
|
-
|
|
213
|
-
# ---------------------------------------------------
|
|
214
|
-
# Konfigurationshilfsmethoden
|
|
215
|
-
# ---------------------------------------------------
|
|
216
|
-
def has_key?(key)
|
|
217
|
-
!@config.nil? && @config.has_key?(key)
|
|
218
|
-
end
|
|
219
|
-
|
|
220
|
-
def get_key(key, default=nil)
|
|
221
|
-
forward(STR_CMD_ERR, "Attribut #{key} nicht gesetzt") if default.nil? && !has_key?(key)
|
|
222
|
-
@config.fetch(key, default)
|
|
223
|
-
end
|
|
224
|
-
|
|
225
|
-
def get_array(key, default=nil)
|
|
226
|
-
get_key(key, default).split(STRING_SEPERATOR_PATTERN)
|
|
227
|
-
end
|
|
228
|
-
|
|
229
|
-
# ---------------------------------------------------
|
|
230
|
-
# Abstrakte Methoden
|
|
231
|
-
#
|
|
232
|
-
# init
|
|
233
|
-
# control(cmd, param)
|
|
234
|
-
# process(obj)
|
|
235
|
-
# ---------------------------------------------------
|
|
236
|
-
|
|
237
|
-
end
|
|
238
|
-
|
|
239
|
-
class BufferedAttendee < Attendee
|
|
240
|
-
|
|
241
|
-
BufferInsert = Struct.new(:position, :object)
|
|
242
|
-
|
|
243
|
-
def initialize(config, lingo)
|
|
244
|
-
# In den Buffer werden alle Objekte geschrieben, bis process_buffer? == true ist
|
|
245
|
-
@buffer = []
|
|
246
|
-
|
|
247
|
-
# deferred_inserts beeinflussen nicht die Buffer-Größe, sondern werden an einer
|
|
248
|
-
# bestimmten Stelle in den Datenstrom eingefügt
|
|
249
|
-
@deferred_inserts = []
|
|
250
|
-
|
|
251
|
-
super
|
|
252
|
-
end
|
|
253
|
-
|
|
254
|
-
protected
|
|
255
|
-
|
|
256
|
-
def process(obj)
|
|
257
|
-
@buffer.push(obj)
|
|
258
|
-
process_buffer if process_buffer?
|
|
259
|
-
end
|
|
260
|
-
|
|
261
|
-
private
|
|
262
|
-
|
|
263
|
-
def forward_buffer
|
|
264
|
-
# Aufgeschobene Einfügungen in Buffer kopieren
|
|
265
|
-
@deferred_inserts.sort_by { |ins| ins.position }.each { |ins|
|
|
266
|
-
@buffer.insert(ins.position, ins.object)
|
|
267
|
-
}
|
|
268
|
-
@deferred_inserts.clear
|
|
269
|
-
|
|
270
|
-
# Buffer weiterleiten
|
|
271
|
-
@buffer.each { |obj| forward(obj) }
|
|
272
|
-
@buffer.clear
|
|
273
|
-
end
|
|
274
|
-
|
|
275
|
-
def process_buffer?
|
|
276
|
-
true
|
|
277
|
-
end
|
|
278
|
-
|
|
279
|
-
def process_buffer
|
|
280
|
-
# to be defined by child class
|
|
281
|
-
end
|
|
282
|
-
|
|
283
|
-
def deferred_insert(pos, obj)
|
|
284
|
-
@deferred_inserts << BufferInsert.new(pos, obj)
|
|
285
|
-
end
|
|
286
|
-
|
|
287
|
-
end
|
|
288
|
-
|
|
289
|
-
end
|
data/lib/lingo/const.rb
DELETED
|
@@ -1,131 +0,0 @@
|
|
|
1
|
-
# encoding: utf-8
|
|
2
|
-
|
|
3
|
-
#--
|
|
4
|
-
# LINGO ist ein Indexierungssystem mit Grundformreduktion, Kompositumzerlegung,
|
|
5
|
-
# Mehrworterkennung und Relationierung.
|
|
6
|
-
#
|
|
7
|
-
# Copyright (C) 2005-2007 John Vorhauer
|
|
8
|
-
# Copyright (C) 2007-2011 John Vorhauer, Jens Wille
|
|
9
|
-
#
|
|
10
|
-
# This program is free software; you can redistribute it and/or modify it under
|
|
11
|
-
# the terms of the GNU Affero General Public License as published by the Free
|
|
12
|
-
# Software Foundation; either version 3 of the License, or (at your option)
|
|
13
|
-
# any later version.
|
|
14
|
-
#
|
|
15
|
-
# This program is distributed in the hope that it will be useful, but WITHOUT
|
|
16
|
-
# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
|
|
17
|
-
# FOR A PARTICULAR PURPOSE. See the GNU Affero General Public License for more
|
|
18
|
-
# details.
|
|
19
|
-
#
|
|
20
|
-
# You should have received a copy of the GNU Affero General Public License along
|
|
21
|
-
# with this program; if not, write to the Free Software Foundation, Inc.,
|
|
22
|
-
# 51 Franklin St, Fifth Floor, Boston, MA 02110, USA
|
|
23
|
-
#
|
|
24
|
-
# For more information visit http://www.lex-lingo.de or contact me at
|
|
25
|
-
# welcomeATlex-lingoDOTde near 50°55'N+6°55'E.
|
|
26
|
-
#
|
|
27
|
-
# Lex Lingo rules from here on
|
|
28
|
-
#++
|
|
29
|
-
|
|
30
|
-
class Lingo
|
|
31
|
-
|
|
32
|
-
ENC = 'UTF-8'
|
|
33
|
-
|
|
34
|
-
STRING_SEPERATOR_PATTERN = /[; ,\|]/
|
|
35
|
-
|
|
36
|
-
# String-Konstanten im Datenstrom
|
|
37
|
-
CHAR_PUNCT = '.'
|
|
38
|
-
|
|
39
|
-
# Define printable characters for tokenizer for UTF-8 encoding
|
|
40
|
-
UTF_8_DIGIT = '[0-9]'
|
|
41
|
-
# Define Basic Latin printable characters for UTF-8 encoding from U+0000 to U+007f
|
|
42
|
-
UTF_8_BASLAT = '[A-Za-z]'
|
|
43
|
-
# Define Latin-1 Supplement printable characters for UTF-8 encoding from U+0080 to U+00ff
|
|
44
|
-
UTF_8_LAT1SP = '[\xc3\x80-\xc3\x96\xc3\x98-\xc3\xb6\xc3\xb8-\xc3\xbf]'
|
|
45
|
-
# Define Latin Extended-A printable characters for UTF-8 encoding from U+0100 to U+017f
|
|
46
|
-
UTF_8_LATEXA = '[\xc4\x80-\xc4\xbf\xc5\x80-\xc5\xbf]'
|
|
47
|
-
# Define Latin Extended-B printable characters for UTF-8 encoding from U+0180 to U+024f
|
|
48
|
-
UTF_8_LATEXB = '[\xc6\x80-\xc6\xbf\xc7\x80-\xc7\xbf\xc8\x80-\xc8\xbf\xc9\x80-\xc9\x8f]'
|
|
49
|
-
# Define IPA Extension printable characters for UTF-8 encoding from U+024f to U+02af
|
|
50
|
-
UTF_8_IPAEXT = '[\xc9\xa0-\xc9\xbf\xca\xa0-\xca\xaf]'
|
|
51
|
-
# Collect all UTF-8 printable characters in Unicode range U+0000 to U+02af
|
|
52
|
-
UTF_8_CHAR = "#{UTF_8_DIGIT}|#{UTF_8_BASLAT}|#{UTF_8_LAT1SP}|#{UTF_8_LATEXA}|#{UTF_8_LATEXB}|#{UTF_8_IPAEXT}"
|
|
53
|
-
|
|
54
|
-
PRINTABLE_CHAR = "#{UTF_8_CHAR}|[<>-]"
|
|
55
|
-
|
|
56
|
-
# Status vars
|
|
57
|
-
STA_FORMAT_INT = ' %-20s = %d'
|
|
58
|
-
STA_FORMAT_FLT = ' %-20s = %6.5f'
|
|
59
|
-
STA_NUM_COMMANDS = 'Received Commands'
|
|
60
|
-
STA_NUM_OBJECTS = 'Received Objects '
|
|
61
|
-
STA_TIM_COMMANDS = 'Time to control '
|
|
62
|
-
STA_TIM_OBJECTS = 'Time to process '
|
|
63
|
-
STA_PER_OBJECT = 'Time per object '
|
|
64
|
-
STA_PER_COMMAND = 'Time per command '
|
|
65
|
-
|
|
66
|
-
# Stream commands
|
|
67
|
-
STR_CMD_TALK = 'TALK'
|
|
68
|
-
STR_CMD_STATUS = 'STATUS'
|
|
69
|
-
STR_CMD_ERR = 'ERR'
|
|
70
|
-
STR_CMD_WARN = 'WARN'
|
|
71
|
-
STR_CMD_LIR = 'LIR-FORMAT'
|
|
72
|
-
STR_CMD_FILE = 'FILE'
|
|
73
|
-
STR_CMD_EOL = 'EOL'
|
|
74
|
-
STR_CMD_RECORD = 'RECORD'
|
|
75
|
-
STR_CMD_EOF = 'EOF'
|
|
76
|
-
|
|
77
|
-
# Token attributes
|
|
78
|
-
TA_WORD = 'WORD'
|
|
79
|
-
TA_PUNCTUATION = 'PUNC'
|
|
80
|
-
TA_NUMERICAL = 'NUMS'
|
|
81
|
-
TA_URL = 'URLS'
|
|
82
|
-
TA_ABREVIATION = 'ABRV'
|
|
83
|
-
TA_ABREVIATION1 = 'ABRS'
|
|
84
|
-
TA_OTHER = 'OTHR'
|
|
85
|
-
TA_STOPWORD = 'STOP'
|
|
86
|
-
|
|
87
|
-
# Word attributes
|
|
88
|
-
WA_UNSET = '-' # Standardattribut bei der Initialisierung eines Word-Objektes
|
|
89
|
-
WA_IDENTIFIED = 'IDF' # Status, nachdem das Word im Wörterbuch gefunden wurde
|
|
90
|
-
WA_UNKNOWN = '?' # Status, wenn das Word nicht gefunden werden konnte
|
|
91
|
-
WA_KOMPOSITUM = 'KOM' # Wort ist als Kompositum erkannt worden
|
|
92
|
-
WA_MULTIWORD = 'MUL' # Wort ist eine Mehrwortgruppe
|
|
93
|
-
WA_SEQUENCE = 'SEQ' # Wort ist eine Mehrwortgruppe
|
|
94
|
-
WA_UNKMULPART = 'MU?' # Word ist unbekannt, jedoch Teil einer Mehrwortgruppe
|
|
95
|
-
|
|
96
|
-
# Lexical attributes (Wortklassen)
|
|
97
|
-
LA_SUBSTANTIV = 's'
|
|
98
|
-
LA_ADJEKTIV = 'a'
|
|
99
|
-
LA_VERB = 'v'
|
|
100
|
-
LA_EIGENNAME = 'e'
|
|
101
|
-
LA_KOMPOSITUM = 'k'
|
|
102
|
-
LA_MULTIWORD = 'm'
|
|
103
|
-
LA_SEQUENCE = 'q'
|
|
104
|
-
LA_WORTFORM = 'w'
|
|
105
|
-
LA_SYNONYM = 'y'
|
|
106
|
-
LA_STOPWORD = 't'
|
|
107
|
-
LA_TAKEITASIS = 'x'
|
|
108
|
-
LA_UNKNOWN = '?'
|
|
109
|
-
|
|
110
|
-
LA_SORTORDER = [
|
|
111
|
-
LA_MULTIWORD,
|
|
112
|
-
LA_KOMPOSITUM,
|
|
113
|
-
LA_SUBSTANTIV,
|
|
114
|
-
LA_VERB,
|
|
115
|
-
LA_ADJEKTIV,
|
|
116
|
-
LA_EIGENNAME,
|
|
117
|
-
LA_WORTFORM,
|
|
118
|
-
LA_STOPWORD,
|
|
119
|
-
LA_TAKEITASIS,
|
|
120
|
-
LA_SYNONYM,
|
|
121
|
-
LA_UNKNOWN
|
|
122
|
-
].reverse.join
|
|
123
|
-
|
|
124
|
-
# Field separators for DBM files
|
|
125
|
-
KEY_SEP = '='
|
|
126
|
-
FLD_SEP = '|'
|
|
127
|
-
IDX_REF = '^'
|
|
128
|
-
KEY_REF = '*'
|
|
129
|
-
SYS_KEY = '~'
|
|
130
|
-
|
|
131
|
-
end
|