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");


		// Detect the language for a web URL.
		string xml = alchemyObj.URLGetLanguage("http://news.google.de/");
		Console.WriteLine (xml);


		// Detect the language for a text string (requires at least 15 characters).
		xml = alchemyObj.TextGetLanguage("Hello there, my name is Bob Jones.  I live in the United States of America.  Where do you live, Fred?");
		Console.WriteLine (xml);


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


		// Detect the language for a HTML document.
		xml = alchemyObj.HTMLGetLanguage(htmlDoc, "http://www.test.com/");
		Console.WriteLine (xml);
	}
	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");


		// Categorize a web URL by topic.
		string xml = alchemyObj.URLGetCategory("http://www.techcrunch.com/");
		Console.WriteLine (xml);


		// Categorize some text.
		xml = alchemyObj.TextGetCategory("Latest on the War in Iraq.");
		Console.WriteLine (xml);


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


		// Categorize a HTML document by topic.
		xml = alchemyObj.HTMLGetCategory(htmlDoc, "http://www.test.com/");
		Console.WriteLine (xml);
	}
	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);
	}
    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 a ranked list of named entities from a web URL.
        string xml = alchemyObj.URLGetRankedNamedEntities("http://www.techcrunch.com/");

        Console.WriteLine(xml);


        // Extract a ranked list of named entities from a text string.
        xml = alchemyObj.TextGetRankedNamedEntities("Hello there, my name is Bob Jones.  I live in the United States of America.  Where do you live, Fred?");
        Console.WriteLine(xml);


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

        streamReader.Close();


        // Extract a ranked list of named entities from a HTML document.
        xml = alchemyObj.HTMLGetRankedNamedEntities(htmlDoc, "http://www.test.com/");
        Console.WriteLine(xml);
    }
	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 first link from an URL.
		string xml = alchemyObj.URLGetConstraintQuery("http://microformats.org/wiki/hcard", "1st link");
		Console.WriteLine (xml);


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


		// Extract first link from a HTML.
		xml = alchemyObj.HTMLGetConstraintQuery(htmlDoc, "http://www.test.com/", "1st link");;
		Console.WriteLine (xml);
	}
    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 first link from an URL.
        string xml = alchemyObj.URLGetConstraintQuery("http://microformats.org/wiki/hcard", "1st link");

        Console.WriteLine(xml);


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

        streamReader.Close();


        // Extract first link from a HTML.
        xml = alchemyObj.HTMLGetConstraintQuery(htmlDoc, "http://www.test.com/", "1st link");;
        Console.WriteLine(xml);
    }
    static public void Main()
    {
        // Create an AlchemyAPI object.
        AlchemyAPI.AlchemyAPI    alchemyObj    = new AlchemyAPI.AlchemyAPI();
        AlchemyAPI_KeywordParams keywordParams = new AlchemyAPI_KeywordParams();
        AlchemyAPI_EntityParams  entityParams  = new AlchemyAPI_EntityParams();

        // Load an API key from disk.
        alchemyObj.LoadAPIKey("api_key.txt");
        keywordParams.setMaxRetrieve(1);
        keywordParams.setShowSourceText(true);
        keywordParams.setSourceText(AlchemyAPI_KeywordParams.SourceTextMode.RAW);
        keywordParams.setSentiment(true);
        // Extract a ranked list of named entities from a web URL with parameters.
        string xml = alchemyObj.URLGetRankedKeywords("http://www.techcrunch.com/", keywordParams);

        Console.WriteLine(xml);

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

        streamReader.Close();


        entityParams.setMaxRetrieve(3);
        entityParams.setDisambiguate(true);
        entityParams.setOutputMode(AlchemyAPI_BaseParams.OutputMode.RDF);
        entityParams.setSentiment(true);
        // Extract a ranked list of named entities from a HTML document with parameters.
        xml = alchemyObj.HTMLGetRankedNamedEntities(htmlDoc, "http://www.test.com/", entityParams);
        Console.WriteLine(xml);
    }
    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");


        // Categorize a web URL by topic.
        string xml = alchemyObj.URLGetCategory("http://www.techcrunch.com/");

        Console.WriteLine(xml);


        // Categorize some text.
        xml = alchemyObj.TextGetCategory("Latest on the War in Iraq.");
        Console.WriteLine(xml);


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

        streamReader.Close();


        // Categorize a HTML document by topic.
        xml = alchemyObj.HTMLGetCategory(htmlDoc, "http://www.test.com/");
        Console.WriteLine(xml);
    }
    public static void Main()
    {
        // Create an AlchemyAPI object.
        AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();
        AlchemyAPI_KeywordParams keywordParams = new AlchemyAPI_KeywordParams();
        AlchemyAPI_EntityParams entityParams = new AlchemyAPI_EntityParams();

        // Load an API key from disk.
        alchemyObj.LoadAPIKey("api_key.txt");
        keywordParams.setMaxRetrieve(1);
        keywordParams.setShowSourceText(true);
        keywordParams.setSourceText(AlchemyAPI_KeywordParams.SourceTextMode.RAW);
        keywordParams.setSentiment(true);
        // Extract a ranked list of named entities from a web URL with parameters.
        string xml = alchemyObj.URLGetRankedKeywords("http://www.techcrunch.com/", keywordParams);
        Console.WriteLine (xml);

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

        entityParams.setMaxRetrieve(3);
        entityParams.setDisambiguate(true);
        entityParams.setOutputMode(AlchemyAPI_BaseParams.OutputMode.RDF);
        entityParams.setSentiment(true);
        // Extract a ranked list of named entities from a HTML document with parameters.
        xml = alchemyObj.HTMLGetRankedNamedEntities(htmlDoc, "http://www.test.com/", entityParams);
        Console.WriteLine (xml);
    }
Exemple #10
0
        private void bttnSearch_Click(object sender, EventArgs e)
        {
            TwitterService twitterService = new TwitterService();

            AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();
            alchemyObj.LoadAPIKey("api_key.txt");
            twitterService.AuthenticateWith(consumerKey, consumerSecret, accessToken, accessTokenSecret);
            //IEnumerable<TwitterStatus> tweets = twitterService.ListTweetsOnHomeTimeline(new ListTweetsOnHomeTimelineOptions());
            var tweets_search = twitterService.Search(new SearchOptions {
                Q = "zardari", Count = 10
            });

            if (tweets_search != null)
            {
                foreach (var tweet in tweets_search.Statuses)
                {
                    //System.Diagnostics.Debug.WriteLine("{0} says '{1}", tweet.User.ScreenName, tweet.Text);

                    string xml = alchemyObj.TextGetTextSentiment("");
                }
            }
            else
            {
                System.Diagnostics.Debug.WriteLine("FAIL");
            }
        }
Exemple #11
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);
    }
Exemple #12
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");


        // Detect the language for a web URL.
        string xml = alchemyObj.URLGetLanguage("http://news.google.de/");

        Console.WriteLine(xml);


        // Detect the language for a text string (requires at least 15 characters).
        xml = alchemyObj.TextGetLanguage("Hello there, my name is Bob Jones.  I live in the United States of America.  Where do you live, Fred?");
        Console.WriteLine(xml);


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

        streamReader.Close();


        // Detect the language for a HTML document.
        xml = alchemyObj.HTMLGetLanguage(htmlDoc, "http://www.test.com/");
        Console.WriteLine(xml);
    }
Exemple #13
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 topic keywords for a web URL.
		string xml = alchemyObj.URLGetRankedKeywords("http://www.techcrunch.com/");
		Console.WriteLine (xml);


		// Extract topic keywords for a text string.
		xml = alchemyObj.TextGetRankedKeywords("Hello there, my name is Bob Jones.  I live in the United States of America.  Where do you live, Fred?");
		Console.WriteLine (xml);


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


		// Extract topic keywords for a HTML document.
		xml = alchemyObj.HTMLGetRankedKeywords(htmlDoc, "http://www.test.com/");
		Console.WriteLine (xml);
	}
Exemple #14
0
    static public void Main()
    {
        // Create an AlchemyAPI object.
        AlchemyAPI.AlchemyAPI    alchemyObj    = new AlchemyAPI.AlchemyAPI();
        AlchemyAPI_KeywordParams alchemyParams = new AlchemyAPI_KeywordParams();

        alchemyParams.setOutputMode(AlchemyAPI_BaseParams.OutputMode.JSON);


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


        // Extract topic keywords for a web URL.
        string response = alchemyObj.URLGetRankedKeywords("http://www.techcrunch.com/", alchemyParams);

        Console.WriteLine(response);


        // Extract topic keywords for a text string.
        response = alchemyObj.TextGetRankedKeywords("Hello there, my name is Bob Jones.  I live in the United States of America.  Where do you live, Fred?", alchemyParams);
        Console.WriteLine(response);


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

        streamReader.Close();


        // Extract topic keywords for a HTML document.
        response = alchemyObj.HTMLGetRankedKeywords(htmlDoc, "http://www.test.com/", alchemyParams);
        Console.WriteLine(response);
    }
    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 RSS / ATOM feed links from a web URL.
        string xml = alchemyObj.URLGetFeedLinks("http://www.techcrunch.com/");

        Console.WriteLine(xml);


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

        streamReader.Close();


        // Extract RSS / ATOM feed links from a HTML document.
        xml = alchemyObj.HTMLGetFeedLinks(htmlDoc, "http://www.test.com/");
        Console.WriteLine(xml);
    }
	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 RSS / ATOM feed links from a web URL.
		string xml = alchemyObj.URLGetFeedLinks("http://www.techcrunch.com/");
		Console.WriteLine (xml);


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


		// Extract RSS / ATOM feed links from a HTML document.
		xml = alchemyObj.HTMLGetFeedLinks(htmlDoc, "http://www.test.com/");
		Console.WriteLine (xml);
	}
Exemple #17
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");

		AlchemyAPI_CombinedDataParams prms = new AlchemyAPI_CombinedDataParams();
		prms.Extractions = CombinedExtract.Title | CombinedExtract.Author | CombinedExtract.Entity | CombinedExtract.Concept;

		string xml = alchemyObj.URLGetCombinedData("http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html", prms);
		Console.WriteLine(xml);
	}
        public void Initialize()
        {
            alchemyObj = new AlchemyAPI.AlchemyAPI();
            alchemyObj.LoadAPIKey("alchemyapikey.txt");

            eparams = new AlchemyAPI_EntityParams();
            eparams.setMaxRetrieve(250);

            kparams = new AlchemyAPI_KeywordParams();
            kparams.setMaxRetrieve(250);

            cparams = new AlchemyAPI_ConceptParams();
            cparams.setMaxRetrieve(250);
        }
Exemple #19
0
        public void Initialize()
        {
            alchemyObj = new AlchemyAPI.AlchemyAPI();
            alchemyObj.LoadAPIKey("alchemyapikey.txt");

            eparams = new AlchemyAPI_EntityParams();
            eparams.setMaxRetrieve(250);

            kparams = new AlchemyAPI_KeywordParams();
            kparams.setMaxRetrieve(250);

            cparams = new AlchemyAPI_ConceptParams();
            cparams.setMaxRetrieve(250);
        }
    public static void Main()
    {
        // Create an AlchemyAPI object.
        AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();

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

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

        // Extract sentiment from a text string.
        xml = alchemyObj.TextGetTextSentiment("Hello there, my name is Bob Jones.  I live in the United States of America.  Where do you live, Fred?");
        Console.WriteLine (xml);

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

        // Extract sentiment from a HTML document.
        xml = alchemyObj.HTMLGetTextSentiment(htmlDoc, "http://www.test.com/");
        Console.WriteLine (xml);

        // Extract named entities with entity-targeted sentiment.
        AlchemyAPI_EntityParams entityParams = new AlchemyAPI_EntityParams();
        entityParams.setSentiment(true);
        xml = alchemyObj.TextGetRankedNamedEntities("Bryan Adams' genius is unsurpassed.", entityParams);
        Console.WriteLine (xml);

        // Extract keywords with keyword-targeted sentiment.
        AlchemyAPI_KeywordParams keywordParams = new AlchemyAPI_KeywordParams();
        keywordParams.setSentiment(true);
        xml = alchemyObj.TextGetRankedKeywords("Bryan Adams' genius is unsurpassed.", keywordParams);
        Console.WriteLine (xml);

        // Extract Targeted Sentiment
        AlchemyAPI_TargetedSentimentParams sentimentParams = new AlchemyAPI_TargetedSentimentParams();
        sentimentParams.setShowSourceText(true);
        xml = alchemyObj.TextGetTargetedSentiment("This car is terrible.", "car", sentimentParams);
        Console.WriteLine(xml);

        xml = alchemyObj.URLGetTargetedSentiment("http://techcrunch.com/2012/03/01/keen-on-anand-rajaraman-how-walmart-wants-to-leapfrog-over-amazon-tctv/", "Walmart",sentimentParams);
        Console.WriteLine(xml);

        xml = alchemyObj.HTMLGetTargetedSentiment(htmlDoc, "http://www.test.com/", "WujWuj", sentimentParams);
        Console.WriteLine(xml);
    }
Exemple #21
0
    public static void Main()
    {
        // Create an AlchemyAPI object.
        AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();

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

        AlchemyAPI_ImageParams prms = new AlchemyAPI_ImageParams();
        prms.ImageMode = PageImageMode.AlwaysInfer;

        string xml = alchemyObj.URLGetImage("http://www.theguardian.com/world/2013/dec/01/ukraine-largest-street-protests-orange-revolution", prms);

        Console.WriteLine(xml);
    }
Exemple #22
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");

        AlchemyAPI_ImageParams prms = new AlchemyAPI_ImageParams();

        prms.ImageMode = PageImageMode.AlwaysInfer;

        string xml = alchemyObj.URLGetImage("http://www.theguardian.com/world/2013/dec/01/ukraine-largest-street-protests-orange-revolution", prms);

        Console.WriteLine(xml);
    }
Exemple #23
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");

        AlchemyAPI_CombinedDataParams prms = new AlchemyAPI_CombinedDataParams();

        prms.Extractions = CombinedExtract.Title | CombinedExtract.Author | CombinedExtract.Entity | CombinedExtract.Concept;

        string xml = alchemyObj.URLGetCombinedData("http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html", prms);

        Console.WriteLine(xml);
    }
Exemple #24
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 page text from a web URL. (ignoring ads, navigation links, etc.)
        string xml = alchemyObj.URLGetText("http://www.techcrunch.com/");

        Console.WriteLine(xml);


        // Extract raw page text from a web URL. (including ads, navigation links, etc.)
        xml = alchemyObj.URLGetRawText("http://www.techcrunch.com/");
        Console.WriteLine(xml);


        // Extract a title from a web URL.
        xml = alchemyObj.URLGetTitle("http://www.techcrunch.com/");
        Console.WriteLine(xml);


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

        streamReader.Close();


        // Extract page text from a HTML document. (ignoring ads, navigation links, etc.)
        xml = alchemyObj.HTMLGetText(htmlDoc, "http://www.test.com/");
        Console.WriteLine(xml);


        // Extract raw page text from a HTML document. (including ads, navigation links, etc.)
        xml = alchemyObj.HTMLGetRawText(htmlDoc, "http://www.test.com/");
        Console.WriteLine(xml);


        // Extract a title from a HTML document.
        xml = alchemyObj.HTMLGetTitle(htmlDoc, "http://www.test.com/");
        Console.WriteLine(xml);
    }
Exemple #25
0
	static public void Main ()
	{
		// Create an AlchemyAPI object.
		AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();

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

		string htmlDoc = File.ReadAllText("data/example.html");

		string xml = alchemyObj.URLGetRankedTaxonomy("http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html");

		Console.WriteLine(xml);

		xml = alchemyObj.HTMLGetRankedTaxonomy(htmlDoc, "http://www.test.com/");
		Console.WriteLine(xml);
	}
    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 a ranked list of relations from a web URL.
        string xml = alchemyObj.URLGetRelations("http://www.techcrunch.com/");

        Console.WriteLine(xml);


        // Extract a ranked list of relations from a text string.
        xml = alchemyObj.TextGetRelations("Hello there, my name is Bob Jones.  I live in the United States of America.  Where do you live, Fred?");
        Console.WriteLine(xml);


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

        streamReader.Close();


        // Extract a ranked list of relations from a HTML document.
        xml = alchemyObj.HTMLGetRelations(htmlDoc, "http://www.test.com/");
        Console.WriteLine(xml);

        AlchemyAPI_RelationParams relationParams = new AlchemyAPI_RelationParams();

        relationParams.setSentiment(true);
        relationParams.setEntities(true);
        relationParams.setDisambiguate(true);
        relationParams.setSentimentExcludeEntities(true);
        xml = alchemyObj.TextGetRelations("Madonna enjoys tasty Pepsi.  I love her style.", relationParams);
        Console.WriteLine(xml);

        relationParams.setSentiment(true);
        relationParams.setRequireEntities(true);
        relationParams.setSentimentExcludeEntities(false);
        xml = alchemyObj.TextGetRelations("Madonna enjoys tasty Pepsi.  I love her style.", relationParams);
        Console.WriteLine(xml);
    }
Exemple #27
0
    static public void Main()
    {
        // Create an AlchemyAPI object.
        AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();

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

        string htmlDoc = File.ReadAllText("data/example.html");

        string xml = alchemyObj.URLGetRankedTaxonomy("http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html");

        Console.WriteLine(xml);

        xml = alchemyObj.HTMLGetRankedTaxonomy(htmlDoc, "http://www.test.com/");
        Console.WriteLine(xml);
    }
    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");

        // Use the upload image class
        AlchemyAPI_RankedImageKeywords fozzle = new AlchemyAPI_RankedImageKeywords();
        fozzle.SetImage("data/fozzle.jpg");

        string ret = alchemyObj.ImageGetRankedImageKeywords(fozzle);

        Console.WriteLine(ret);

        ret = alchemyObj.URLGetRankedImageKeywords("http://truestorieswithgill.com/wp-content/uploads/2013/09/20130915-190532.jpg");

        Console.WriteLine(ret);
    }
Exemple #29
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");

        // Use the upload image class
        AlchemyAPI_RankedImageKeywords fozzle = new AlchemyAPI_RankedImageKeywords();

        fozzle.SetImage("data/fozzle.jpg");

        string ret = alchemyObj.ImageGetRankedImageKeywords(fozzle);

        Console.WriteLine(ret);

        ret = alchemyObj.URLGetRankedImageKeywords("http://truestorieswithgill.com/wp-content/uploads/2013/09/20130915-190532.jpg");

        Console.WriteLine(ret);
    }
    public static void Main()
    {
        // Create an AlchemyAPI object.
        AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();

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

        // Extract a ranked list of relations from a web URL.
        string xml = alchemyObj.URLGetRelations("http://www.techcrunch.com/");
        Console.WriteLine (xml);

        // Extract a ranked list of relations from a text string.
        xml = alchemyObj.TextGetRelations("Hello there, my name is Bob Jones.  I live in the United States of America.  Where do you live, Fred?");
        Console.WriteLine (xml);

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

        // Extract a ranked list of relations from a HTML document.
        xml = alchemyObj.HTMLGetRelations(htmlDoc, "http://www.test.com/");
        Console.WriteLine (xml);

        AlchemyAPI_RelationParams relationParams = new AlchemyAPI_RelationParams();
        relationParams.setSentiment(true);
        relationParams.setEntities(true);
        relationParams.setDisambiguate(true);
        relationParams.setSentimentExcludeEntities(true);
        xml = alchemyObj.TextGetRelations("Madonna enjoys tasty Pepsi.  I love her style.", relationParams);
        Console.WriteLine (xml);

        relationParams.setSentiment(true);
        relationParams.setRequireEntities(true);
        relationParams.setSentimentExcludeEntities(false);
        xml = alchemyObj.TextGetRelations("Madonna enjoys tasty Pepsi.  I love her style.", relationParams);
        Console.WriteLine (xml);
    }
Exemple #31
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");
		
		// Load a HTML document to analyze.
		StreamReader streamReader = new StreamReader("data/example.html");
		string htmlDoc = streamReader.ReadToEnd();
		streamReader.Close();

		// Extract concept tags for a web URL.
		string xml = alchemyObj.URLGetAuthor("http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html");
		Console.WriteLine (xml);
		
		// Extract concept tags for a web URL.
		xml = alchemyObj.HTMLGetAuthor(htmlDoc, "http://www.test.com/");
		Console.WriteLine (xml);
	}
    public static void Main()
    {
        // Create an AlchemyAPI object.
        AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();

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

        // Extract page text from a web URL. (ignoring ads, navigation links, etc.)
        string xml = alchemyObj.URLGetText("http://www.techcrunch.com/");
        Console.WriteLine (xml);

        // Extract raw page text from a web URL. (including ads, navigation links, etc.)
        xml = alchemyObj.URLGetRawText("http://www.techcrunch.com/");
        Console.WriteLine (xml);

        // Extract a title from a web URL.
        xml = alchemyObj.URLGetTitle("http://www.techcrunch.com/");
        Console.WriteLine (xml);

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

        // Extract page text from a HTML document. (ignoring ads, navigation links, etc.)
        xml = alchemyObj.HTMLGetText(htmlDoc, "http://www.test.com/");
        Console.WriteLine (xml);

        // Extract raw page text from a HTML document. (including ads, navigation links, etc.)
        xml = alchemyObj.HTMLGetRawText(htmlDoc, "http://www.test.com/");
        Console.WriteLine (xml);

        // Extract a title from a HTML document.
        xml = alchemyObj.HTMLGetTitle(htmlDoc, "http://www.test.com/");
        Console.WriteLine (xml);
    }
Exemple #33
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");

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

        streamReader.Close();

        // Extract concept tags for a web URL.
        string xml = alchemyObj.URLGetAuthor("http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html");

        Console.WriteLine(xml);

        // Extract concept tags for a web URL.
        xml = alchemyObj.HTMLGetAuthor(htmlDoc, "http://www.test.com/");
        Console.WriteLine(xml);
    }
Exemple #34
0
        public ActionResult Test1()
        {
            // Create an AlchemyAPI object.
            AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();

            // Extract sentiment for a web URL.
            string json = alchemyObj.URLGetTextSentiment("http://www.techcrunch.com/");
            var res = json.FromJson<RequestRes>();

            // Extract sentiment from a text string.
            json = alchemyObj.TextGetTextSentiment("Hello there, my name is Bob Jones.  I live in the United States of America.  Where do you live, Fred?");
            res = json.FromJson<RequestRes>();

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

            // Extract sentiment from a HTML document.
            //xml = alchemyObj.HTMLGetTextSentiment(htmlDoc, "http://www.test.com/");
            //Console.WriteLine(xml);

            // Extract named entities with entity-targeted sentiment.
            //AlchemyAPI_EntityParams entityParams = new AlchemyAPI_EntityParams();
            //entityParams.setSentiment(true);
            //xml = alchemyObj.TextGetRankedNamedEntities("Bryan Adams' genius is unsurpassed.", entityParams);
            //Console.WriteLine(xml);

            //// Extract keywords with keyword-targeted sentiment.
            //AlchemyAPI_KeywordParams keywordParams = new AlchemyAPI_KeywordParams();
            //keywordParams.setSentiment(true);
            //xml = alchemyObj.TextGetRankedKeywords("Bryan Adams' genius is unsurpassed.", keywordParams);
            //Console.WriteLine(xml);

            return Json(res, JsonRequestBehavior.AllowGet);
        }
    static public void Main1()
    {
        // Create an AlchemyAPI object.
        AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();


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


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

        Console.WriteLine(xml);


        // Extract sentiment from a text string.
        xml = alchemyObj.TextGetTextSentiment("Hello there, my name is Bob Jones.  I live in the United States of America.  Where do you live, Fred?");
        Console.WriteLine(xml);


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

        streamReader.Close();


        // Extract sentiment from a HTML document.
        xml = alchemyObj.HTMLGetTextSentiment(htmlDoc, "http://www.test.com/");
        Console.WriteLine(xml);


        // Extract named entities with entity-targeted sentiment.
        AlchemyAPI_EntityParams entityParams = new AlchemyAPI_EntityParams();

        entityParams.setSentiment(true);
        xml = alchemyObj.TextGetRankedNamedEntities("Bryan Adams' genius is unsurpassed.", entityParams);
        Console.WriteLine(xml);


        // Extract keywords with keyword-targeted sentiment.
        AlchemyAPI_KeywordParams keywordParams = new AlchemyAPI_KeywordParams();

        keywordParams.setSentiment(true);
        xml = alchemyObj.TextGetRankedKeywords("Bryan Adams' genius is unsurpassed.", keywordParams);
        Console.WriteLine(xml);

        // Extract Targeted Sentiment
        AlchemyAPI_TargetedSentimentParams sentimentParams = new AlchemyAPI_TargetedSentimentParams();

        sentimentParams.setShowSourceText(true);
        xml = alchemyObj.TextGetTargetedSentiment("This car is terrible.", "car", sentimentParams);
        Console.WriteLine(xml);

        xml = alchemyObj.URLGetTargetedSentiment("http://techcrunch.com/2012/03/01/keen-on-anand-rajaraman-how-walmart-wants-to-leapfrog-over-amazon-tctv/", "Walmart", sentimentParams);
        Console.WriteLine(xml);

        xml = alchemyObj.HTMLGetTargetedSentiment(htmlDoc, "http://www.test.com/", "WujWuj", sentimentParams);
        Console.WriteLine(xml);
    }
Exemple #36
0
		protected void InitializeAlchemy()
		{
			alchemyObj = new AlchemyAPI.AlchemyAPI();
			alchemyObj.LoadAPIKey("alchemyapikey.txt");
		}
Exemple #37
0
        public void Execute(AnalysisExecutionContext context)
        {
            _context = context;

            if (context.Results.Count <= 0)
            {
                context.OnExecutionProgress("Alchemy", new AnalysisExecutionProgressEventArgs(AnalysisExecutionStatus.Canceled, 0, 0, 0));
                return;
            }

            AlchemyAPI.AlchemyAPI session = new AlchemyAPI.AlchemyAPI();
            session.SetAPIKey(context.Key);

            AlchemyAPI_TargetedSentimentParams parameters = new AlchemyAPI_TargetedSentimentParams();

            parameters.setOutputMode(AlchemyAPI_BaseParams.OutputMode.XML);

            int processed = 0;
            int failed    = 0;

            foreach (KeyValuePair <string, ResultSet> document in context.Results)
            {
                try
                {
                    string strResult = string.Empty;
                    if (context.UseDebugMode)
                    {
                        TimeSpan time = TimeSpan.Zero;
                        strResult = BenchmarkHelper.Invoke(new InvokeBenchmarkHandler(delegate(object state)
                        {
                            return(session.TextGetTextSentiment(document.Value.Source, parameters));
                        }), null, out time) as string;

                        Console.WriteLine("\tAlchemyAPI: Sentiment for the document {0} has been retreived. Execution time is: {1}", document.Key, time.TotalMilliseconds);
                    }
                    else
                    {
                        strResult = session.TextGetTextSentiment(document.Value.Source, parameters);
                    }

                    using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(strResult)))
                    {
                        XmlSerializer          serializer = new XmlSerializer(typeof(AlchemySentimentResult));
                        AlchemySentimentResult result     = (AlchemySentimentResult)serializer.Deserialize(stream);

                        processed++;
                        document.Value.AddOutput("Alchemy", result.SentimentDetails.Score, result.SentimentDetails.Type);

                        AnalysisExecutionProgressEventArgs ea = new AnalysisExecutionProgressEventArgs(AnalysisExecutionStatus.Processed, context.Results.Count, processed, failed);
                        context.OnExecutionProgress("Alchemy", ea);

                        if (ea.Cancel)
                        {
                            break;
                        }
                    }
                }
                catch (Exception ex)
                {
                    failed++;
                    document.Value.AddOutput("Alchemy", 0, "failed");
                    AnalysisExecutionProgressEventArgs ea = new AnalysisExecutionProgressEventArgs(AnalysisExecutionStatus.Failed, context.Results.Count, processed, failed);
                    ea.Reason = ex.Message;
                    context.OnExecutionProgress("Alchemy", ea);

                    if (ea.Cancel)
                    {
                        break;
                    }
                }
            }

            context.OnExecutionProgress("Alchemy", new AnalysisExecutionProgressEventArgs(AnalysisExecutionStatus.Success, context.Results.Count, processed, failed));
        }
Exemple #38
0
        public void Execute(AnalysisExecutionContext context)
        {
            _context = context;

            if (context.Results.Count <= 0)
            {
                context.OnExecutionProgress("Alchemy", new AnalysisExecutionProgressEventArgs(AnalysisExecutionStatus.Canceled, 0, 0, 0));
                return;
            }

            AlchemyAPI.AlchemyAPI session = new AlchemyAPI.AlchemyAPI();
            session.SetAPIKey(context.Key);

            AlchemyAPI_TargetedSentimentParams parameters = new AlchemyAPI_TargetedSentimentParams();
            parameters.setOutputMode(AlchemyAPI_BaseParams.OutputMode.XML);

            int processed = 0;
            int failed = 0;
            foreach (KeyValuePair<string, ResultSet> document in context.Results)
            {
                try
                {
                    string strResult = string.Empty;
                    if (context.UseDebugMode)
                    {
                        TimeSpan time = TimeSpan.Zero;
                        strResult = BenchmarkHelper.Invoke(new InvokeBenchmarkHandler(delegate(object state)
                        {
                            return session.TextGetTextSentiment(document.Value.Source, parameters);
                        }), null, out time) as string;

                        Console.WriteLine("\tAlchemyAPI: Sentiment for the document {0} has been retreived. Execution time is: {1}", document.Key, time.TotalMilliseconds);
                    }
                    else
                        strResult = session.TextGetTextSentiment(document.Value.Source, parameters);

                    using (MemoryStream stream = new MemoryStream(Encoding.UTF8.GetBytes(strResult)))
                    {
                        XmlSerializer serializer = new XmlSerializer(typeof(AlchemySentimentResult));
                        AlchemySentimentResult result = (AlchemySentimentResult)serializer.Deserialize(stream);

                        processed++;
                        document.Value.AddOutput("Alchemy", result.SentimentDetails.Score, result.SentimentDetails.Type);

                        AnalysisExecutionProgressEventArgs ea = new AnalysisExecutionProgressEventArgs(AnalysisExecutionStatus.Processed, context.Results.Count, processed, failed);
                        context.OnExecutionProgress("Alchemy", ea);

                        if (ea.Cancel)
                            break;
                    }
                }
                catch (Exception ex)
                {
                    failed++;
                    document.Value.AddOutput("Alchemy", 0, "failed");
                    AnalysisExecutionProgressEventArgs ea = new AnalysisExecutionProgressEventArgs(AnalysisExecutionStatus.Failed, context.Results.Count, processed, failed);
                    ea.Reason = ex.Message;
                    context.OnExecutionProgress("Alchemy", ea);

                    if (ea.Cancel)
                        break;
                }
            }

            context.OnExecutionProgress("Alchemy", new AnalysisExecutionProgressEventArgs(AnalysisExecutionStatus.Success, context.Results.Count, processed, failed));
        }
Exemple #39
0
 protected void InitializeAlchemy()
 {
     alchemyObj = new AlchemyAPI.AlchemyAPI();
     alchemyObj.LoadAPIKey("alchemyapikey.txt");
 }
Exemple #40
0
        public static void ProcessUrl(string url, DateTime date, string source, string title)
        {
            if (LinkList.Count < 1)
                LoadProcessedLinks(date);

            if (CheckIfUrlProcessed(url))
                return;

            try
            {
                AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();
                alchemyObj.LoadAPIKey("api_key.txt");
                AlchemyAPI.AlchemyAPI_EntityParams prms = new AlchemyAPI.AlchemyAPI_EntityParams();
                prms.setSentiment(true);
                prms.setMaxRetrieve(1000);
                prms.setOutputMode(AlchemyAPI_BaseParams.OutputMode.XML);
                string in_xml = alchemyObj.URLGetRankedNamedEntities(url, prms);
                string mid_xml = in_xml.Replace("<sentiment>", "");
                string s_xml = mid_xml.Replace("</sentiment>", "");
                string xml_01 = s_xml.Replace(@"<type>Person</type>", @"<Stype>Person</Stype>");
                string xml_02 = xml_01.Replace(@"<type>PrintMedia</type>", @"<Stype>PrintMedia</Stype>");
                string xml_03 = xml_02.Replace(@"<type>JobTitle</type>", @"<Stype>JobTitle</Stype>");
                string xml_04 = xml_03.Replace(@"<type>FieldTerminology</type>", @"<Stype>FieldTerminology</Stype>");
                string xml_05 = xml_04.Replace(@"<type>Company</type>", @"<Stype>Company</Stype>");
                string xml_06 = xml_05.Replace(@"<type>City</type>", @"<Stype>City</Stype>");
                string xml_07 = xml_06.Replace(@"<type>State</type>", @"<Stype>State</Stype>");  //
                string xml_08 = xml_07.Replace(@"<type>Country</type>", @"<Stype>Country</Stype>");
                string xml_09 = xml_08.Replace(@"<type>Automobile</type>", @"<Stype>Automobile</Stype>");
                string xml_10 = xml_09.Replace(@"<type>TelevisionStation</type>", @"<Stype>TelevisionStation</Stype>");
                string xml_11 = xml_10.Replace(@"<type>StateOrCounty</type>", @"<Stype>StateOrCounty</Stype>");
                string xml_12 = xml_11.Replace(@"<type>Organization</type>", @"<Stype>Organization</Stype>");
                string xml_13 = xml_12.Replace(@"<type>OperatingSystem</type>", @"<Stype>OperatingSystem</Stype>");
                string xml_14 = xml_13.Replace(@"<type>Crime</type>", @"<Stype>Crime</Stype>");
                string xml_15 = xml_14.Replace(@"<type>Technology</type>", @"<Stype>Technology</Stype>");
                string xml_16 = xml_15.Replace(@"<type>Facility</type>", @"<Stype>Facility</Stype>");
                string xml_17 = xml_16.Replace(@"<type>Continent</type>", @"<Stype>Continent</Stype>");
                string xml_18 = xml_17.Replace(@"<type>FinancialMarketIndex</type>", @"<Stype>FinancialMarketIndex</Stype>");
                string xml = xml_18.Replace(@"<type>HealthCondition</type>", @"<Stype>HealthCondition</Stype>");

                if (Historical.printAPIresultXML)
                {
                    try
                    {
                        File.Delete("f.xml");
                        File.WriteAllText("f.xml", xml);
                    }
                    catch { }
                }

                DataSet newN = new DataSet();
                newN.ReadXml(new StringReader(xml), XmlReadMode.Auto);

                DataTable table = new DataTable();
                table = newN.Tables[2];

                lock (table)
                {
                    using (MySqlConnection cn1 = new MySqlConnection(connectMySQL))
                    {
                        MySqlCommand cmd;

                        foreach (DataRow row in table.Rows)
                        {
                            cn1.Open();
                            string txt = row["text"].ToString().Replace("'", "").Replace("`", "").Replace("’", "");
                            string mxd = "";
                            try
                            {
                                mxd = row["mixed"].ToString().Replace("'", "").Replace("`", "").Replace("’", "");
                            }
                            catch { }

                            var sqlDate = date.Date.ToString("yyyy-MM-dd");
                            string query = @"Insert INTO api_results (Stype, artdate, source, url, api, relevance, score, mixed, count, text)  values ('" + row["Stype"] + "','" + sqlDate + "','" + source + "','" + url + "','Alchemy','" + row["relevance"] + "','" + row["score"] + "','" + mxd + "','" + row["count"] + "','" + txt + "')";
                            cmd = new MySqlCommand(query, cn1);
                            cmd.ExecuteNonQuery();
                            cn1.Close();
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                using (StreamWriter writer = new StreamWriter("errors-exceptions-Log.txt", true))
                {
                    writer.WriteLine(DateTime.Now.ToString("dd/MM/yy | hh:mm:ss :: ")+ url +" ||"  + ex.ToString());
                }
                return;
            }
        }