| 1 |
.. _installation: |
| 2 |
|
| 3 |
|
| 4 |
Installation |
| 5 |
============== |
| 6 |
|
| 7 |
You can download Frog, manually compile and install it from source. |
| 8 |
However, due to the many dependencies and required technical expertise |
| 9 |
this is not an easy endeavor. |
| 10 |
|
| 11 |
Linux users should first check whether their distribution’s package |
| 12 |
manager has up-to-date packages for Frog, as this provides the easiest |
| 13 |
way of installation. |
| 14 |
|
| 15 |
If no up-to-date package exists, we recommend to use **LaMachine**. Frog |
| 16 |
is part of our LaMachine software distribution and includes all |
| 17 |
necessary dependencies. It runs on Linux, BSD and Mac OS X. It can also |
| 18 |
run as a virtual machine under other operating systems, including |
| 19 |
Windows. LaMachine makes the installation of Frog straightforward; |
| 20 |
detailed instructions for the installation of LaMachine can be found |
| 21 |
here: http://proycon.github.io/LaMachine/. |
| 22 |
|
| 23 |
Manual compilation and installation |
| 24 |
--------------------------------- |
| 25 |
|
| 26 |
The source code of Frog for manual installation can be obtained from |
| 27 |
GitHub. Because of file sizes and to cleanly separate code from data, |
| 28 |
the data and configuration files for the modules of Frog have been |
| 29 |
packaged separately. |
| 30 |
|
| 31 |
- Source code repository: https://github.com/LanguageMachines/frog/ |
| 32 |
|
| 33 |
- Stable releases [1]_: |
| 34 |
https://github.com/LanguageMachines/frog/releases/ |
| 35 |
|
| 36 |
- Frog data repository: https://github.com/LanguageMachines/frogdata/ |
| 37 |
(required dependency!) |
| 38 |
|
| 39 |
To compile these manually, you first need current versions of the |
| 40 |
following dependencies of our software, and compile and install them in |
| 41 |
the order specified here: |
| 42 |
|
| 43 |
- ``ticcutils``\ [2]_ - A shared utility library |
| 44 |
|
| 45 |
- ``libfolia``\ [3]_ - A library for the FoLiA format |
| 46 |
|
| 47 |
- ``ucto``\ [4]_ - A rule-based tokenizer |
| 48 |
|
| 49 |
- ``timbl``\ [5]_ - The memory-based classifier engine |
| 50 |
|
| 51 |
- ``mbt``\ [6]_ - The memory-based tagger |
| 52 |
|
| 53 |
- ``frogdata``\ [7]_ - Datafiles needed to run Frog |
| 54 |
|
| 55 |
You will also need the following third party dependencies: |
| 56 |
|
| 57 |
- **icu** - A C++ library for Unicode and Globalization support. On |
| 58 |
Debian/Ubuntu systems, install the package ``libicu-dev``. |
| 59 |
|
| 60 |
- **libxml2** - An XML library. On Debian/Ubuntu systems install the |
| 61 |
package ``libxml2-dev``. |
| 62 |
|
| 63 |
- **textcat** - A library for language detection. On Debian/Ubuntu systems install the |
| 64 |
package ``libexttextcat-dev``. |
| 65 |
|
| 66 |
- A sane build environment with a C++ compiler (e.g. GCC or Clang), |
| 67 |
autotools, autoconf-archive, libtool, pkg-config |
| 68 |
|
| 69 |
The actual compilation proceeds by entering the Frog directory and |
| 70 |
issuing the following commands: |
| 71 |
|
| 72 |
:: |
| 73 |
|
| 74 |
$ bash bootstrap.sh |
| 75 |
$ ./configure |
| 76 |
$ make |
| 77 |
$ sudo make install |
| 78 |
|
| 79 |
| To install in a non-standard location (``/usr/local/`` by default), |
| 80 |
you may use the ``–prefix`` option in the configure step: |
| 81 |
| ``./configure –prefix=/desired/installation/path/``. |
| 82 |
|
| 83 |
|
| 84 |
Quick start guide |
| 85 |
========== |
| 86 |
|
| 87 |
Frog aims to automatically enrich Dutch text with linguistic information |
| 88 |
of various forms. Frog integrates several NLP modules that perform the |
| 89 |
following tasks: tokenize text to split punctuation from word forms |
| 90 |
(including recognition of sentence boundaries and multi-word units), |
| 91 |
assignment of part-of-speech tags, lemmas, and morphological and |
| 92 |
syntactic information to words. |
| 93 |
|
| 94 |
We give a brief explanation on running Frog to get you started quickly, followed by a more elaborate description of |
| 95 |
using Frog and how to manipulate the settings for each of the separate |
| 96 |
modules in Chapter: :doc:`Frog Modules<moduleDetails>`. |
| 97 |
|
| 98 |
Frog is developed as a command line tool. We assume the reader already |
| 99 |
has at least basic command line skills. |
| 100 |
|
| 101 |
Typing ``frog -h`` on the command line results in a brief overview of all |
| 102 |
available command line options. Frog is typically run on an input |
| 103 |
document, which is specified using the -t option for plain |
| 104 |
text, --JSONin for |
| 105 |
documents in JSON format, or -x for documents in the FoLiA XML format. It is, however, |
| 106 |
also possible to run it interactively or as a server. We show an example |
| 107 |
of the output of Frog when processing the contents of a plain-text file |
| 108 |
``test.txt``, containing just the sentence *In ’41 werd aan de stamkaart |
| 109 |
een z.g. inlegvel toegevoegd.* |
| 110 |
|
| 111 |
We run Frog as follows: $ frog -t test.txt |
| 112 |
|
| 113 |
Frog will present the output as shown in the example below: |
| 114 |
|
| 115 |
|
| 116 |
|
| 117 |
+----+------------+-----------+--------------------+------------------------------+----------+---+------+---+------+ |
| 118 |
| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | |
| 119 |
+====+============+===========+====================+==============================+==========+===+======+===+======+ |
| 120 |
| 1 | In | in | [in] | VZ(init) | 0.987660 | O | B-PP | 0 | ROOT | |
| 121 |
+----+------------+-----------+--------------------+------------------------------+----------+---+------+---+------+ |
| 122 |
| 2 | ’41 | '41 |['41] | TW(hoofd,vrij) | 0.719498 | O | B-NP | 1 | obj1 | |
| 123 |
+----+------------+-----------+--------------------+------------------------------+----------+---+------+---+------+ |
| 124 |
| 3 | werd | worden | [word] | WW(pv,verl,ev) | 0.999799 | O | B-VP | 0 | ROOT | |
| 125 |
+----+------------+-----------+--------------------+------------------------------+----------+---+------+---+------+ |
| 126 |
| 4 | aan | aan | [aan] | VZ(init) | 0.996734 | O | B-PP |10 | mod | |
| 127 |
+----+------------+-----------+--------------------+------------------------------+----------+---+------+---+------+ |
| 128 |
| 5 | de | de | [de] | LID(bep,stan,rest) | 0.999964 | O | B-NP | 6 | det | |
| 129 |
+----+------------+-----------+--------------------+------------------------------+----------+---+------+---+------+ |
| 130 |
| 6 | stamkaart | stamkaart | [stam][kaart] | N(soort,ev,basis,zijd,stan) | 0.996536 | O | I-NP | 4 | obj1 | |
| 131 |
+----+------------+-----------+--------------------+------------------------------+----------+---+------+---+------+ |
| 132 |
| 7 | een | een | [een] | LID(onbep,stan,agr) | 0.995147 | O | B-NP | 9 | det | |
| 133 |
+----+------------+-----------+--------------------+------------------------------+----------+---+------+---+------+ |
| 134 |
| 8 | z.g. | z.g. | [z.g.] | ADJ(prenom,basis,met-e,stan) | 0.500000 | O | I-NP | 9 | mod | |
| 135 |
+----+------------+-----------+--------------------+------------------------------+----------+---+------+---+------+ |
| 136 |
| 9 | inlegvel | inlegvel | [in][leg][vel] | N(soort,ev,basis,zijd,stan) | 1.000000 | O | I-NP |10 | obj1 | |
| 137 |
+----+------------+-----------+--------------------+------------------------------+----------+---+------+---+------+ |
| 138 |
| 10 | toegevoegd | toevoegen | [toe][ge][voeg][d] | WW(vd,vrij,zonder) | 0.998549 | O | B-VP | 3 | vc | |
| 139 |
+----+------------+-----------+--------------------+------------------------------+----------+---+------+---+------+ |
| 140 |
| 11 | . | . | [.] | LET() | 1.000000 | O | O |10 | punct| |
| 141 |
+----+------------+-----------+--------------------+------------------------------+----------+---+------+---+------+ |
| 142 |
|
| 143 |
The ten TAB-delimited columns in the output of Frog contain the |
| 144 |
information we list below. This columned output is intended for quick |
| 145 |
interpretation on the terminal or in scripts. It does, however, not |
| 146 |
contain every detail available to Frog. |
| 147 |
|
| 148 |
1. Token number |
| 149 |
(Number is reset every sentence.) |
| 150 |
|
| 151 |
2. Token |
| 152 |
The text of the token/word |
| 153 |
|
| 154 |
3. Lemma |
| 155 |
The lemma |
| 156 |
|
| 157 |
4. Morphological segmentation |
| 158 |
A morphological segmentation in which each morpheme is enclosed in |
| 159 |
square brackets |
| 160 |
|
| 161 |
5. PoS tag |
| 162 |
The Part-of-Speech tag according to the CGN tagset [VanEynde2004]_. |
| 163 |
|
| 164 |
6. Confidence |
| 165 |
in the PoS tag, a number between 0 and 1, representing the |
| 166 |
probability mass assigned to the best guess tag in the tag |
| 167 |
distribution |
| 168 |
|
| 169 |
7. Named entity type |
| 170 |
in BIO-encoding [8]_ |
| 171 |
|
| 172 |
8. Base phrase chunk |
| 173 |
in BIO-encoding |
| 174 |
|
| 175 |
9. Token number of head word |
| 176 |
in dependency graph (according to the Frog parser) |
| 177 |
|
| 178 |
10. Dependency relation type |
| 179 |
of the word with head word |
| 180 |
|
| 181 |
|
| 182 |
For full output, you will want to instruct Frog to output to a FoLiA XML |
| 183 |
file. This is done using the -X option, followed by the name of the |
| 184 |
output file. |
| 185 |
|
| 186 |
To run Frog in this way we execute: $ frog -t test.txt -X test.xml The |
| 187 |
result is a file in FoLiA XML format [FOLIA]_ that |
| 188 |
contains all information in a more structured and verbose fashion. More |
| 189 |
information about this file format, including a full specification, |
| 190 |
programming libraries, and other tools, can be found on |
| 191 |
https://proycon.github.io/folia. We show an example of the XML structure |
| 192 |
for the token *aangesneden* in the XML example below and explain the |
| 193 |
details of this structure in the :doc: `Folia |
| 194 |
Documentation<https://folia.readthedocs.io/en/latest/introduction.html#annotation-types>`. Each |
| 195 |
of the layers |
| 196 |
of linguistic output will be discussed in more detail in the |
| 197 |
Chapter :doc: `Frog Modules<moduleDetails>`. |
| 198 |
|
| 199 |
:: |
| 200 |
|
| 201 |
<w xml:id="WP3452.p.1.s.1.w.4" class="WORD"> |
| 202 |
<t>aangesneden</t> |
| 203 |
<pos class="WW(vd,vrij,zonder)" confidence="0.875" head="WW"> |
| 204 |
<feat class="vd" subset="wvorm"/> |
| 205 |
<feat class="vrij" subset="positie"/> |
| 206 |
<feat class="zonder" subset="buiging"/> |
| 207 |
</pos> |
| 208 |
<lemma class="aansnijden"/> |
| 209 |
<morphology> |
| 210 |
<morpheme> |
| 211 |
<t>aan</t> |
| 212 |
</morpheme> |
| 213 |
<morpheme> |
| 214 |
<t>ge</t> |
| 215 |
</morpheme> |
| 216 |
<morpheme> |
| 217 |
<t>snijd</t> |
| 218 |
</morpheme> |
| 219 |
<morpheme> |
| 220 |
<t>en</t> |
| 221 |
</morpheme> |
| 222 |
</morphology> |
| 223 |
</w> |
| 224 |
|
| 225 |
Input and Output options |
| 226 |
~~~~~~~~~~~~~~~~~~~~~~~~ |
| 227 |
|
| 228 |
By default the output of Frog is written to screen (i.e. standard |
| 229 |
output). There are two options for writing the output to file: |
| 230 |
|
| 231 |
- ``-o <filename>`` – Writes columned (TAB delimited) data to file. |
| 232 |
|
| 233 |
- ``-X <filename>`` – Writes FoLiA XML to file. |
| 234 |
|
| 235 |
We already saw the input option ``-t <filename>`` for plain-text files. It |
| 236 |
is also possible to read FoLiA XML documents instead, using the `` -x |
| 237 |
<filename>`` option. Frog also allows for inputfiles and outputfiles in |
| 238 |
JSON format, when using the options ``--JSONin`` or |
| 239 |
``--JSONout`` respectively. We show an example of JSON input and output |
| 240 |
below. Each linguistic layer in the output is presented as a key-value pair for each |
| 241 |
detected token in the text input. |
| 242 |
|
| 243 |
|
| 244 |
:: |
| 245 |
|
| 246 |
JSON input: |
| 247 |
[{"sentence":"Dit nog zo'n boeiende test."}] |
| 248 |
|
| 249 |
|
| 250 |
JSON output: |
| 251 |
[ |
| 252 |
{ |
| 253 |
"chunking": { |
| 254 |
"confidence": 1.0, |
| 255 |
"tag": "B-NP" |
| 256 |
}, |
| 257 |
"index": 1, |
| 258 |
"lemma": "dit", |
| 259 |
"morph": "[dit]", |
| 260 |
"parse": { |
| 261 |
"parse_index": 2, |
| 262 |
"parse_role": "su" |
| 263 |
}, |
| 264 |
"pos": { |
| 265 |
"confidence": 0.7770847770847771, |
| 266 |
"tag": "VNW(aanw,pron,stan,vol,3o,ev)" |
| 267 |
}, |
| 268 |
"ucto": { |
| 269 |
"new_paragraph": true, |
| 270 |
"token": "WORD" |
| 271 |
}, |
| 272 |
"word": "Dit" |
| 273 |
}, |
| 274 |
{ |
| 275 |
"chunking": { |
| 276 |
"confidence": 1.0, |
| 277 |
"tag": "B-VP" |
| 278 |
}, |
| 279 |
"index": 2, |
| 280 |
"lemma": "zijn", |
| 281 |
"morph": "[zijn] |
| 282 |
"parse": { |
| 283 |
"parse_index": 0, |
| 284 |
"parse_role": "ROOT" |
| 285 |
}, |
| 286 |
"pos": { |
| 287 |
"confidence": 0.9998905788379473, |
| 288 |
"tag": "WW(pv,tgw,ev)" |
| 289 |
}, |
| 290 |
"ucto": { |
| 291 |
"token": "WORD" |
| 292 |
}, |
| 293 |
"word": "is" |
| 294 |
}, |
| 295 |
{ |
| 296 |
"chunking": { |
| 297 |
"confidence": 1.0, |
| 298 |
"tag": "B-NP" |
| 299 |
}, |
| 300 |
"index": 3, |
| 301 |
"lemma": "een", |
| 302 |
"morph": "[een]", |
| 303 |
"parse": { |
| 304 |
"parse_index": 4, |
| 305 |
"parse_role": "det" |
| 306 |
}, |
| 307 |
"pos": { |
| 308 |
"confidence": 0.9991126885536823, |
| 309 |
"tag": "LID(onbep,stan,agr)" |
| 310 |
}, |
| 311 |
"ucto": { |
| 312 |
"token": "WORD" |
| 313 |
}, |
| 314 |
"word": "een" |
| 315 |
}, |
| 316 |
{ |
| 317 |
"chunking": { |
| 318 |
"confidence": 1.0, |
| 319 |
"tag": "I-NP" |
| 320 |
}, |
| 321 |
"index": 4, |
| 322 |
"lemma": "test", |
| 323 |
"morph": "[test]", |
| 324 |
"parse": { |
| 325 |
"parse_index": 2, |
| 326 |
"parse_role": "predc" |
| 327 |
}, |
| 328 |
"pos": { |
| 329 |
"confidence": 0.9030552291421856, |
| 330 |
"tag": "N(soort,ev,basis,zijd,stan)" |
| 331 |
}, |
| 332 |
"ucto": { |
| 333 |
"space": false, |
| 334 |
"token": "WORD" |
| 335 |
}, |
| 336 |
"word": "test" |
| 337 |
}, |
| 338 |
}, |
| 339 |
{ |
| 340 |
"chunking": { |
| 341 |
"confidence": 1.0, |
| 342 |
"tag": "O" |
| 343 |
}, |
| 344 |
"index": 5, |
| 345 |
"lemma": ".", |
| 346 |
"morph": "[.]", |
| 347 |
"parse": { |
| 348 |
"parse_index": 4, |
| 349 |
"parse_role": "punct" |
| 350 |
}, |
| 351 |
"pos": { |
| 352 |
"confidence": 1.0, |
| 353 |
"tag": "LET()" |
| 354 |
}, |
| 355 |
"ucto": { |
| 356 |
"token": "PUNCTUATION" |
| 357 |
}, |
| 358 |
"word": "." |
| 359 |
} |
| 360 |
] |
| 361 |
|
| 362 |
|
| 363 |
|
| 364 |
Besides input of a single plain text file, Frog also accepts a directory |
| 365 |
of plain text files (or JSON format) as input –testdir=<directory> , which can also be |
| 366 |
written to an output directory with parameter –outputdir=<dir>. The |
| 367 |
FoLiA equivalent for –outputdir is –xmldir. To read multiple FoLiA |
| 368 |
documents, instead of plain-text documents, from a directory, use -x |
| 369 |
–testdir=<directory>. |
| 370 |
|
| 371 |
Interactive Mode |
| 372 |
~~~~~~~~~~~~~~~~~~ |
| 373 |
|
| 374 |
Frog can be started in an interactive mode by simply typing ``frog`` on |
| 375 |
the command line. Frog will present a ``frog>`` prompt after which you |
| 376 |
can type text for processing. By default, you will press ENTER at an |
| 377 |
empty prompt before Frog will process the prior input. This allows for |
| 378 |
multiline sentences to be entered. To change this behavior, you may want |
| 379 |
to start Frog with the -n option instead, which tells it to assume each |
| 380 |
input line is a sentence. FoLiA input or output is not supported in |
| 381 |
interactive mode. |
| 382 |
|
| 383 |
To exit this mode, type CTRL-D. |
| 384 |
|
| 385 |
Server mode |
| 386 |
~~~~~~~~~~~ |
| 387 |
|
| 388 |
Frog offers a server mode that launches it as a daemon to which multiple |
| 389 |
clients can connect over TCP. The server mode is started using the |
| 390 |
``-S <port>`` option. Note that options like ``-n`` and ``–skip`` are |
| 391 |
valid in this mode too. |
| 392 |
|
| 393 |
You can for example start a Frog server on port 12345 as follows: |
| 394 |
``$ frog -S 12345``. |
| 395 |
|
| 396 |
The simple protocol clients should adhere to is as follows: |
| 397 |
|
| 398 |
- The client sends text to process (may contain newlines) |
| 399 |
|
| 400 |
- The client sends the string ``EOT`` followed by a newline |
| 401 |
|
| 402 |
- The server responds with columned, TAB delimited output, one token |
| 403 |
per line, and an empty line between sentences. |
| 404 |
|
| 405 |
- FoLiA input and output are also possible, using the ``-x`` and ``-X`` |
| 406 |
options without parameters. When ``-X`` is selected, TAB delimited |
| 407 |
output is suppressed. |
| 408 |
|
| 409 |
- The last line of the server response consists of the string |
| 410 |
``READY``, so the client knows it received the full response. |
| 411 |
|
| 412 |
Communicating with Frog on such a low-level may not be necessary, as |
| 413 |
there are already some libraries available to communicate with Frog for |
| 414 |
several programming languages: |
| 415 |
|
| 416 |
- Python – **pynlpl.clients.frogclient**\ [9]_ |
| 417 |
|
| 418 |
- R – **frogr**\ [10]_ – by Wouter van Atteveldt |
| 419 |
|
| 420 |
- Go – **gorf**\ [11]_ – by Machiel Molenaar |
| 421 |
|
| 422 |
The following example shows how to communicate with the Frog server from |
| 423 |
Python using the Frog client in PyNLPl, which can generally be installed |
| 424 |
with a simple ``pip install pynlpl``, or is already available if you use |
| 425 |
our LaMachine distribution. |
| 426 |
|
| 427 |
:: |
| 428 |
|
| 429 |
from pynlpl.clients.frogclient import FrogClient |
| 430 |
|
| 431 |
port = 12345 |
| 432 |
frogclient = FrogClient('localhost',port) |
| 433 |
|
| 434 |
for data in frogclient.process("Dit is de tekst om te verwerken.") |
| 435 |
word, lemma, morph, pos = data[:4] |
| 436 |
#TODO: Further processing per word |
| 437 |
|
| 438 |
Do note that Python users may prefer using the ``python-frog`` binding |
| 439 |
instead, which will be described in the Chapter :doc:`Python Frog |
| 440 |
<pythonfrog>`. This binds |
| 441 |
with Frog natively without using a client/server model and therefore has |
| 442 |
better performance. |
| 443 |
|
| 444 |
|
| 445 |
|
| 446 |
|
| 447 |
|
| 448 |
.. [1] |
| 449 |
The source code repository points to the latest development version |
| 450 |
by default, which may contain experimental features. Stable releases |
| 451 |
are deliberate snapshots of the source code. It is recommended to |
| 452 |
grab the latest stable release. |
| 453 |
|
| 454 |
.. [2] |
| 455 |
https://github.com/LanguageMachines/ticcutils |
| 456 |
|
| 457 |
.. [3] |
| 458 |
https://github.com/LanguageMachines/libfolia |
| 459 |
|
| 460 |
.. [4] |
| 461 |
https://languagemachines.github.io/ucto |
| 462 |
|
| 463 |
.. [5] |
| 464 |
https://languagemachines.github.io/timbl |
| 465 |
|
| 466 |
.. [6] |
| 467 |
https://languagemachines.github.io/mbt |
| 468 |
|
| 469 |
.. [7] |
| 470 |
https://github.com/LanguageMachines/frogdata |
| 471 |
|
| 472 |
.. [8] |
| 473 |
B (begin) indicates the begin of the named entity, I (inside) |
| 474 |
indicates the continuation of a named entity, and O (outside) |
| 475 |
indicates that something is not a named entity |
| 476 |
|
| 477 |
.. [9] |
| 478 |
https://github.com/proycon/pynlpl, supports both Python 2 and Python 3 |
| 479 |
|
| 480 |
.. [10] |
| 481 |
https://github.com/vanatteveldt/frogr/ |
| 482 |
|
| 483 |
.. [11] |
| 484 |
https://github.com/Machiel/gorf |
| 485 |
|
| 486 |
|
| 487 |
|