@@ -35,33 +35,52 @@ three values `entities`, `sentiment`, or `syntax`.
3535Basic usage:
3636
3737```
38- function run_nl {
39- local MAIN_CLASS=com.google.cloud.language.samples.Analyze
40- local JAR_FILE=target/language-entities-1.0-jar-with-dependencies.jar
41- java -cp ${JAR_FILE} ${MAIN_CLASS} $1 "$2"
38+ #######################################
39+ # Performs a language operation on the given text or GCS object.
40+ # Globals:
41+ # None
42+ # Arguments:
43+ # $1 The operation to perform, either entities, sentiment, or syntax.
44+ # $2 The text or GCS object to operate on.
45+ # Returns:
46+ # None
47+ #######################################
48+ function run_nl() {
49+ local main_class=com.google.cloud.language.samples.Analyze
50+ local jar_file=target/language-entities-1.0-jar-with-dependencies.jar
51+ java -cp ${jar_file} ${main_class} $1 "$2"
4252}
43- run_nl entities "The quick fox jumped over the lazy dog."
44- run_nl sentiment "The quick fox jumped over the lazy dog."
45- run_nl syntax "The quick fox jumped over the lazy dog."
53+ run_nl entities "The quick brown fox jumped over the lazy dog."
54+ run_nl sentiment "The quick brown fox jumped over the lazy dog."
55+ run_nl syntax "The quick brown fox jumped over the lazy dog."
4656```
4757
4858Additional examples:
4959```
50- function run_nl_all {
51- local MAIN_CLASS=com.google.cloud.language.samples.Analyze
52- local JAR_FILE=target/language-entities-1.0-jar-with-dependencies.jar
53- local QUOTE="Larry Page, Google's co-founder, once described the 'perfect search
60+ #######################################
61+ # Exercises the sample code on various example text and GCS objects.
62+ # Globals:
63+ # None
64+ # Arguments:
65+ # None
66+ # Returns:
67+ # None
68+ #######################################
69+ function run_nl_all() {
70+ local main_class=com.google.cloud.language.samples.Analyze
71+ local jar_file=target/language-entities-1.0-jar-with-dependencies.jar
72+ local quote="Larry Page, Google's co-founder, once described the 'perfect search
5473 engine' as something that 'understands exactly what you mean and gives you
5574 back exactly what you want.' Since he spoke those words Google has grown to
5675 offer products beyond search, but the spirit of what he said remains."
57- local GS_PATH ="gs://bucket/file"
58-
59- java -cp ${JAR_FILE } ${MAIN_CLASS } entities "${QUOTE }"
60- java -cp ${JAR_FILE } ${MAIN_CLASS } entities "${GS_PATH }"
61- java -cp ${JAR_FILE } ${MAIN_CLASS } sentiment "${QUOTE }"
62- java -cp ${JAR_FILE } ${MAIN_CLASS } sentiment "${GS_PATH }"
63- java -cp ${JAR_FILE } ${MAIN_CLASS } syntax "${QUOTE }"
64- java -cp ${JAR_FILE } ${MAIN_CLASS } syntax "${GS_PATH }"
76+ local gs_path ="gs://bucket/file"
77+
78+ java -cp ${jar_file } ${main_class } entities "${quote }"
79+ java -cp ${jar_file } ${main_class } entities "${gs_path }"
80+ java -cp ${jar_file } ${main_class } sentiment "${quote }"
81+ java -cp ${jar_file } ${main_class } sentiment "${gs_path }"
82+ java -cp ${jar_file } ${main_class } syntax "${quote }"
83+ java -cp ${jar_file } ${main_class } syntax "${gs_path }"
6584}
6685
6786run_nl_all
0 commit comments