This repository was archived by the owner on Oct 30, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 15
Expand file tree
/
Copy pathparameters.cs
More file actions
42 lines (33 loc) · 1.4 KB
/
parameters.cs
File metadata and controls
42 lines (33 loc) · 1.4 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
using System;
using System.IO;
using AlchemyAPI;
public class TestApp
{
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);
}
}