NLP4J [001b] Morphological analysis in Java (using kuromoji)

Index

What is kuromoji

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>

code

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);
		}
	}
}

result

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=。]

Index

Recommended Posts

NLP4J [001b] Morphological analysis in Java (using kuromoji)
Morphological analysis in Java with Kuromoji
NLP4J [002] Try parsing Japanese using Yahoo! Developer Network Japanese Parsing Analysis (V1) in Java
NLP4J [004] Try text analysis using natural language processing and parsing statistical processing in Java
Try using RocksDB in Java
Topic Analysis (LDA) in Java
NLP4J [001b] Morphological analysis in Java (using kuromoji)
Morphological analysis in Java with Kuromoji
Sorting using java comparator
All analysis using Javassist
[Java] Holiday judgment sample
Scraping practice using Java ②
Scraping practice using Java ①
Encrypt using RSA cryptography in Java
HTTPS connection using tls1.2 in Java 6
I tried using JWT in Java
Creating lexical analysis in Java 8 (Part 2)
1 Implement simple lexical analysis in Java
Creating lexical analysis in Java 8 (Part 1)
I tried using Elasticsearch API in Java
Map without using an array in java
Using JavaScript from Java in Rhino 2021 version
Read Felica using RC-S380 (PaSoRi) in Java
ChatWork4j for using the ChatWork API in Java
[Java] API creation using Jerjey (Jax-rs) in eclipse
Static code analysis with Checkstyle in Java + Gradle
Send email using Amazon SES SMTP in Java
Send push notifications using Notification Hubs in Java
Try using Sourcetrail (win version) in Java code
Try using GCP's Cloud Vision API in Java
Try using Sourcetrail (macOS version) in Java code
Match IP addresses using regular expressions in Java
Display "Hello World" in the browser using Java
Display "Hello World" in the browser using Java
Introducing NLP4J-[000] Natural Language Processing Index in Java
Try using the COTOHA API parsing in Java
Partization in Java
NLP4J [005-2] NLP4J + Twitter4J (Analysis 1)
Changes in Java 11
Pi in Java
FizzBuzz in Java
Convert JSON and YAML in Java (using Jackson and SnakeYAML)
I tried using Google Cloud Vision API in Java
How to convert A to a and a to A using AND and OR in Java
I tried using an extended for statement in Java
Try global hooking in Java using the JNativeHook library
NLP4J [006-030] 100 language processing knocks with NLP4J # 30 Reading morphological analysis results
Differences in code when using the length system in Java