@@ -59,18 +59,24 @@ public static void main(String[] args) throws IOException, GeneralSecurityExcept
5959
6060 Analyze app = new Analyze (LanguageServiceClient .create ());
6161
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://" )) {
6970 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://" )) {
7376 printSyntax (System .out , app .analyzeSyntaxFile (text ));
77+ } else {
78+ printSyntax (System .out , app .analyzeSyntaxText (text ));
79+ }
7480 }
7581 }
7682
@@ -117,6 +123,9 @@ public static void printSentiment(PrintStream out, Sentiment sentiment) {
117123 out .printf ("\t Score: %.3f\n " , sentiment .getScore ());
118124 }
119125
126+ /**
127+ * Prints the Syntax for the {@code tokens}.
128+ */
120129 public static void printSyntax (PrintStream out , List <Token > tokens ) {
121130 if (tokens == null || tokens .size () == 0 ) {
122131 out .println ("No syntax found" );
@@ -170,7 +179,7 @@ public List<Entity> analyzeEntitiesText(String text) throws IOException {
170179 }
171180
172181 /**
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}.
174183 */
175184 public List <Entity > analyzeEntitiesFile (String path ) throws IOException {
176185 Document doc = Document .newBuilder ()
@@ -193,7 +202,7 @@ public Sentiment analyzeSentimentText(String text) throws IOException {
193202 }
194203
195204 /**
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}.
197206 */
198207 public Sentiment analyzeSentimentFile (String path ) throws IOException {
199208 Document doc = Document .newBuilder ()
@@ -216,7 +225,7 @@ public List<Token> analyzeSyntaxText(String text) throws IOException {
216225 }
217226
218227 /**
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}.
220229 */
221230 public List <Token > analyzeSyntaxFile (String path ) throws IOException {
222231 Document doc = Document .newBuilder ()
0 commit comments