@@ -59,18 +59,24 @@ public static void main(String[] args) throws IOException, GeneralSecurityExcept |
59 | 59 |
|
60 | 60 | Analyze app = new Analyze(LanguageServiceClient.create()); |
61 | 61 |
|
62 | | - if (command.equals("entities-text")) { |
63 | | - printEntities(System.out, app.analyzeEntitiesText(text)); |
64 | | - } else if (command.equals("entities-file")) { |
65 | | - printEntities(System.out, app.analyzeEntitiesFile(text)); |
66 | | - } else if (command.equals("sentiment-text")) { |
67 | | - printSentiment(System.out, app.analyzeSentimentText(text)); |
68 | | - } else if (command.equals("sentiment-file")) { |
| 62 | + if (command.equals("entities")) { |
| 63 | + if (text.startsWith("gs://")) { |
| 64 | + printEntities(System.out, app.analyzeEntitiesFile(text)); |
| 65 | + } else { |
| 66 | + printEntities(System.out, app.analyzeEntitiesText(text)); |
| 67 | + } |
| 68 | + } else if (command.equals("sentiment")) { |
| 69 | + if (text.startsWith("gs://")) { |
69 | 70 | printSentiment(System.out, app.analyzeSentimentFile(text)); |
70 | | - } else if (command.equals("syntax-text")) { |
71 | | - printSyntax(System.out, app.analyzeSyntaxText(text)); |
72 | | - } else if (command.equals("syntax-file")) { |
| 71 | + } else { |
| 72 | + printSentiment(System.out, app.analyzeSentimentText(text)); |
| 73 | + } |
| 74 | + } else if (command.equals("syntax")) { |
| 75 | + if (text.startsWith("gs://")) { |
73 | 76 | printSyntax(System.out, app.analyzeSyntaxFile(text)); |
| 77 | + } else { |
| 78 | + printSyntax(System.out, app.analyzeSyntaxText(text)); |
| 79 | + } |
74 | 80 | } |
75 | 81 | } |
76 | 82 |
|
@@ -117,6 +123,9 @@ public static void printSentiment(PrintStream out, Sentiment sentiment) { |
117 | 123 | out.printf("\tScore: %.3f\n", sentiment.getScore()); |
118 | 124 | } |
119 | 125 |
|
| 126 | + /** |
| 127 | + * Prints the Syntax for the {@code tokens}. |
| 128 | + */ |
120 | 129 | public static void printSyntax(PrintStream out, List<Token> tokens) { |
121 | 130 | if (tokens == null || tokens.size() == 0) { |
122 | 131 | out.println("No syntax found"); |
@@ -170,7 +179,7 @@ public List<Entity> analyzeEntitiesText(String text) throws IOException { |
170 | 179 | } |
171 | 180 |
|
172 | 181 | /** |
173 | | - * Gets {@link Entity}s from the string representing the GCS {@code path}. |
| 182 | + * Gets {@link Entity}s from the contents of the object at the given GCS {@code path}. |
174 | 183 | */ |
175 | 184 | public List<Entity> analyzeEntitiesFile(String path) throws IOException { |
176 | 185 | Document doc = Document.newBuilder() |
@@ -193,7 +202,7 @@ public Sentiment analyzeSentimentText(String text) throws IOException { |
193 | 202 | } |
194 | 203 |
|
195 | 204 | /** |
196 | | - * Gets {@link Sentiment} from the string representing the GCS {@code path}. |
| 205 | + * Gets {@link Sentiment} from the contents of the object at the given GCS {@code path}. |
197 | 206 | */ |
198 | 207 | public Sentiment analyzeSentimentFile(String path) throws IOException { |
199 | 208 | Document doc = Document.newBuilder() |
@@ -216,7 +225,7 @@ public List<Token> analyzeSyntaxText(String text) throws IOException { |
216 | 225 | } |
217 | 226 |
|
218 | 227 | /** |
219 | | - * Gets {@link Token}s from the string representing the GCS {@code path}. |
| 228 | + * Gets {@link Token}s from the contents of the object at the given GCS {@code path}. |
220 | 229 | */ |
221 | 230 | public List<Token> analyzeSyntaxFile(String path) throws IOException { |
222 | 231 | Document doc = Document.newBuilder() |
|