lingo 1.8.5 → 1.8.6
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 +25 -0
- data/README +7 -5
- data/Rakefile +58 -55
- data/{lingo-call.cfg → config/lingo-call.cfg} +1 -1
- data/{lingo.cfg → config/lingo.cfg} +10 -2
- data/{lir.cfg → config/lir.cfg} +10 -2
- data/{de → dict/de}/lingo-abk.txt +0 -0
- data/{de → dict/de}/lingo-dic.txt +0 -0
- data/{de → dict/de}/lingo-mul.txt +0 -0
- data/{de → dict/de}/lingo-syn.txt +0 -0
- data/{de → dict/de}/test_dic.txt +0 -0
- data/{de → dict/de}/test_gen.txt +0 -0
- data/{de → dict/de}/test_mu2.txt +0 -0
- data/{de → dict/de}/test_mul.txt +0 -0
- data/{de → dict/de}/test_sgw.txt +0 -0
- data/{de → dict/de}/test_syn.txt +0 -0
- data/{de → dict/de}/user-dic.txt +0 -0
- data/{en → dict/en}/lingo-dic.txt +0 -0
- data/{en → dict/en}/lingo-irr.txt +0 -0
- data/{en → dict/en}/lingo-mul.txt +0 -0
- data/{en → dict/en}/lingo-syn.txt +0 -0
- data/{en → dict/en}/lingo-wdn.txt +0 -0
- data/{en → dict/en}/user-dic.txt +0 -0
- data/{ru → dict/ru}/lingo-dic.txt +0 -0
- data/{ru → dict/ru}/lingo-mul.txt +0 -0
- data/{ru → dict/ru}/lingo-syn.txt +0 -0
- data/{ru → dict/ru}/user-dic.txt +0 -0
- data/{de.lang → lang/de.lang} +1 -1
- data/{en.lang → lang/en.lang} +0 -0
- data/{ru.lang → lang/ru.lang} +0 -0
- data/lib/lingo.rb +14 -15
- data/lib/lingo/app.rb +4 -2
- data/lib/lingo/attendee.rb +23 -43
- data/lib/lingo/attendee/abbreviator.rb +5 -5
- data/lib/lingo/attendee/debugger.rb +39 -12
- data/lib/lingo/attendee/decomposer.rb +3 -4
- data/lib/lingo/attendee/dehyphenizer.rb +4 -4
- data/lib/lingo/attendee/formatter.rb +1 -3
- data/lib/lingo/attendee/multi_worder.rb +3 -4
- data/lib/lingo/attendee/noneword_filter.rb +8 -12
- data/lib/lingo/attendee/object_filter.rb +6 -3
- data/lib/lingo/attendee/sequencer.rb +5 -5
- data/lib/lingo/attendee/stemmer.rb +3 -2
- data/lib/lingo/attendee/synonymer.rb +3 -4
- data/lib/lingo/attendee/text_reader.rb +39 -38
- data/lib/lingo/attendee/text_writer.rb +10 -10
- data/lib/lingo/attendee/tokenizer.rb +63 -33
- data/lib/lingo/attendee/variator.rb +3 -7
- data/lib/lingo/attendee/vector_filter.rb +132 -65
- data/lib/lingo/attendee/word_searcher.rb +5 -3
- data/lib/lingo/buffered_attendee.rb +1 -3
- data/lib/lingo/call.rb +4 -3
- data/lib/lingo/cli.rb +5 -1
- data/lib/lingo/config.rb +11 -5
- data/lib/lingo/ctl.rb +3 -3
- data/lib/lingo/database.rb +3 -1
- data/lib/lingo/database/crypter.rb +1 -3
- data/lib/lingo/database/source.rb +3 -1
- data/lib/lingo/database/source/key_value.rb +3 -1
- data/lib/lingo/database/source/multi_key.rb +3 -1
- data/lib/lingo/database/source/multi_value.rb +3 -1
- data/lib/lingo/database/source/single_word.rb +3 -1
- data/lib/lingo/database/source/word_class.rb +3 -1
- data/lib/lingo/debug.rb +5 -5
- data/lib/lingo/{agenda_item.rb → deferred_attendee.rb} +21 -12
- data/lib/lingo/error.rb +1 -1
- data/lib/lingo/language.rb +1 -9
- data/lib/lingo/language/dictionary.rb +2 -17
- data/lib/lingo/language/grammar.rb +10 -10
- data/lib/lingo/language/lexical.rb +2 -0
- data/lib/lingo/language/lexical_hash.rb +2 -0
- data/lib/lingo/language/token.rb +17 -3
- data/lib/lingo/language/word.rb +13 -5
- data/lib/lingo/language/word_form.rb +5 -3
- data/lib/lingo/progress.rb +2 -2
- data/lib/lingo/srv.rb +1 -1
- data/lib/lingo/srv/lingosrv.cfg +1 -1
- data/lib/lingo/version.rb +1 -1
- data/lib/lingo/web.rb +1 -1
- data/lib/lingo/web/lingoweb.cfg +1 -1
- data/test/attendee/ts_abbreviator.rb +4 -2
- data/test/attendee/ts_multi_worder.rb +81 -88
- data/test/attendee/ts_noneword_filter.rb +2 -2
- data/test/attendee/ts_object_filter.rb +2 -2
- data/test/attendee/ts_sequencer.rb +40 -20
- data/test/attendee/ts_stemmer.rb +52 -26
- data/test/attendee/ts_text_reader.rb +75 -56
- data/test/attendee/ts_text_writer.rb +6 -4
- data/test/attendee/ts_tokenizer.rb +304 -193
- data/test/attendee/ts_vector_filter.rb +242 -9
- data/test/ref/artikel.non +3 -0
- data/test/ref/artikel.vec +1 -4
- data/test/ref/artikel.vef +940 -0
- data/test/ref/artikel.ven +0 -3
- data/test/ref/artikel.ver +0 -3
- data/test/ref/artikel.vet +2580 -0
- data/test/ref/lir.non +34 -31
- data/test/ref/lir.seq +14 -15
- data/test/ref/lir.vec +37 -37
- data/test/ref/lir.vef +329 -0
- data/test/ref/lir.ven +329 -0
- data/test/ref/lir.ver +329 -0
- data/test/ref/lir.vet +329 -0
- data/test/test_helper.rb +29 -16
- data/test/ts_language.rb +6 -47
- metadata +74 -87
- data/lingo.rb +0 -29
- data/spec/spec_helper.rb +0 -5
data/lib/lingo/database.rb
CHANGED
@@ -30,12 +30,14 @@ require_relative 'database/source'
|
|
30
30
|
|
31
31
|
class Lingo
|
32
32
|
|
33
|
+
#--
|
33
34
|
# Die Klasse Database stellt eine einheitliche Schnittstelle auf Lingo-Datenbanken bereit.
|
34
35
|
# Die Identifizierung der Datenbank erfolgt über die ID der Datenbank, so wie sie in der
|
35
36
|
# Sprachkonfigurationsdatei <tt>de.lang</tt> unter <tt>language/dictionary/databases</tt>
|
36
37
|
# hinterlegt ist.
|
37
38
|
#
|
38
39
|
# Das Lesen und Schreiben der Datenbank erfolgt über die Funktionen []() und []=().
|
40
|
+
#++
|
39
41
|
|
40
42
|
class Database
|
41
43
|
|
@@ -68,7 +70,7 @@ class Lingo
|
|
68
70
|
@srcfile = Lingo.find(:dict, config['name'], relax: true)
|
69
71
|
@crypter = config.key?('crypt') && Crypter.new
|
70
72
|
|
71
|
-
@val = Hash.
|
73
|
+
@val = Hash.nest { [] }
|
72
74
|
|
73
75
|
begin
|
74
76
|
@stofile = Lingo.find(:store, @srcfile)
|
@@ -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 #
|
@@ -31,8 +31,6 @@ class Lingo
|
|
31
31
|
|
32
32
|
class Database
|
33
33
|
|
34
|
-
# Crypter ermöglicht die Ver- und Entschlüsselung von Wörterbüchern
|
35
|
-
|
36
34
|
class Crypter
|
37
35
|
|
38
36
|
def self.digest(key)
|
@@ -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,7 @@ class Lingo
|
|
34
34
|
|
35
35
|
class Database
|
36
36
|
|
37
|
+
#--
|
37
38
|
# Die Klasse Source stellt eine einheitliche Schnittstelle auf die unterschiedlichen Formate
|
38
39
|
# von Wörterbuch-Quelldateien bereit. Die Identifizierung der Quelldatei erfolgt über die ID
|
39
40
|
# der Datei, so wie sie in der Sprachkonfigurationsdatei <tt>de.lang</tt> unter
|
@@ -44,6 +45,7 @@ class Lingo
|
|
44
45
|
#
|
45
46
|
# Nicht korrekt erkannte Zeilen werden abgewiesen und in eine Revoke-Datei gespeichert, die
|
46
47
|
# an der Dateiendung <tt>.rev</tt> zu erkennen ist.
|
48
|
+
#++
|
47
49
|
|
48
50
|
class Source
|
49
51
|
|
@@ -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 #
|
@@ -30,10 +30,12 @@ class Lingo
|
|
30
30
|
|
31
31
|
class Source
|
32
32
|
|
33
|
+
#--
|
33
34
|
# Abgeleitet von Source behandelt die Klasse Dateien mit dem Format <tt>KeyValue</tt>.
|
34
35
|
# Eine Zeile <tt>"Fachbegriff*Fachterminus\n"</tt> wird gewandelt in <tt>[ 'fachbegriff', ['fachterminus#s'] ]</tt>.
|
35
36
|
# Die Wortklasse kann über den Parameter <tt>def-wc</tt> beeinflusst werden.
|
36
37
|
# Der Trenner zwischen Schlüssel und Projektion kann über den Parameter <tt>separator</tt> geändert werden.
|
38
|
+
#++
|
37
39
|
|
38
40
|
class KeyValue < self
|
39
41
|
|
@@ -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 #
|
@@ -30,11 +30,13 @@ class Lingo
|
|
30
30
|
|
31
31
|
class Source
|
32
32
|
|
33
|
+
#--
|
33
34
|
# Abgeleitet von Source behandelt die Klasse Dateien mit dem Format <tt>MultiKey</tt>.
|
34
35
|
# Eine Zeile <tt>"Triumph;Sieg;Erfolg\n"</tt> wird gewandelt in <tt>[ 'triumph', ['sieg', 'erfolg'] ]</tt>.
|
35
36
|
# Die Sonderbehandlung erfolgt in der Methode Database#convert, wo daraus Schlüssel-Werte-Paare in der Form
|
36
37
|
# <tt>[ 'sieg', ['triumph'] ]</tt> und <tt>[ 'erfolg', ['triumph'] ]</tt> erzeugt werden.
|
37
38
|
# Der Trenner zwischen Schlüssel und Projektion kann über den Parameter <tt>separator</tt> geändert werden.
|
39
|
+
#++
|
38
40
|
|
39
41
|
class MultiKey < self
|
40
42
|
|
@@ -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 #
|
@@ -30,9 +30,11 @@ class Lingo
|
|
30
30
|
|
31
31
|
class Source
|
32
32
|
|
33
|
+
#--
|
33
34
|
# Abgeleitet von Source behandelt die Klasse Dateien mit dem Format <tt>MultiValue</tt>.
|
34
35
|
# Eine Zeile <tt>"Triumph;Sieg;Erfolg\n"</tt> wird gewandelt in <tt>[ nil, ['triumph', 'sieg', 'erfolg'] ]</tt>.
|
35
36
|
# Der Trenner zwischen Schlüssel und Projektion kann über den Parameter <tt>separator</tt> geändert werden.
|
37
|
+
#++
|
36
38
|
|
37
39
|
class MultiValue < self
|
38
40
|
|
@@ -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 #
|
@@ -30,9 +30,11 @@ class Lingo
|
|
30
30
|
|
31
31
|
class Source
|
32
32
|
|
33
|
+
#--
|
33
34
|
# Abgeleitet von Source behandelt die Klasse Dateien mit dem Format <tt>SingleWord</tt>.
|
34
35
|
# Eine Zeile <tt>"Fachbegriff\n"</tt> wird gewandelt in <tt>[ 'fachbegriff', ['#s'] ]</tt>.
|
35
36
|
# Die Wortklasse kann über den Parameter <tt>def-wc</tt> beeinflusst werden.
|
37
|
+
#++
|
36
38
|
|
37
39
|
class SingleWord < self
|
38
40
|
|
@@ -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 #
|
@@ -30,9 +30,11 @@ class Lingo
|
|
30
30
|
|
31
31
|
class Source
|
32
32
|
|
33
|
+
#--
|
33
34
|
# Abgeleitet von Source behandelt die Klasse Dateien mit dem Format <tt>WordClass</tt>.
|
34
35
|
# Eine Zeile <tt>"essen,essen #v essen #o esse #s\n"</tt> wird gewandelt in <tt>[ 'essen', ['esse#s', 'essen#v', 'essen#o'] ]</tt>.
|
35
36
|
# Der Trenner zwischen Schlüssel und Projektion kann über den Parameter <tt>separator</tt> geändert werden.
|
37
|
+
#++
|
36
38
|
|
37
39
|
class WordClass < self
|
38
40
|
|
data/lib/lingo/debug.rb
CHANGED
@@ -35,7 +35,7 @@ class Lingo
|
|
35
35
|
|
36
36
|
PS_RE = File.executable?(PS_COMMAND) ? %r{\A#{ENV['LINGO_DEBUG_PS']}\z} : nil
|
37
37
|
|
38
|
-
PS_NO_HEADING = Hash.
|
38
|
+
PS_NO_HEADING = Hash.seen
|
39
39
|
|
40
40
|
def ps(name)
|
41
41
|
system(PS_COMMAND,
|
@@ -62,10 +62,10 @@ class Lingo
|
|
62
62
|
base += "-#{mode}" if mode && !mode.empty?
|
63
63
|
|
64
64
|
{
|
65
|
-
:
|
66
|
-
:
|
67
|
-
:
|
68
|
-
:
|
65
|
+
txt: :FlatPrinter,
|
66
|
+
lines: :FlatPrinterWithLineNumbers,
|
67
|
+
html: :GraphHtmlPrinter,
|
68
|
+
stack: :CallStackPrinter
|
69
69
|
}.each { |ext, name|
|
70
70
|
File.open("#{base}.#{ext}", 'a+', encoding: ENC) { |f|
|
71
71
|
RubyProf.const_get(name).new(result).print(f)
|
@@ -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 #
|
@@ -26,26 +26,35 @@
|
|
26
26
|
|
27
27
|
class Lingo
|
28
28
|
|
29
|
-
class
|
29
|
+
class DeferredAttendee < Attendee
|
30
30
|
|
31
|
-
|
31
|
+
def self.enhance(base)
|
32
|
+
base.instance_variable_set(:@deferr_buffer, [])
|
32
33
|
|
33
|
-
|
34
|
+
def base.command(*args)
|
35
|
+
@deferr_buffer << buf = [args]
|
34
36
|
|
35
|
-
|
36
|
-
|
37
|
+
args.first != :EOT ? buf << control_deferred(*args) :
|
38
|
+
flush_deferred { |block|
|
39
|
+
@deferr_buffer.each { |command_args, control_args|
|
40
|
+
super(*command_args)
|
41
|
+
block[*control_args] if control_args
|
42
|
+
}
|
43
|
+
}
|
44
|
+
end
|
37
45
|
end
|
38
46
|
|
39
|
-
def
|
40
|
-
|
47
|
+
def initialize(config, lingo)
|
48
|
+
self.class.enhance(self)
|
49
|
+
super
|
41
50
|
end
|
42
51
|
|
43
|
-
def
|
44
|
-
|
52
|
+
def control_deferred(cmd, *)
|
53
|
+
raise NotImplementedError, 'must be implemented by subclass'
|
45
54
|
end
|
46
55
|
|
47
|
-
def
|
48
|
-
|
56
|
+
def flush_deferred(&block)
|
57
|
+
raise NotImplementedError, 'must be implemented by subclass'
|
49
58
|
end
|
50
59
|
|
51
60
|
end
|
data/lib/lingo/error.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 #
|
data/lib/lingo/language.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,26 +37,18 @@ class Lingo
|
|
37
37
|
|
38
38
|
module Language
|
39
39
|
|
40
|
-
# String-Konstanten im Datenstrom
|
41
40
|
CHAR_PUNCT = '.'
|
42
41
|
|
43
42
|
TA_WORD = 'WORD'
|
44
43
|
TA_PUNCTUATION = 'PUNC'
|
45
44
|
TA_OTHER = 'OTHR'
|
46
45
|
|
47
|
-
# Standardattribut bei der Initialisierung eines Word-Objektes
|
48
46
|
WA_UNSET = '-'
|
49
|
-
# Status, nachdem das Word im Wörterbuch gefunden wurde
|
50
47
|
WA_IDENTIFIED = 'IDF'
|
51
|
-
# Status, wenn das Word nicht gefunden werden konnte
|
52
48
|
WA_UNKNOWN = '?'
|
53
|
-
# Wort ist als Kompositum erkannt worden
|
54
49
|
WA_COMPOUND = 'KOM'
|
55
|
-
# Wort ist eine Mehrwortgruppe
|
56
50
|
WA_MULTIWORD = 'MUL'
|
57
|
-
# Wort ist eine Mehrwortgruppe
|
58
51
|
WA_SEQUENCE = 'SEQ'
|
59
|
-
# Word ist unbekannt, jedoch Teil einer Mehrwortgruppe
|
60
52
|
WA_UNKMULPART = 'MU?'
|
61
53
|
|
62
54
|
LA_SORTORDER = [
|
@@ -64,12 +64,8 @@ class Lingo
|
|
64
64
|
@src.each { |i| i.close }
|
65
65
|
end
|
66
66
|
|
67
|
-
|
68
|
-
|
69
|
-
# Erstellt aus dem String ein Wort und sucht nach diesem im Wörterbuch.
|
70
|
-
def find_word(str)
|
71
|
-
(@_word ||= {})[str] ||=
|
72
|
-
Word.new(str, WA_UNKNOWN).identify(select_with_suffix(str))
|
67
|
+
def find_word(str, token = nil)
|
68
|
+
Word.new(str, WA_UNKNOWN, token).identify(select_with_suffix(str))
|
73
69
|
end
|
74
70
|
|
75
71
|
def find_synonyms(obj, syn = [], com = true)
|
@@ -86,9 +82,6 @@ class Lingo
|
|
86
82
|
syn
|
87
83
|
end
|
88
84
|
|
89
|
-
# _dic_.select( _aString_ ) -> _ArrayOfLexicals_
|
90
|
-
#
|
91
|
-
# Sucht alle Wörterbücher durch und gibt den ersten Treffer zurück (+mode = first+), oder alle Treffer (+mode = all+)
|
92
85
|
def select(str, lex = [])
|
93
86
|
@src.each { |src|
|
94
87
|
lex.concat(src[str] || next)
|
@@ -99,10 +92,6 @@ class Lingo
|
|
99
92
|
lex
|
100
93
|
end
|
101
94
|
|
102
|
-
# _dic_.select_with_suffix( _aString_ ) -> _ArrayOfLexicals_
|
103
|
-
#
|
104
|
-
# Sucht alle Wörterbücher durch und gibt den ersten Treffer zurück (+mode = first+), oder alle Treffer (+mode = all+).
|
105
|
-
# Sucht dabei auch Wörter, die um wortklassenspezifische Suffixe bereinigt wurden.
|
106
95
|
def select_with_suffix(str)
|
107
96
|
select(str) { |lex|
|
108
97
|
each_affix(str) { |form, attr|
|
@@ -117,10 +106,6 @@ class Lingo
|
|
117
106
|
}
|
118
107
|
end
|
119
108
|
|
120
|
-
# _dic_.select_with_infix( _aString_ ) -> _ArrayOfLexicals_
|
121
|
-
#
|
122
|
-
# Sucht alle Wörterbücher durch und gibt den ersten Treffer zurück (+mode = first+), oder alle Treffer (+mode = all+).
|
123
|
-
# Sucht dabei auch Wörter, die eine Fugung am Ende haben.
|
124
109
|
def select_with_infix(str)
|
125
110
|
select(str) { |lex|
|
126
111
|
each_affix(str, :infix) { |form, _| select(form, lex) }
|
@@ -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 #
|
@@ -28,10 +28,12 @@ class Lingo
|
|
28
28
|
|
29
29
|
module Language
|
30
30
|
|
31
|
+
#--
|
31
32
|
# Die Klasse Grammar beinhaltet grammatikalische Spezialitäten einer Sprache. Derzeit findet die
|
32
33
|
# Kompositumerkennung hier ihren Platz, die mit der Methode find_compound aufgerufen werden kann.
|
33
34
|
# Die Klasse Grammar wird genau wie ein Dictionary initialisiert. Das bei der Initialisierung angegebene Wörterbuch ist Grundlage
|
34
35
|
# für die Erkennung der Kompositumteile.
|
36
|
+
#++
|
35
37
|
|
36
38
|
class Grammar
|
37
39
|
|
@@ -46,7 +48,9 @@ class Lingo
|
|
46
48
|
def initialize(config, lingo)
|
47
49
|
@dic, @suggestions = Dictionary.new(config, lingo), []
|
48
50
|
|
49
|
-
|
51
|
+
if lingo.dictionary_config.key?('compositum')
|
52
|
+
lingo.config.deprecate(:compositum, :compound, self)
|
53
|
+
end
|
50
54
|
|
51
55
|
cfg = lingo.dictionary_config['compound'] ||
|
52
56
|
lingo.dictionary_config['compositum'] # DEPRECATE compositum
|
@@ -57,15 +61,19 @@ class Lingo
|
|
57
61
|
instance_variable_set("@#{k}", cfg.fetch(k.to_s.tr('_', '-'), v).to_i)
|
58
62
|
}
|
59
63
|
|
64
|
+
#--
|
60
65
|
# Die Wortklasse eines Kompositum-Wortteils kann separat gekennzeichnet
|
61
66
|
# werden, um sie von Wortklassen normaler Wörter unterscheiden zu
|
62
67
|
# können z.B. Hausmeister => ['haus/s', 'meister/s'] oder Hausmeister
|
63
68
|
# => ['haus/s+', 'meister/s+'] mit append-wordclass = '+'
|
69
|
+
#++
|
64
70
|
@append_wc = cfg.fetch('append-wordclass', '')
|
65
71
|
|
72
|
+
#--
|
66
73
|
# Bestimmte Sequenzen können als ungültige Komposita erkannt werden,
|
67
74
|
# z.B. ist ein Kompositum aus zwei Adjetiven kein Kompositum, also
|
68
75
|
# skip-sequence = 'aa'
|
76
|
+
#++
|
69
77
|
@sequences = cfg.fetch('skip-sequences', []).map! { |i| i.downcase }
|
70
78
|
end
|
71
79
|
|
@@ -73,11 +81,6 @@ class Lingo
|
|
73
81
|
@dic.close
|
74
82
|
end
|
75
83
|
|
76
|
-
# find_compound(str) -> word wenn level=1
|
77
|
-
# find_compound(str) -> [lex, sta] wenn level!=1
|
78
|
-
#
|
79
|
-
# find_compound arbeitet in verschiedenen Leveln, da die Methode auch rekursiv aufgerufen wird. Ein Level größer 1
|
80
|
-
# entspricht daher einem rekursiven Aufruf
|
81
84
|
def find_compound(str, level = 1, tail = false)
|
82
85
|
level == 1 ? (@_compound ||= {})[str] ||=
|
83
86
|
permute_compound(Word.new(str, WA_UNKNOWN), str, level, tail) :
|
@@ -120,9 +123,6 @@ class Lingo
|
|
120
123
|
ret
|
121
124
|
end
|
122
125
|
|
123
|
-
# test_compound() -> [lex, sta, seq]
|
124
|
-
#
|
125
|
-
# Testet einen definiert zerlegten String auf Kompositum
|
126
126
|
def test_compound(fstr, infix, bstr, level = 1, tail = false)
|
127
127
|
sta, seq, empty = [fstr.length, bstr.length], %w[? ?], [[], [], '']
|
128
128
|
|
@@ -28,11 +28,13 @@ class Lingo
|
|
28
28
|
|
29
29
|
module Language
|
30
30
|
|
31
|
+
#--
|
31
32
|
# Die Klasse Lexical, abgeleitet von der Klasse WordForm, stellt den Container
|
32
33
|
# für eine Grundform eines Wortes bereit, welches mit der Wortklasse versehen ist.
|
33
34
|
#
|
34
35
|
# Wird z.B. aus dem Wörterbuch eine Grundform gelesen, so wird dies in Form eines
|
35
36
|
# Lexical-Objektes zurückgegeben, z.B. Lexical.new('Rennen', 'S') -> (rennen/s)
|
37
|
+
#++
|
36
38
|
|
37
39
|
class Lexical < WordForm
|
38
40
|
|
@@ -28,9 +28,11 @@ class Lingo
|
|
28
28
|
|
29
29
|
module Language
|
30
30
|
|
31
|
+
#--
|
31
32
|
# Die Klasse LexicalHash ermöglicht den Zugriff auf die Lingodatenbanken. Im Gegensatz zur
|
32
33
|
# Klasse Database, welche nur Strings als Ergebnis zurück gibt, wird hier als Ergebnis ein
|
33
34
|
# Array von Lexical-Objekten zurück gegeben.
|
35
|
+
#++
|
34
36
|
|
35
37
|
class LexicalHash
|
36
38
|
|