Difference between revisions of "Voikkospell"

From Apertium
Jump to navigation Jump to search
 
(5 intermediate revisions by the same user not shown)
Line 2: Line 2:
 
[https://github.com/m5w/corevoikko m5w/corevoikko], a fork of [https://github.com/voikko/corevoikko corevoikko], supports apertium stream format.
 
[https://github.com/m5w/corevoikko m5w/corevoikko], a fork of [https://github.com/voikko/corevoikko corevoikko], supports apertium stream format.
   
To clone it, execute the following command:
+
To clone it, execute the following command.
   
 
<pre>
 
<pre>
Line 8: Line 8:
 
</pre>
 
</pre>
   
First, install [https://github.com/voikko/corevoikko/libvoikko libvoikko]'s dependencies. Next, execute the following commands:
+
First, install [https://github.com/voikko/corevoikko/libvoikko libvoikko]'s dependencies. Next, execute the following commands.
   
 
<pre>
 
<pre>
Line 17: Line 17:
 
</pre>
 
</pre>
   
If you do not have root privileges or would like to specify where to install libvoikko, execute the following instead: (Otherwise, you are finished with installation.)
+
If you do not have root privileges or would like to specify where to install libvoikko, execute the following instead. (Otherwise, you are finished with installation.)
   
 
<pre>cd corevoikko/libvoikko
 
<pre>cd corevoikko/libvoikko
Line 26: Line 26:
 
</pre>
 
</pre>
   
Finally, add your <code>"$PREFIX"</code> to your <code>"$PATH"</code> by appending the following lines to your <code>.profile</code>:
+
Finally, add your <code>"$PREFIX"</code> to your <code>"$PATH"</code> by appending the following lines to your <code>.profile</code>.
   
 
<pre>
 
<pre>
Line 98: Line 98:
   
 
===An HTML Example===
 
===An HTML Example===
Let's spellcheck the following webpage:
+
Let's spellcheck the following webpage.
   
 
<pre>
 
<pre>
Line 113: Line 113:
 
&lt;/html&gt;
 
&lt;/html&gt;
 
</pre>
 
</pre>
  +
  +
Running <code>apertium-deshtml</code> on it yields the following.
  +
  +
<pre>
  +
.[][<!DOCTYPE html>
  +
<html>
  +
<head>
  +
<title>]An HTML Example.[][<\/title>
  +
<\/head>
  +
<body>
  +
<p>
  +
]This is an HTML example..[][
  +
<\/p>
  +
<\/body>
  +
<\/html>
  +
]
  +
</pre>
  +
  +
Note that all the <code>&lt;</code>'s, <code>&gt;</code>'s, and <code>/</code>'s are encoded as superblanks. In fact, everything except the title and body paragraph is escaped. However, those words are not yet encoded as lexical units. Running <code>lt-proc</code> on the output yields the following, suitable for <code>voikkospell --apertium-stream</code>.
  +
  +
<pre>
  +
^./.&lt;sent&gt;$[][&lt;!DOCTYPE html&gt;
  +
&lt;html&gt;
  +
&lt;head&gt;
  +
&lt;title&gt;]^An/A&lt;det&gt;&lt;ind&gt;&lt;sg&gt;$ ^HTML/HTML&lt;n&gt;&lt;acr&gt;&lt;sp&gt;$ ^Example/Example&lt;n&gt;&lt;sg&gt;$^./.&lt;sent&gt;$[][&lt;\/title&gt;
  +
&lt;\/head&gt;
  +
&lt;body&gt;
  +
&lt;p&gt;
  +
]^This/This&lt;det&gt;&lt;dem&gt;&lt;sg&gt;/This&lt;prn&gt;&lt;tn&gt;&lt;mf&gt;&lt;sg&gt;$ ^is/be&lt;vbser&gt;&lt;pri&gt;&lt;p3&gt;&lt;sg&gt;$ ^an/a&lt;det&gt;&lt;ind&gt;&lt;sg&gt;$ ^HTML/HTML&lt;n&gt;&lt;acr&gt;&lt;sp&gt;$ ^example/example&lt;n&gt;&lt;sg&gt;$^./.&lt;sent&gt;$^./.&lt;sent&gt;$[][
  +
&lt;\/p&gt;
  +
&lt;\/body&gt;
  +
&lt;\/html&gt;
  +
</pre>
  +
  +
Running <code>voikkospell --apertium-stream</code> on this yields the following final output.
  +
  +
<pre>
  +
^*.$[][&lt;!DOCTYPE html&gt;
  +
&lt;html&gt;
  +
&lt;head&gt;
  +
&lt;title&gt;]^*An/N/Anu/En/Ane/San$ ^HTML/HTML$ ^*Example$^*.$[][&lt;\/title&gt;
  +
&lt;\/head&gt;
  +
&lt;body&gt;
  +
&lt;p&gt;
  +
]^*This$ ^*is/ies/iso/s/isä/i$ ^*an/en/ane/n/a/van$ ^HTML/HTML$ ^*example$^*.$^*.$[][
  +
&lt;\/p&gt;
  +
&lt;\/body&gt;
  +
&lt;\/html&gt;
  +
</pre>
  +
  +
voikkospell outputs correct Finnish words like <code>^HTML/HTML$</code>; it outputs incorrect words with suggestions like <code>^*An/N/Anu/En/Ane/San$</code> and those with no suggestions like <code>^*Example$</code>.
   
 
[[Category:Spellchecking]]
 
[[Category:Spellchecking]]

Latest revision as of 23:14, 17 December 2015

Installation[edit]

m5w/corevoikko, a fork of corevoikko, supports apertium stream format.

To clone it, execute the following command.

git clone https://github.com/m5w/corevoikko.git corevoikko

First, install libvoikko's dependencies. Next, execute the following commands.

cd corevoikko/libvoikko
./configure
make
sudo make install

If you do not have root privileges or would like to specify where to install libvoikko, execute the following instead. (Otherwise, you are finished with installation.)

cd corevoikko/libvoikko
PREFIX="$HOME/install/corevoikko" # e.g.
./configure --prefix="$PREFIX"
make
make install

Finally, add your "$PREFIX" to your "$PATH" by appending the following lines to your .profile.

PREFIX="$HOME/install/corevoikko" # e.g.
if [ -d "$PREFIX" ]; then
        export PATH="$PREFIX/bin:$PATH"
fi

Using voikkospell with apertium Stream Format[edit]

Invoke voikkospell with --apertium-stream. voikkospell then expects apertium-stream-formatted input instead of a list of words.

Words in apertium Stream Format[edit]

apertium stream format encodes words as lexical units. Each begins with a ^

^ . . .

and ends with a $.

^ . . . $

The word immediately follows the ^,

^word . . .$

and a / immediately follows the word. If the word is unknown, *word follows;

^word/*word$

otherwise, all the word's analyses follow, delimited by /'s.

^word/word<n><sg>/word<vblex><inf>/word<vblex><pres>$

Escaping[edit]

To use ^, $, /, <, and > as characters, one must escape them. Each escape sequence begins with a \,

\ . . .

and a character follows. voikkospell then interprets the character literally. Note that the character can be any wide character, including newlines.

To use \'s as characters, one must escape them.

Superblanks[edit]

One can also escape multiple characters not encoded in lexical units by encoding them as a superblank. Each superblank begins with a [

[ . . .

and ends with a ].

[ . . . ]

Each ^, $, /, <, and > between the [ and the ] is interpreted literally.

To use [ and ] as characters, one must escape them.

An HTML Example[edit]

Let's spellcheck the following webpage.

<!DOCTYPE html>
<html>
    <head>
        <title>An HTML Example</title>
    </head>
    <body>
        <p>
        This is an HTML example.
        </p>
    </body>
</html>

Running apertium-deshtml on it yields the following.

.[][<!DOCTYPE html>
<html>
    <head>
        <title>]An HTML Example.[][<\/title>
    <\/head>
    <body>
        <p>
        ]This is an HTML example..[][
        <\/p>
    <\/body>
<\/html>
]

Note that all the <'s, >'s, and /'s are encoded as superblanks. In fact, everything except the title and body paragraph is escaped. However, those words are not yet encoded as lexical units. Running lt-proc on the output yields the following, suitable for voikkospell --apertium-stream.

^./.<sent>$[][<!DOCTYPE html>
<html>
    <head>
        <title>]^An/A<det><ind><sg>$ ^HTML/HTML<n><acr><sp>$ ^Example/Example<n><sg>$^./.<sent>$[][<\/title>
    <\/head>
    <body>
        <p>
        ]^This/This<det><dem><sg>/This<prn><tn><mf><sg>$ ^is/be<vbser><pri><p3><sg>$ ^an/a<det><ind><sg>$ ^HTML/HTML<n><acr><sp>$ ^example/example<n><sg>$^./.<sent>$^./.<sent>$[][
        <\/p>
    <\/body>
<\/html>

Running voikkospell --apertium-stream on this yields the following final output.

^*.$[][<!DOCTYPE html>
<html>
    <head>
        <title>]^*An/N/Anu/En/Ane/San$ ^HTML/HTML$ ^*Example$^*.$[][<\/title>
    <\/head>
    <body>
        <p>
        ]^*This$ ^*is/ies/iso/s/isä/i$ ^*an/en/ane/n/a/van$ ^HTML/HTML$ ^*example$^*.$^*.$[][
        <\/p>
    <\/body>
<\/html>

voikkospell outputs correct Finnish words like ^HTML/HTML$; it outputs incorrect words with suggestions like ^*An/N/Anu/En/Ane/San$ and those with no suggestions like ^*Example$.