Skip to content

Commit 198a3b1

Browse files
author
Ben McLean
committed
Added documentation to PerspectiveAPI
1 parent 6704e06 commit 198a3b1

3 files changed

Lines changed: 34 additions & 3 deletions

File tree

src/au/com/origma/perspectiveapi/v1alpha1/PerspectiveAPI.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,13 +9,39 @@
99
import au.com.origma.perspectiveapi.v1alpha1.models.AnalyzeCommentRequest;
1010
import au.com.origma.perspectiveapi.v1alpha1.models.AnalyzeCommentResponse;
1111

12+
/**
13+
* Interact with Google's PerspectiveAPI to analyze comments and content.<br>
14+
* See the API documentation
15+
* <a href="https://github.com/conversationai/perspectiveapi/blob/master/2-api/README.md">here</a>
16+
*
17+
* @author Ben McLean &lt;ben@origma.com.au&gt;
18+
*/
1219
public interface PerspectiveAPI {
1320

21+
/**
22+
* The endpoint to which analysis requests are sent
23+
*/
1424
public static final String ANALYZE_ENDPOINT = "https://commentanalyzer.googleapis.com/v1alpha1/comments:analyze";
1525

26+
/**
27+
* Analyze a comment
28+
* @param request The request
29+
* @return The analysis of the request
30+
*/
1631
public AnalyzeCommentResponse analyze(AnalyzeCommentRequest request);
32+
33+
/**
34+
* Analyze a comment with the default settings
35+
* @param comment The comment to analyze
36+
* @return The analysis of the request
37+
*/
1738
public AnalyzeCommentResponse analyze(String comment);
1839

40+
/**
41+
* Instantiate the default implementation of the PerspectiveAPI
42+
* @param apiKey The Google API key
43+
* @return The default implementation of the PerspectiveAPI
44+
*/
1945
public static PerspectiveAPI create(String apiKey) {
2046
return new UnirestPerspectiveAPI(apiKey);
2147
}

src/au/com/origma/perspectiveapi/v1alpha1/UnirestPerspectiveAPI.java

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,11 @@
1414
import kong.unirest.HttpResponse;
1515
import kong.unirest.Unirest;
1616

17+
/**
18+
* The default implementation of the PerspectiveAPI client, made using the Unirest library
19+
*
20+
* @author Ben McLean &lt;ben@origma.com.au&gt;
21+
*/
1722
public class UnirestPerspectiveAPI implements PerspectiveAPI {
1823

1924
String apiKey;

src/au/com/origma/perspectiveapi/v1alpha1/models/AnalyzeCommentRequest.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@
1313

1414
/**
1515
* A request to analyze a string of text for attributes
16-
* @author Ben McLean &gt; ben@origma.com.au &lt;
16+
* @author Ben McLean &lt;ben@origma.com.au&gt;
1717
*/
1818
public class AnalyzeCommentRequest {
1919

@@ -93,7 +93,7 @@ public Double getSuggestCommentScore() {
9393
/**
9494
* Builds an AnalyzeCommentRequest
9595
*
96-
* @author Ben McLean &gt; ben@origma.com.au &lt;
96+
* @author Ben McLean &lt;ben@origma.com.au&gt;
9797
*
9898
*/
9999
public static class Builder {
@@ -213,7 +213,7 @@ public Builder suggestCommentScore(Double suggestCommentScore) {
213213

214214
/**
215215
* Build and create a new instance of AnalyzeCommentRequest
216-
* @return
216+
* @return The builder
217217
*/
218218
public AnalyzeCommentRequest build() {
219219
return new AnalyzeCommentRequest(this);

0 commit comments

Comments
 (0)