Debian Codegraph @

docs/source/advanced.rst

raw
1
2
3 Frog generator
4 ==============
5
6 Frog is developed for Dutch and intended as a ready tool to feed your
7 text and to get detailed linguistic information as output. However, it
8 is possible to create a Frog lemmatizer and PoS-tagger for your own data
9 set, either for a specific Dutch corpus or for a corpus in a different
10 language. Froggen is a Frog-generator that expects as input a training
11 corpus in a TAB separated column format of words, lemmas and PoS-tags.
12 This Dutch tweet annotated with lemma and PoS-tag information is an
13 example of input required for froggen:
14
15 ::
16
17 Coolio coolio TSW
18 mam mam N
19 , , LET
20 echt echt ADJ
21 vet vet ADJ
22 lekker lekker ADJ
23 ' ' LET
24 <utt>
25 Eh eh TSW
26 ... ... LET
27 watte wat VNW
28 <utt>
29 ? ? LET
30 #kleinemannetjeswordengroot #kleinemannetjeswordengroot HTAG
31
32 Running froggen -T taggedcorpus -c my\_frog.cfg will create a set of
33 Frog files, including the specified configuration file, that can be used
34 to run your own Frog. Your own instance of Frog should then be invoked
35 using frog -c my\_frog.cfg.
36
37 Besides the option to specify the Frog configuration file name to save
38 the settings, one can also name the output directory where the frog
39 files will be saved with . Froggen also allows an additional dictionary
40 list of words, lemmas and PoS-tags to improve the lemmatizer module with
41 the option .
42
43 -
44 Configuration
45 ===============
46
47 Frog was developed as a modular system that allows for flexibility in
48 usage. In the current version of Frog, modules have a minimum of
49 dependencies between each other so that the different modules can
50 actually run in parallel processes, speeding up the performance time of
51 Frog. The tokenizer, lemmatizer, phrase chunker and dependency parser
52 are all independent from each other. All modules expect tokenized text
53 as input. The NER module, lemmatizer, morphological analyzer and parser do depend on
54 the PoS-tagger output. These dependencies are depicted in figure
55 [fig-arch]. The tokenizer and multi-word chunker are rule-based modules
56 while all other modules are based on trained memory-based classifiers.
57
58
59 For advanced usage of Frog, we can define the individual settings of
60 each module in the Frog configuration file (frog.cfg in the frog source
61 directory) or adapt some of the standard options. Editing this file
62 requires detailed knowledge about the modules and relevant options will
63 be discussed in the next sections. You can create your own frog
64 configuration file and run frog with frog -c myconfigfile.cfg . The
65 configuation file follows the INI file format [15]_ and is divided in
66 individual sections for each of the modules. Some parts of the config
67 file are obligatory and we show the
68
69 ::
70
71 ------------------------------------
72 [[tagger]]
73 set=http://ilk.uvt.nl/folia/sets/frog-mbpos-cgn
74 settings=morgen.settings
75
76 [[mblem]]
77 timblOpts=-a1 -w2 +vS
78 treeFile=morgen.tree
79
80 -------------------------------------
81
82 There are some settings that each of the modules uses:
83
84 - debug Alternative to using –debug on the command line. Debug values
85 ranges from 1 (not very verbose) to 10??? (very verbose). Default
86 setting isdebug=0.
87
88 - version module version that will be mentioned in FoLia XML output
89 file.
90
91 - char\_filter\_file file name of file where you can specify whether
92 certain characters need to be replaced or ignored. For example, by
93 default we translate all forms of exotic single quotes to the
94 standard quote character.
95
96 - set reference to the appropriate Folia XML set definition that is
97 used in the module.
98
99 Tokenizer
100 ~~~~~~~~~
101
102 The tokenizer UCTO has its own reference guide [UCTO]_
103 and more detailed information can also be found on
104 https://languagemachines.github.io/ucto/.
105
106 Multi-word Units
107 ~~~~~~~~~~~~~~~~
108
109 Extraction of multi-word units is a necessary pre-processing step for
110 the Frog parser. The mwu module is a simple script that takes as input
111 the tokenized and PoS-tagged text and concatenates certain tokens like
112 fixed expressions and names. Common mwu such as ‘ad hoc’ are found with
113 a dictionary lookup, and consecutive tokens that are labeled as
114 ‘SPEC(deeleigen)’ by the PoS-tagger are concatenated (gluetag in the
115 Frog config file). The dictionary list of common mwu contains 1325 items
116 and is distributed with the Frog source code and can be found under
117 /etc/frog/Frog.mwu.1.0 . These settings can be modified in the Frog
118 config file.
119
120 Lemmatizer
121 ~~~~~~~~~~
122
123 The lemmatizer is trained on the e-Lex lexicon [ELEX]_
124 with 595,664 unique word form - PoS-tag - lemma combinations. The e-Lex
125 lexicon has been manually cleaned to correct several errors. A timbl
126 classifier [Timbl]_ is trained to learn the conversion of word forms to their
127 lemmas. Each word form in the lexicon is represented as training
128 instance consisting of the last 20 characters of the word form. Note
129 that this abbreviates long words such as *consumptiemaatschappijen* to u
130 m p t i e m a a t s c h a p p i j e n.In total, the training instance
131 base has 402,734 unique word forms. As in the Dutch language
132 morphological changes occur in the word suffix, leaving out the word
133 beginning will not hinder the lemma assignment. The class label of each
134 instance is the PoStag and a rewrite rule to transform the word form to
135 the lemma form. The rewrite rules are applied to the word form endings
136 and delete or insert one or multiple characters. For example to get the
137 lemma *bij* for the noun *bijen* we need to delete the ending *en* to
138 derive the lemma. We show some examples of instances in [ex-lem] where
139 the rewrite rules should be read as follows. For the example the word
140 form *haarspleten* with label N(soort,mv,basis)+Dten+Iet is a plural
141 noun with lemma *haarspleet* that is derived by deleting(+D) the ending
142 *ten* and inserting (+I) the new ending *et*. For ambiguous word forms,
143 the class label consists of multiple rewrite rules. The first rewrite
144 rule with the same PoS tag is selected in such case. Let’s take as
145 example the word *staken* that can be the plural noun form of *staak*,
146 the present tense of the verb *staken* or the past tense of the verb
147 *steken*. Here the PoS determines which rewrite rule is applied. The
148 lemmatizer does not take into account the sentence context of the words
149 and in those rare cases where a word form has different lemmas
150 associated with the same PoS-tags, a random choice is made.
151
152
153
154 Morphological Analyzer
155 ~~~~~~~~~~~~~~~~~~~~~~
156
157 The Morphological analyser MBMA [MBMA]_ aims to
158 decompose tokens into their morphemes reflecting possible spelling
159 changes. Here we show two example words:
160
161
162 ::
163
164 [leven][s][ver][zeker][ing][s][maatschappij][en]
165 [aan][deel][houd][er][s][vergader][ing][en]
166
167 Internally, MBMA not only tries to split tokens into morphemes but also
168 aims to classify each splitting point and its relation to the adjacent
169 morpheme. MBMA is trained on the [CELEX]_ database. Each word is represented by a set of
170 instances that each represent one character of the word in context of 6
171 characters to the left and right. As example we show the 10 instances
172 that were created for the word form *gesneden* in [ex-mbma]. The general
173 rule in Dutch to create a part particle of a verb is to add *ge-* at the
174 beginning and add *-en* at the end. The first character ’g’ is labeled
175 with pv+Ige indicating the start of an past particle (pv) where a prefix
176 *ge* was inserted (+Ige). Instance 3 represents the actual start of the
177 verb (V) and instance 5 reflects the spelling change that transforms the
178 root form *snijd* to the actual used form *sned* (0+Rij\ :math:`>`\ e:
179 replace current character ’ij’ with ’e’ ). Instance 7 also has label
180 ’pv’ and denotes the end boundary of the root morpheme.
181
182 Timbl IGtree [TIMBL]_ trained on 3179,331 instances
183 extracted from that were based on the CELEX lexicon of 293,570 word
184 forms. The morphological character type classes result in a total 2708
185 class labels where the most frequent class ’0’ occurs in 69% of the
186 cases as most characters are inside an morpheme and to do not signify
187 any morpheme border or spelling change. 7% of the instance represent a
188 noun (N) starting point and 4% a verb (V) starting point. The most
189 frequent spelling changes are the insertion of an ’e’ after the morpheme
190 (0/e) (klopt dit?) or a plural inflection (denoted as ’m’).
191
192 The MBMA module of Frog does not analyze every token in the text, it
193 uses the PoS tags assigned by the PoS module to filter out punctuation
194 and names (PoS ’SPEC’) and words that we labeled as ABBREVIATION by the
195 Tokeniser. For these cases, Frog keeps the token as it is without
196 further analysis.
197
198 *Running frog with the parameter –deep-morph results in a much richer
199 morphological analysis including grammatical classes and spelling
200 changes*.
201
202 [ex-mbma]
203
204 +-----+------+------+------+------+------+------+---------+------+------+------+------+------+------+-----------------------+
205 | 1 | \_ | \_ | \_ | \_ | \_ | \_ | **g** | e | s | n | e | d | e | pv+Ige |
206 +-----+------+------+------+------+------+------+---------+------+------+------+------+------+------+-----------------------+
207 | 2 | \_ | \_ | \_ | \_ | \_ | g | e | s | n | e | d | e | n | 0 |
208 +-----+------+------+------+------+------+------+---------+------+------+------+------+------+------+-----------------------+
209 | 3 | \_ | \_ | \_ | \_ | g | e | s | n | e | d | e | n | \_ | V |
210 +-----+------+------+------+------+------+------+---------+------+------+------+------+------+------+-----------------------+
211 | 4 | \_ | \_ | \_ | g | e | s | n | e | d | e | n | \_ | \_ | 0 |
212 +-----+------+------+------+------+------+------+---------+------+------+------+------+------+------+-----------------------+
213 | 5 | \_ | \_ | g | e | s | n | e | d | e | n | \_ | \_ | \_ | 0+Rij\ :math:`>`\ e |
214 +-----+------+------+------+------+------+------+---------+------+------+------+------+------+------+-----------------------+
215 | 6 | \_ | g | e | s | n | e | d | e | n | \_ | \_ | \_ | \_ | 0 |
216 +-----+------+------+------+------+------+------+---------+------+------+------+------+------+------+-----------------------+
217 | 7 | g | e | s | n | e | d | e | n | \_ | \_ | \_ | \_ | \_ | pv |
218 +-----+------+------+------+------+------+------+---------+------+------+------+------+------+------+-----------------------+
219 | 8 | e | s | n | e | d | e | n | \_ | \_ | \_ | \_ | \_ | \_ | 0 |
220 +-----+------+------+------+------+------+------+---------+------+------+------+------+------+------+-----------------------+
221
222 Note that the older version of the morphological analyzer reported in
223 [Tadpole2007]_ was trained on a slightly different version
224 of the data with a context of only 5 instead of 6 characters left and
225 right. In that older study the performance of the morphological analyzer
226 was evaluated on a 10% held out set and an accuracy of 79% on *unseen*
227 words was attained.
228
229 MBMA Configuration file options
230 ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
231
232 When you want to set certain options for the MBMA module, place them
233 under the heading ] in the Frog configuration file.
234
235 - set FoLiA set name for the morphological tag set that MBMA uses.
236
237 - clex-set FoLiA set name PoS-tag- set that MBMA uses internally. As
238 MBMA is trained on CELEX, it uses the CELEX POS-tag set, and not the
239 default PoS-tag set (CGN tag set) of the Frog PoS tagger module.
240 However, these internal pos-tags are mapped back to the CGN tag set.
241
242 - cgn\_clex\_mainFile name of file that contains the mapping of CGN
243 tags to CELEX tags.
244
245 - deep-morph Alternative to using –deep-morph on the command line.
246
247 - treeFile Name of the trained MVMA Timbl tree (usually IG tree is
248 used).
249
250 - timbOpts Timbl options that were used for creating the MBMA treeFile.
251
252 PoS Tagger
253 ~~~~~~~~~~
254
255 The PoS tagger in Frog is based on MBT, a memory-based tagger-generator
256 and tagger [MBT]_ [16]_ trained on a large Dutch corpus
257 of 10,975,324 tokens in 933,891 sentences. This corpus is a mix of
258 several manually annotated corpora but about 90% of the data comes from
259 the transcribed Spoken Dutch Corpus of about nine million tokens
260 [CGN]_ The other ten precent of the training data
261 comes from the ILK corpus (46K tokens), the D-Coi corpus (330K tokens)
262 and the Eindhoven corpus (75K tokens) citeuit den Boogaart 1975 that
263 were re-tagged with CGN tag set. The tag set consists of 12 coarse
264 grained PoS-tags and 280 fine-grained PoS tag labels. Note that the
265 chosen main categories (shown in table [tab-pos-tags]) are well in line
266 with a universal PoS tag set as proposed by which has almost the same
267 tags. The universal set has a *particles* tag for function words that
268 signify negation, mood or tense while CGN has an *interjection* tag to
269 label words like ‘aha’ and ‘oké’ that are typically used in spoken
270 utterances.
271
272 Named Entity Recognition
273 ~~~~~~~~~~~~~~~~~~~~~~~~
274
275 The Named Entity Recognizer (NER) is an MBT classifier [MBT]_
276 trained on the SoNar 1 million word corpus
277 labeled with manually verified NER labels. The annotation is flat and in
278 case of nested names, the longest name is annotated. For example a
279 phrase like ’het Gentse Stadsbestuur’ is labeled as
280 :math:`het [Gentse stadsbestuur]_{ORG}`. ’Gentse’ also refers to a
281 location but the overarching phrase is the name of an organization and
282 this label takes precedence. Dutch determiners are never included as
283 part of the name. Details about the annotation of the training data can
284 be found in the Sonar NE annotation guidelines [NERmanual]_.
285 | The NER module does not use PoS tags but learns the relation between
286 words and name tags directly. An easy way to adapt the NER module to a
287 new domain is to give an additional name list to the NER module. The
288 names on this list has the following format: the full name followed by
289 a tab and the name label as exemplified here.The name list can be
290 specified in the configuration file under :math:`[[NER]]` as
291 known\_ners=nerfile.
292
293 +----------------------+-------+
294 | Zwarte Zwadderneel | per |
295 +----------------------+-------+
296 | LaMa groep | org |
297 +----------------------+-------+
298
299 Phrase Chunker
300 ~~~~~~~~~~~~~~
301
302 The phrase chunker module is based on the chunker developed in the 90’s [Daelemans1999]_ and uses MBT [MBT]_ as
303 classifier. The chunker adopted the BIO tags to represent chunking as a
304 tagging task where B-tags signal the start of the chunk, I-tags inside
305 the chunk and O-tags outside the chunk. In the context of the TTNWW
306 [TTNWW]_, the chunker was updated and trained on a newer and larger
307 corpus of one million words, the Lassy Small corpus
308 [lassysmall]_. This corpus a annotated with syntactic trees that were first converted to a flat structure with a
309 script.
310
311 Parser
312 ~~~~~~
313
314 The default parser in Frog is the Constraint-satisfaction inference-based dependency parser (CSI-DP)
315 [Canisius2009]_ . However, it is also possible to switch to the Alpino
316 parser instead. The Alpino parser is more accurate in predicting
317 syntactic labels but has a much higher memory usage and is slower.
318 Alpino is not integrated in Frog, you need to install the parser
319 locally on your machine and can integrate the parser output in Frog
320 using the option --alpino. If you want to use an Alpino version on a
321 remoter server, you can specify this --alpino=server. We refer to the
322 [Alpino]_ documentation for details of the Alpino parser.
323
324 CSI-DP is trained on the manually verified
325 *Lassy small* corpus [lassysmall]_ and several million
326 tokens of automatically parsed text by the Alpino parser
327 [ALPINO]_ from Wikipedia pages, newspaper
328 articles, and the Eindhoven corpus. When CSI-DP is parsing a new
329 sentence, the parser first aims to predict low level syntactic
330 information, such as the syntactic dependency relation between each pair
331 of tokens in the sentence and the possible relation types a certain
332 token can have. These low level predictions take the form of soft
333 weighted constraints. In the second step, the parser aims to generate
334 the final parse tree where each token has only one relation with another
335 token using a constraint solver based on the Eisner parsing algorithm
336 [Eisner2000]_. The soft constraints determine the
337 search space for the constraint solver to find the optimal solution.
338 s
339 CSI-DP applies three types of constraints: dependency constraints,
340 modifier constraints and direction constraints. For each constraint
341 type, a separate timbl classifier is trained. Each pair of tokens in the
342 training set occurs with a certain set of possible dependency relations
343 and this information is learned by the dependency constraint classifier.
344 An instance is created for each token pair and its relation where one is
345 the modifier and and one is head. Note that a pair always creates two
346 instances where these roles are switched. The TiMBL classifier trained
347 on this instance base will then for each token pair predict zero, one or
348 multiple relations and these relations form the soft constraints that
349 are the input for the general solver who selects the overall best parse
350 tree. The potential relation between the token pair is expressed in the
351 following features: the words and PoS tags of each token and its left
352 and right neighboring token, the distance between the two tokens in
353 number of intermediate tokens, and a position feature expressing whether
354 the token is located right or left of the potential head word.
355
356 For each token in the sentence, instances are created between the token
357 and all other tokens in the sentence with a maximum distance of 8 tokens
358 left and right. The maximum distance of 8 tokens covers 95% of all
359 present dependency relations in the training set
360 [Canisius+2006]_. This leads to a unbalance of
361 instances that express an actual syntactic relation between a word pair
362 and negative cases. Therefore, the negative instances in the training
363 set were reduced by randomly sampling a set of negative cases that is
364 twice as big as the number of positive cases (based on experiments in
365 [Canisius2009]_).
366
367 The second group of constraints are the modifier constraints that
368 express the possible syntactic relations for each single token that it
369 has in the training set. The feature set for these instances consists of
370 the local context in 1 or 2 ?? words and PoS tags of the token.
371
372 The third group of direction constraints specify for each token in the
373 sentence whether the potential linked head word is left or right of the
374 word, or the root. Based on evidence in the training set, a word is
375 added with one, two or three possible positions as soft weighted
376 constraints. For example the token *politie* might occur in a left
377 positioned subject relation to a root verb, a right positioned direct
378 object relation, of in an elliptic sentence as the root form itself.
379
380
381 References
382 =============
383
384 .. [15]
385 More about the INI file
386 format:\ https://en.wikipedia.org/wiki/INI_file)
387
388 .. [16]
389 MBT available at http://languagemachines.github.io/mbt/
390
391 .. [17]
392 https://github.com/proycon/python-frog
393
394 .. [18]
395 Part of PyNLPL: https://github.com/proycon/pynlpl
396
397 .. [19]
398 https://github.com/vanatteveldt/frogr/
399
400 .. [20]
401 https://github.com/Machiel/gorf
402
403
404 .. [CELEX] Baayen, R. H., R. Piepenbrock, and H. van Rijn. 1993. The CELEX lexical data base on CD-ROM. Linguistic Data Consortium, Philadelphia, PA.
405
406 .. [ELEX] TST-centrale. 2007. E-lex voor taal- en spraaktechnologie, version 1.1. Technical report, Nederlandse TaalUnie.
407
408 .. [Alpino] Bouma, G., G. Van Noord R., and Malouf. 2001. Alpino: Wide-coverage computational analysis of dutch. Language and Computers, 37(1):45–59.
409
410 .. [Canisius2009] Canisius, Sander. 2009. Structured prediction for natural language processing. A constraint satisfaction approach. Ph.D. thesis, Tilburg University.
411
412 .. [Canisius+2006] Canisius, Sander, Toine Bogers, Antal van den Bosch, Jeroen Geertzen, and Erik Tjong Kim Sang. 2006. Dependency parsing by inference over high-recall dependency predictions. In Proceedings of the Tenth Conference on Computational Natural Language Learning, CoNLL-X ’06, pages 176–180, Stroudsburg, PA, USA. Association for Computational Linguistics.
413
414 .. [MBT] Daelemans, W., J. Zavrel, A. Van den Bosch, and K. Van der Sloot. 2010. MBT: Memory-based tagger, version 3.2, reference guide. Technical Report ILK Research Group Technical Report Series 10-04, ILK, Tilburg University, The Netherlands.
415
416 .. [Timbl] Daelemans, W., J. Zavrel, K. Van der Sloot, and A. Van den Bosch. 2004. TiMBL: Tilburg Memory Based Learner, version 6.3, reference manual. Technical Report ILK Research Group Technical Report Series 10-01, ILK, Tilburg University, The Netherlands.
417
418 .. [Daelemans1999] Daelemans, Walter, Sabine Buchholz, and Jorn Veenstra. 1999. Memory-based shallow parsing. In Proceedings of CoNLL-99, pages 53–60.
419
420 .. [NERmanual] Desmet, Bart and Veronique Hoste. 2009. Named Entity Annotatierichtlijnen voor het Nederlands. Technical Report LT3 09.01., LT3, University Ghent, Belgium.
421
422 .. [Eisner2000] Eisner, Jason, 2000. Bilexical grammars and their cubic-time parsing algorithms, pages 29–61. Springer. Haque, R., S. Kumar Naskar, A. Van den Bosch, and A. Way. 2011. Integrating source-language context into phrase-based statistical machine translation. Machine Translation, 25(3):239–285, September.
423
424 .. [CGN] Schuurman, Ineke, Machteld Schouppe, Heleen Hoekstra, and Ton van der Wouden. 2003. CGN, an annotated corpus of spoken Dutch. In Anne Abeillé, Silvia Hansen-Schirra, and Hans Uszkoreit, editors, Proceedings of 4th International Workshop on Linguistically Interpreted Corpora (LINC-03), pages 101–108, Budapest, Hungary.
425
426 .. [Tadpole2007] van den Bosch, Antal, B. Busser, S. Canisius, and Walter Daelemans, 2007. An efficient memory-based morphosyntactic tagger and parser for Dutch, pages 191–206. LOT, Utrecht.
427
428 .. [Lassysmall] van Noord, Gertjan, Ineke Schuurman, and Gosse Bouma. 2011. Lassy syntactische annotatie. Technical report.
429
430 .. [LASSY] Van Noord, Gertjan, Gosse Bouma, Frank Van Eynde, Daniel De Kok, Jelmer Van der Linde, Ineke Schuurman, Erik Tjong Kim Sang, and Vincent Vandeghinste. 2013a. Large scale syntactic annotation of written dutch: Lassy. In Essential Speech and Language Technology for Dutch. Springer, pages 147–164.
431
432 .. [Folia] van Gompel, M. and M. Reynaert. 2013. Folia: A practical xml format for linguistic annotation - a descriptive and comparative study. Computational Linguistics in the Netherlands Journal, 3.
433
434 .. [VanEynde2004] Van Eynde, Frank. 2004. Part of speech tagging en lemmatisering van het corpus gesproken nederlands. Technical report, Centrum voor Computerlinguıstiek, KU Leuven, Belgium.
435
436 .. [UCTO] Maarten van Gompel, Ko van der Sloot, Iris Hendrickx and Antal van den Bosch. Ucto: Unicode Tokeniser. Reference Guide, Language and Speech Technology Technical Report Series 18-01, Radboud University, Nijmegen, October, 2018, Available from https://ucto.readthedocs.io/