Beispiel #1
0
	static public void Main ()
	{
		// Create an AlchemyAPI object.
		AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();


		// Load an API key from disk.
		alchemyObj.LoadAPIKey("api_key.txt");


		// Extract concept tags for a web URL.
		string xml = alchemyObj.URLGetRankedConcepts("http://www.techcrunch.com/");
		Console.WriteLine (xml);


		// Extract concept tags for a text string.
		xml = alchemyObj.TextGetRankedConcepts("This thing has a steering wheel, tires, and an engine.  Do you know what it is?");
		Console.WriteLine (xml);


		// Load a HTML document to analyze.
		StreamReader streamReader = new StreamReader("data/example.html");
		string htmlDoc = streamReader.ReadToEnd();
		streamReader.Close();


		// Extract concept tags for a HTML document.
		xml = alchemyObj.HTMLGetRankedConcepts(htmlDoc, "http://www.test.com/");
		Console.WriteLine (xml);
	}
Beispiel #2
0
    static public void Main()
    {
        // Create an AlchemyAPI object.
        AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();


        // Load an API key from disk.
        alchemyObj.LoadAPIKey("api_key.txt");


        // Extract concept tags for a web URL.
        string xml = alchemyObj.URLGetRankedConcepts("http://www.techcrunch.com/");

        Console.WriteLine(xml);


        // Extract concept tags for a text string.
        xml = alchemyObj.TextGetRankedConcepts("This thing has a steering wheel, tires, and an engine.  Do you know what it is?");
        Console.WriteLine(xml);


        // Load a HTML document to analyze.
        StreamReader streamReader = new StreamReader("data/example.html");
        string       htmlDoc      = streamReader.ReadToEnd();

        streamReader.Close();


        // Extract concept tags for a HTML document.
        xml = alchemyObj.HTMLGetRankedConcepts(htmlDoc, "http://www.test.com/");
        Console.WriteLine(xml);
    }
Beispiel #3
0
        public DataSet LoadConceptsFromUrl(string url)
        {
            DataSet    dsConcepts = new DataSet();
            string     xml        = alchemyObj.URLGetRankedConcepts(url, cparams);
            TextReader tr         = new StringReader(xml);
            XmlReader  xr         = XmlReader.Create(tr);

            dsConcepts.ReadXml(xr);
            xr.Close();
            tr.Close();

            return(dsConcepts);
        }
Beispiel #4
0
        protected DataSet GetConcepts(string url)
        {
            DataSet dsConcepts = new DataSet();

#if TEST
            // Using previously captured dataset
            dsConcepts.ReadXml("alchemyConceptsTestResponse.xml");
#else
            if (!Cached("Concept", url, ref dsConcepts))
            {
                AlchemyAPI_ConceptParams eparams = new AlchemyAPI_ConceptParams();
                eparams.setMaxRetrieve(250);
                string     xml = alchemyObj.URLGetRankedConcepts(url, eparams);
                TextReader tr  = new StringReader(xml);
                XmlReader  xr  = XmlReader.Create(tr);
                dsConcepts.ReadXml(xr);
                xr.Close();
                tr.Close();
                Cache("Concept", url, dsConcepts);
            }
#endif
            return(dsConcepts);
        }