A Java client for Google's PerspectiveAPI
First create a new PerspectiveAPI instance:
PerspectiveAPI pAPI = PerspectiveAPI.create(key);
Then build an analysis request using the builder:
pAPI.analyze(new AnalyzeCommentRequest.Builder()
.addRequestedAttribute(AttributeType.TOXICITY, null)
.comment(new Entry.Builder()
.type(ContentType.PLAIN_TEXT)
.text(comment)
.build())
.build());
or do a simple request
pAPI.analyze(comment);
To understand the models and their functions, see https://github.com/conversationai/perspectiveapi/blob/master/2-api/models.md and https://github.com/conversationai/perspectiveapi/blob/master/2-api/methods.md
<dependency>
<groupId>com.github.origma</groupId>
<artifactId>Google-PerspectiveAPI-Java-Client</artifactId>
<version>0.0.5</version>
</dependency>
...
<repositories>
<repository>
<id>jitpack.io</id>
<url>https://jitpack.io</url>
</repository>
</repositories>