-
Notifications
You must be signed in to change notification settings - Fork 0
/
java.html
72 lines (52 loc) · 4.45 KB
/
java.html
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN"
"http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml" lang="en" xml:lang="en">
<head>
<meta http-equiv="content-type" content="text/html; charset=utf-8" />
<title>Voikko – Using in Java applications</title>
<link rel="stylesheet" type="text/css" href="stylesheets/styles.css" />
</head>
<body>
<p class="linkback"><a href=".">← Back to Index</a></p>
<h1>Voikko<br /><small>Using in Java applications</small></h1>
<p>There are two different solutions available for using Voikko ja Java applications.</p>
<h2>Option 1: Raudikko — partial reimplementation of libvoikko in pure Java</h2>
<p><a href="https://github.com/EvidentSolutions/raudikko">Raudikko</a> is a partial reimplementation of libvoikko written in pure Java. It does not have all the features
of libvoikko but if you only need to do morphological analysis or search indexing for Finnish this is definitely the easiest and recommended solution. Raudikko uses Voikko's morphological dictionaries (version 5, Finnish VFST) so it will give you exactly the same results as original libvoikko but without the significant additional work needed to install and use native C++ libraries.<p>
<p>There is also an <a href="https://github.com/EvidentSolutions/elasticsearch-analysis-raudikko">Elasticsearch plugin providing Finnish analysis</a> built on top of Raudikko.</p>
<h2>Option 2: Java wrapper for the native libvoikko library</h2>
<p>Libvoikko comes with Java wrapper that uses native libvoikko over JNA interface. This option gives you all the features of libvoikko including spelling and grammar checker but you will have to install the native libraries. Use this only if Raudikko is not enough for your purposes.</p>
<p>The Java interface for Libvoikko is available on the Maven Central Repository:</p>
<pre>
<dependency>
<groupId><strong>org.puimula.voikko</strong></groupId>
<artifactId><strong>libvoikko</strong></artifactId>
<version><strong>4.1.1</strong></version>
</dependency>
</pre>
<p>In addition to this artifact you need to have the native libvoikko library and at least one dictionary installed in order to use Voikko in your application.</p>
<h3>Installing the native library</h3>
<p style="font-size:85%; text-align:right">... or how to resolve <kbd>Could not load the native component of libvoikko.</kbd></p>
<p>You need to have the native libvoikko library available in a place where the OS specific library loading mechanism (<kbd>System.loadLibrary</kbd> in fact) will find it.
Most modern Linux distributions contain the <kbd>libvoikko</kbd> package; installing that should be sufficient.
On Windows you should place <kbd>libvoikko-1.dll</kbd> in one of the directories within the PATH environment variable.
<a href="https://www.puimula.org/htp/testing/voikko-sdk/win-crossbuild/">Here you can download the library for Windows</a> (choose 32 or 64 bit version according to
your Java VM).</p>
<p>Versions of the Java interface and the native library do not need to be exactly the same. The requirements are listed in the following table:</p>
<table class="paketit">
<tr><th>Java interface (Maven artifact) version</th><th>Required native library version</th></tr>
<tr><td>4.1.1</td><td>3.8 or later</td></tr>
<tr><td>4.0.1</td><td>3.8 or later</td></tr>
<tr><td>3.6.1</td><td>3.1 or later</td></tr>
</table>
<h3>Installing suitable dictionary files</h3>
<p style="font-size:85%; text-align:right">... or how to resolve <kbd>org.puimula.libvoikko.VoikkoException: Specified dictionary variant was not found</kbd></p>
<p>You need to have a dictionary installed that is compatible with your version of libvoikko and matches the language (and language variant) you specified as
a parameter in the constructor for Voikko object. <a href="https://www.puimula.org/htp/testing/voikko-snapshot-v5/">Here you can download various dictionary packages
for Finnish</a>. The dictionary packages need to be unzipped but the directory structure within the packages must be preserved.</p>
<p>On Linux you can unpack the dictionaries under <kbd>/etc/voikko</kbd> or <kbd>$HOME/.voikko</kbd>. On Windows these default locations must be set through
the system registry. Another, more portable option is to choose an application specific installation directory for the dictionaries and use the two parameter
constructor of Voikko to specify that directory.</p>
<div style="clear:both;" />
</body>
</html>