Java Reference
In-Depth Information
Datum: {small 1.33 3.50 5.43] Predicted Category: medium
Datum: {small 1.18 1.73 3.14] Predicted Category: small
...
Datum: {large 6.01 9.35 16.64] Predicted Category: large
Datum: {large 6.76 9.66 15.44] Predicted Category: large
To test an individual entry, we can use the makeDatumFromStrings method to create
a Datum instance. In the next code sequence, a one-dimensional array of strings is cre-
ated where each element represents data values for a box. The first entry, the category, is
left null. The Datum instance is then used as the argument of the classOf method to
predict its category:
String sample[] = {"", "6.90", "9.8", "15.69"};
Datum<String, String> datum =
cdc.makeDatumFromStrings(sample);
System.out.println("Category: " +
classifier.classOf(datum));
The output for this sequence is shown here, which correctly classifies the box:
Category: large
Using the Stanford pipeline to perform sentiment analysis
In this section, we will illustrate how the Stanford API can be used to perform sentiment
analysis. We will use the StanfordCoreNLP pipeline to perform this analysis on dif-
ferent texts.
We will use three different texts as defined here. The review string is a movie review
from Rotten Tomatoes ( http://www.rottentomatoes.com/m/forrest_gump/ ) about the movie
Forrest Gump:
String review = "An overly sentimental film with a somewhat
"
+ "problematic message, but its sweetness and charm "
+ "are occasionally enough to approximate true depth "
+ "and grace. ";
String sam = "Sam was an odd sort of fellow. Not prone "
+ "to angry and not prone to merriment. Overall, "
Search WWH ::




Custom Search