NLP4J [001a] Morphological analysis in Java (using Yahoo! Developer Network Japanese morphological analysis)

Index

What is Yahoo! Developer Network Japanese Morphological Analysis?

Japanese morphological analysis API provided by Yahoo! Japan.

Text analysis: Japanese morphological analysis-Yahoo! Developer Network https://developer.yahoo.co.jp/webapi/jlp/ma/v1/parse.html

Maven POM

<dependency>
	<groupId>org.nlp4j</groupId>
	<artifactId>nlp4j-core</artifactId>
	<version>1.3.0.0</version>
</dependency>
<dependency>
	<groupId>org.nlp4j</groupId>
	<artifactId>nlp4j-yahoojp</artifactId>
	<version>1.3.0.0</version>
</dependency>

Preparing APP ID

If you have already obtained an APP ID on the Yahoo! Developer Network (https://developer.yahoo.co.jp/), set it in the JVM environment variable (yhoo_jp.appid) as shown below and execute it.

Even if you have not acquired it, if you want to move it for the time being, it will work for the time being even if you do not have it. Please obtain an APP ID as soon as possible.

-Dyhoo_jp.appid=YOUR_CODE

code

package example;
import java.util.ArrayList;
import nlp4j.Keyword;
import nlp4j.yhoo_jp.YJpMaService;

public class HelloYahooNLP1 {

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

		// Yahoo!JP annotator
		YJpMaAnnotator annotator = new YJpMaAnnotator();
		//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

The output result is as follows. I was able to get the result of morphological analysis with a short code.

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=Special, str=。]

Project URL

https://www.nlp4j.org/ NLP4J_N_128.png


Index

Recommended Posts

NLP4J [001a] Morphological analysis in Java (using Yahoo! Developer Network Japanese morphological analysis)
NLP4J [002] Try parsing Japanese using Yahoo! Developer Network Japanese Parsing Analysis (V1) in Java
NLP4J [001b] Morphological analysis in Java (using kuromoji)
Morphological analysis in Java with Kuromoji
[Java] Spam judgment using morphological analysis "lucene-gosen"
NLP4J [004] Try text analysis using natural language processing and parsing statistical processing in Java
NLP4J [003] Try text analysis using natural language processing and part-speech statistical processing in Java
How to convert A to a and a to A using AND and OR in Java
Translate using Microsoft Translator Text API in Java (Japanese → English)
Try using RocksDB in Java
Topic Analysis (LDA) in Java
Use Japanese morphological analysis "kuromoji"
Find a subset in Java
Make a rhombus using Java
Automatically deploy a Web application developed in Java using Jenkins [Preparation]
[Java] Returns a Japanese name file in filename of HTTP header
3 Implement a simple interpreter in Java
I created a PDF in Java.
Encrypt using RSA cryptography in Java
Upload a file using Java HttpURLConnection
Create a Java project using Eclipse
A simple sample callback in Java
HTTPS connection using tls1.2 in Java 6
I tried using JWT in Java
Creating lexical analysis in Java 8 (Part 2)
Get stuck in a Java primer
1 Implement simple lexical analysis in Java
Using a local network on iOS 14
Creating lexical analysis in Java 8 (Part 1)
Creating a project (and GitHub repository) using Java and Gradle in IntelliJ IDEA
Automatically deploy a web application developed in Java using Jenkins [Spring Boot application]
I tried to make a talk application in Java using AI "A3RT"