Since we set it up through trial and error, we have not confirmed the reproduction of this procedure.
The Windows version distributed at the head family is a 32bit version and it seems that it is not suitable for use from 64bit Java, so we introduced the 64bit version distributed as a stray build
https://github.com/ikegami-yukino/mecab/releases/tag/v0.996
Installation directory C: \ Program Files \ MeCab Character encoding UTF-8 Introduced by specifying
Although the characters are garbled, it started to work for the time being.
>mecab
It's nice weather today.
Today is a good day,荳 € 闊 ャ,*,*,*,*,*
V locust plague, locust plague, gimlet, locust, locust*,*,*,*
險 伜 捷,荳 € 闊 ャ,*,*,*,*,*
C Locust plague, locust plague, gimlet, locust, locust*,*,*,*
險 伜 捷,荳 € 闊 ャ,*,*,*,*,*
Locust plague, locust plague, locust plague, locust plague, locust plague*,*,*,*
暪 伜 捷,荳 € 闊 ャ,*,*,*,*,*
B Locust plague, locust plague, gimlet, locust, locust*,*,*,*
EOS
^Z
"C:\Program Files\MeCab\bin\libmecab.dll" To "C:\Windows\System32\libmecab.dll" I copied it to.
https://code.google.com/archive/p/cmecab-java/downloads
I downloaded cmecab-java-2.0.1-src.zip.
Extract cmecab-java-2.0.1-src.zip and copy it to your Eclipse workspace. When I ant run build.xml, cmecab-2.0.jar is output under bin. (Since the bin directory is not displayed in Package Explorer of Eclipse, I checked it in Explorer of Windows.)
It looked like this in Eclipse.
Create a Java project and set cmecab-2.0.jar and bridj-0.6.1 in the classpath
Create the following sample code (Although it is almost the same as the head family, the sample code was not displayed well in the head family, so I made a clean copy.)
// https://code.google.com/archive/p/cmecab-java/wikis/HowToUse.wiki
import net.moraleboost.mecab.Lattice;
import net.moraleboost.mecab.Node;
import net.moraleboost.mecab.impl.StandardTagger;
public class HelloMecabMain {
public static void main(String[] args) throws Exception {
//Build Tagger.
//In the argument, createTagger of MeCab()Give the argument to give to the function.
StandardTagger tagger = new StandardTagger("");
//Get version string
System.out.println("MeCab version " + tagger.version());
//Build Lattice (an object that stores runtime information required for morphological analysis)
Lattice lattice = tagger.createLattice();
//Set the analysis target character string
String text = "It is a good weather today.";
lattice.setSentence(text);
//tagger.parse()Is called to morphologically analyze the character string.
tagger.parse(lattice);
//Output morphological analysis results
System.out.println(lattice.toString());
//Output surface shape and features while tracing morphemes one by one
Node node = lattice.bosNode();
while (node != null) {
String surface = node.surface();
String feature = node.feature();
System.out.println(surface + "\t" + feature);
node = node.next();
}
//lattice,Destroy tagger
lattice.destroy();
tagger.destroy();
}
}
MeCab version 0.996
Noun today,Adverbs possible,*,*,*,*,today,today,Kyo
Is a particle,Particle,*,*,*,*,Is,C,Wow
Good adjective,Independence,*,*,Adjective, good,Uninflected word,Good,good,good
Weather noun,General,*,*,*,*,weather,weather,weather
Auxiliary verb,*,*,*,Special Death,Uninflected word,is,death,death
.. symbol,Kuten,*,*,*,*,。,。,。
EOS
BOS/EOS,*,*,*,*,*,*,*,*
Noun today,Adverbs possible,*,*,*,*,today,today,Kyo
Is a particle,Particle,*,*,*,*,Is,C,Wow
Good adjective,Independence,*,*,Adjective, good,Uninflected word,Good,good,good
Weather noun,General,*,*,*,*,weather,weather,weather
Auxiliary verb,*,*,*,Special Death,Uninflected word,is,death,death
.. symbol,Kuten,*,*,*,*,。,。,。
BOS/EOS,*,*,*,*,*,*,*,*
It is difficult to build an environment related to Mecab. I thought it would be nice if there was an OS-independent execution environment. I think that Mecab is not so troublesome for research purposes or to run alone, but there are problems in using it for full-scale text analysis and as a business application in the presence of various execution environments. I wondered.
I had a hard time binding MeCab and eclipse-Sakaiaka's blog http://sakaiakas.hatenablog.com/entry/2018/02/20/231719
Try using MeCab with Python (Windows 10 64bit) --Qiita https://qiita.com/wanko5296/items/eeb7865ee71a7b9f1a3a
Recommended Posts