Try calling Watson NLU that seems to support Japanese from the Java SDK

JAR download https://github.com/watson-developer-cloud/java-sdk Download from "Download the jar with dependencies here."

code

		String versionDate = "2018-03-19";
		String username = "xxx";
		String password = "xxx";
		NaturalLanguageUnderstanding service = new NaturalLanguageUnderstanding(versionDate, username, password);

		SentimentOptions sentiment = new SentimentOptions.Builder().build();
		EmotionOptions emotion = new EmotionOptions.Builder().build();
		KeywordsOptions keywords = new KeywordsOptions.Builder().build();
		EntitiesOptions entities = new EntitiesOptions.Builder().build();
		CategoriesOptions categories = new CategoriesOptions();
		SemanticRolesOptions semanticRoles = new SemanticRolesOptions.Builder().build();

		Features features = new Features.Builder() //
				.sentiment(sentiment) //
				.emotion(emotion) // "emotion: unsupported text language: ja"
				.keywords(keywords) //
				.entities(entities) //
				.categories(categories) //
				.semanticRoles(semanticRoles) //
				.build();

		String language = "ja";
		String text = "US President Trump...He criticized the company for surrendering in a trade war.";

		AnalyzeOptions analyzeOptions = new AnalyzeOptions.Builder().features(features).language(language).text(text)
				.build();

		AnalysisResults results = service.analyze(analyzeOptions).execute();

		System.err.println(results); // Print JSON

		if (results.getCategories() != null) {
			for (CategoriesResult result : results.getCategories()) {
				System.err.println(result.getLabel() + " : " + result.getScore());
			}

		}



Below are the results. (A part of the news text part is "... (omitted) ...")

{
  "language": "ja",
  "usage": {
    "features": 5,
    "text_characters": 94,
    "text_units": 1
  },
  "entities": [
    {
      "type": "Person",
      "text": "Playing cards",
      "relevance": 0.954265,
      "count": 1
    },
    {
      "type": "Organization",
      "text": "Harley-Davidson",
      "relevance": 0.860373,
      "count": 1
    },
    {
      "type": "Organization",
      "text": "European Union",
      "relevance": 0.79402,
      "count": 1
    },
    {
      "type": "Location",
      "text": "Rice",
      "relevance": 0.636659,
      "count": 1
    },
    {
      "type": "Location",
      "text": "EU",
      "relevance": 0.115173,
      "count": 1
    }
  ],
  "keywords": [
    {
      "relevance": 0.809941,
      "text": "Trade war"
    },
    {
      "relevance": 0.733196,
      "text": "Outside the United States"
    },
    {
      "relevance": 0.710815,
      "text": "Between the EU"
    },
    {
      "relevance": 0.582804,
      "text": "The company"
    },
    {
      "relevance": 0.569772,
      "text": "European Union(EU"
    },
    {
      "relevance": 0.557057,
      "text": "EU"
    },
    {
      "relevance": 0.498835,
      "text": "war"
    },
    {
      "relevance": 0.498399,
      "text": "Trade"
    },
    {
      "relevance": 0.472507,
      "text": "production"
    },
    {
      "relevance": 0.462888,
      "text": "Overseas"
    },
    {
      "relevance": 0.461109,
      "text": "European Union(EU)Retaliation tariffs by"
    },
    {
      "relevance": 0.445569,
      "text": "US President Trump"
    },
    {
      "relevance": 0.430877,
      "text": "Tariffs"
    },
    {
      "relevance": 0.418106,
      "text": "Retaliation"
    },
    {
      "relevance": 0.417108,
      "text": "while"
    },
    {
      "relevance": 0.395505,
      "text": "Rice"
    },
    {
      "relevance": 0.384407,
      "text": "European Union"
    },
    {
      "relevance": 0.370795,
      "text": "Harley-Davidson"
    },
    {
      "relevance": 0.35972,
      "text": "US President"
    },
    {
      "relevance": 0.350696,
      "text": "Playing cards"
    }
  ],
  "categories": [
    {
      "label": "/society/unrest and war",
      "score": 0.288369
    },
    {
      "label": "/law, govt and politics/government",
      "score": 0.197268
    },
    {
      "label": "/law, govt and politics",
      "score": 0.155733
    }
  ],
  "semantic_roles": [
    {
      "sentence": "US President Trump...(Abbreviation)...I criticized the company.",
      "action": {
        "text": "To do",
        "normalized": "To do",
        "verb": {
          "text": "To do"
        }
      },
      "object": {
        "text": "Production"
      }
    },
    {
      "sentence": "US President Trump...(Abbreviation)...I criticized the company.",
      "subject": {
        "text": "Harley Davidson"
      },
      "action": {
        "text": "did",
        "normalized": "did",
        "verb": {
          "text": "did"
        }
      }
    },
    {
      "sentence": "US President Trump...(Abbreviation)...I criticized the company.",
      "action": {
        "text": "did",
        "normalized": "did",
        "verb": {
          "text": "did"
        }
      },
      "object": {
        "text": "The company"
      }
    }
  ],
  "sentiment": {
    "document": {
      "label": "neutral",
      "score": 0.0
    }
  }
}

null /society/unrest and war : 0.288369 /law, govt and politics/government : 0.197268 /law, govt and politics : 0.155733

Recommended Posts

Try calling Watson NLU that seems to support Japanese from the Java SDK
Try calling IBM Watson Assistant 2018-07-10 from the Java SDK.
Try calling the CORBA service from Spring (Java)
The road from JavaScript to Java
When calling sshpass from Java with shell etc., it seems that it is necessary to have a path.
Try calling the CORBA service in Java 11+
Try calling Nim from Java via JNI
Try to access the on-premise system from SAP Cloud Platform --Java App Edition
Upsert from Java SDK to Azure Cosmos DB
Try accessing the dataset from Java using JZOS
[Java] Try to solve the Fizz Buzz problem
Select * from Java SDK to Azure Cosmos DB
Try calling synchronized methods from multiple threads in Java
[Java] I want to calculate the difference from the date
How to write Scala from the perspective of Java
[Java] How to extract the file name from the path
Changes from Java 8 to Java 11
Sum from Java_1 to 100
From Java to Ruby !!
Try switching from the RHEL environment to the Ubuntu environment Server installation
[JDBC] I tried to access the SQLite3 database from Java.
Get to the abbreviations from 5 examples of iterating Java lists
Try Spark Submit to EMR using AWS SDK for Java
Investigated how to call services with Watson SDK for Java