An open source Japanese morphological analysis engine developed in Java.
kuromoji | Atilika https://www.atilika.com/ja/kuromoji/
Maven
<dependency>
<groupId>org.nlp4j</groupId>
<artifactId>nlp4j-core</artifactId>
<version>1.3.0.0</version>
</dependency>
<dependency>
<groupId>org.nlp4j</groupId>
<artifactId>nlp4j-kuromoji</artifactId>
<version>1.3.0.0</version>
</dependency>
package example;
import nlp4j.Document;
import nlp4j.Keyword;
import nlp4j.impl.DefaultDocument;
import nlp4j.krmj.annotator.KuromojiAnnotator;
public class HelloKuromojiNLP1 {
public static void main(String[] args) throws Exception {
//Natural text
String text = "It is a good weather today.";
Document doc = new DefaultDocument();
//Set as attribute "text"
doc.putAttribute("text", text);
//kuromoji annotator
KuromojiAnnotator annotator = new KuromojiAnnotator();
//Specify the attribute to be processed
annotator.setProperty("target", "text");
//Morphological analysis processing
annotator.annotate(doc); // throws Exception
//Keyword output
for (Keyword kwd : doc.getKeywords()) {
System.err.println(kwd);
}
}
}
today[facet=noun, str=today]
Is[facet=Particle, str=Is]
Good[facet=adjective, str=Good]
weather[facet=noun, str=weather]
is[facet=Auxiliary verb, str=is]
。 [facet=symbol, str=。]
Recommended Posts