11package com .alchemyapi .test ;
22
33import com .alchemyapi .api .AlchemyAPI ;
4+ import com .alchemyapi .api .AlchemyAPI_NamedEntityParams ;
5+ import com .alchemyapi .api .AlchemyAPI_Params ;
46
57import org .xml .sax .SAXException ;
68import org .w3c .dom .Document ;
@@ -21,22 +23,25 @@ public static void main(String[] args)
2123 // Create an AlchemyAPI object.
2224 AlchemyAPI alchemyObj = AlchemyAPI .GetInstanceFromFile ("api_key.txt" );
2325
26+ AlchemyAPI_NamedEntityParams entityParams = new AlchemyAPI_NamedEntityParams ();
27+ entityParams .setOutputMode (AlchemyAPI_Params .OUTPUT_JSON );
28+
2429 // Extract a ranked list of named entities for a web URL.
25- Document doc = alchemyObj .URLGetRankedNamedEntities ("http://www.techcrunch.com/" );
26- System .out .println (getStringFromDocument ( doc ) );
30+ String doc = alchemyObj .URLGetRankedNamedEntities ("http://www.techcrunch.com/" , entityParams );
31+ System .out .println (doc );
2732
2833 // Extract a ranked list of named entities from a text string.
2934 doc = alchemyObj .TextGetRankedNamedEntities (
3035 "Hello there, my name is Bob Jones. I live in the United States of America. " +
31- "Where do you live, Fred?" );
32- System .out .println (getStringFromDocument ( doc ) );
36+ "Where do you live, Fred?" , entityParams );
37+ System .out .println (doc );
3338
3439 // Load a HTML document to analyze.
3540 String htmlDoc = getFileContents ("data/example.html" );
3641
3742 // Extract a ranked list of named entities from a HTML document.
38- doc = alchemyObj .HTMLGetRankedNamedEntities (htmlDoc , "http://www.test.com/" );
39- System .out .println (getStringFromDocument ( doc ) );
43+ doc = alchemyObj .HTMLGetRankedNamedEntities (htmlDoc , "http://www.test.com/" , entityParams );
44+ System .out .println (doc );
4045 }
4146
4247 // utility function
0 commit comments