Skip to content
This repository was archived by the owner on Oct 30, 2018. It is now read-only.

Commit 660fe00

Browse files
committed
Implemented the combined call
1 parent 64c6c65 commit 660fe00

File tree

8 files changed

+411
-19
lines changed

8 files changed

+411
-19
lines changed

example/combined.cs

Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
2+
using System;
3+
using System.IO;
4+
using AlchemyAPI;
5+
6+
7+
public class TestApp
8+
{
9+
static public void Main ()
10+
{
11+
// Create an AlchemyAPI object.
12+
AlchemyAPI.AlchemyAPI alchemyObj = new AlchemyAPI.AlchemyAPI();
13+
14+
// Load an API key from disk.
15+
alchemyObj.LoadAPIKey("api_key.txt");
16+
17+
AlchemyAPI_CombinedDataParams prms = new AlchemyAPI_CombinedDataParams();
18+
prms.Extractions = CombinedExtract.Title | CombinedExtract.Author | CombinedExtract.Entity | CombinedExtract.Concept;
19+
20+
string xml = alchemyObj.URLGetCombinedData("http://www.politico.com/blogs/media/2012/02/detroit-news-ed-upset-over-romney-edit-115247.html", prms);
21+
Console.WriteLine(xml);
22+
}
23+
}

example/combined/AssemblyInfo.cs

Lines changed: 27 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,27 @@
1+
using System.Reflection;
2+
using System.Runtime.CompilerServices;
3+
4+
// Information about this assembly is defined by the following attributes.
5+
// Change them to the values specific to your project.
6+
7+
[assembly: AssemblyTitle("combined")]
8+
[assembly: AssemblyDescription("")]
9+
[assembly: AssemblyConfiguration("")]
10+
[assembly: AssemblyCompany("")]
11+
[assembly: AssemblyProduct("")]
12+
[assembly: AssemblyCopyright("mike")]
13+
[assembly: AssemblyTrademark("")]
14+
[assembly: AssemblyCulture("")]
15+
16+
// The assembly version has the format "{Major}.{Minor}.{Build}.{Revision}".
17+
// The form "{Major}.{Minor}.*" will automatically update the build and revision,
18+
// and "{Major}.{Minor}.{Build}.*" will update just the revision.
19+
20+
[assembly: AssemblyVersion("1.0.*")]
21+
22+
// The following attributes are used to specify the signing key for the assembly,
23+
// if desired. See the Mono documentation for more information about signing.
24+
25+
//[assembly: AssemblyDelaySign(false)]
26+
//[assembly: AssemblyKeyFile("")]
27+

example/combined/combined.csproj

Lines changed: 53 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,53 @@
1+
<?xml version="1.0" encoding="utf-8"?>
2+
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3+
<PropertyGroup>
4+
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
5+
<Platform Condition=" '$(Platform)' == '' ">AnyCPU</Platform>
6+
<ProductVersion>10.0.0</ProductVersion>
7+
<SchemaVersion>2.0</SchemaVersion>
8+
<ProjectGuid>{DC4C1286-3B69-4826-AA74-AAC87B34E4ED}</ProjectGuid>
9+
<OutputType>Exe</OutputType>
10+
<RootNamespace>combined</RootNamespace>
11+
<AssemblyName>combined</AssemblyName>
12+
</PropertyGroup>
13+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Debug|AnyCPU' ">
14+
<DebugSymbols>true</DebugSymbols>
15+
<DebugType>full</DebugType>
16+
<Optimize>false</Optimize>
17+
<OutputPath>bin\Debug</OutputPath>
18+
<DefineConstants>DEBUG;</DefineConstants>
19+
<ErrorReport>prompt</ErrorReport>
20+
<WarningLevel>4</WarningLevel>
21+
<Externalconsole>true</Externalconsole>
22+
</PropertyGroup>
23+
<PropertyGroup Condition=" '$(Configuration)|$(Platform)' == 'Release|AnyCPU' ">
24+
<DebugType>none</DebugType>
25+
<Optimize>true</Optimize>
26+
<OutputPath>bin\Release</OutputPath>
27+
<ErrorReport>prompt</ErrorReport>
28+
<WarningLevel>4</WarningLevel>
29+
<Externalconsole>true</Externalconsole>
30+
</PropertyGroup>
31+
<ItemGroup>
32+
<Reference Include="System" />
33+
</ItemGroup>
34+
<ItemGroup>
35+
<Compile Include="AssemblyInfo.cs" />
36+
<Compile Include="..\combined.cs">
37+
<Link>combined.cs</Link>
38+
</Compile>
39+
</ItemGroup>
40+
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
41+
<ItemGroup>
42+
<ProjectReference Include="..\..\module\sdk\sdk.csproj">
43+
<Project>{799E354F-E323-408C-9733-7F1896342663}</Project>
44+
<Name>sdk</Name>
45+
</ProjectReference>
46+
</ItemGroup>
47+
<ItemGroup>
48+
<None Include="..\api_key.txt">
49+
<Link>api_key.txt</Link>
50+
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
51+
</None>
52+
</ItemGroup>
53+
</Project>

module/AlchemyAPI.cs

Lines changed: 51 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -68,7 +68,8 @@ public void LoadAPIKey(string filename)
6868
throw ex;
6969
}
7070
}
71-
71+
72+
#region GetAuthor
7273
public string URLGetAuthor(string url)
7374
{
7475
CheckURL(url);
@@ -99,7 +100,9 @@ public string HTMLGetAuthor(string html, string url, AlchemyAPI_BaseParams param
99100

100101
return POST("HTMLGetAuthor", "html", parameters);
101102
}
103+
#endregion
102104

105+
#region GetRankedNamedEntities
103106
public string URLGetRankedNamedEntities(string url)
104107
{
105108
CheckURL(url);
@@ -146,7 +149,9 @@ public string TextGetRankedNamedEntities(string text, AlchemyAPI_EntityParams pa
146149

147150
return POST("TextGetRankedNamedEntities", "text", parameters);
148151
}
152+
#endregion
149153

154+
#region GetRankedConcepts
150155
public string URLGetRankedConcepts(string url)
151156
{
152157
CheckURL(url);
@@ -192,7 +197,9 @@ public string TextGetRankedConcepts(string text, AlchemyAPI_ConceptParams parame
192197

193198
return POST("TextGetRankedConcepts", "text", parameters);
194199
}
195-
200+
#endregion
201+
202+
#region GetRankedKeywords
196203
public string URLGetRankedKeywords(string url)
197204
{
198205
CheckURL(url);
@@ -238,7 +245,9 @@ public string TextGetRankedKeywords(string text, AlchemyAPI_KeywordParams parame
238245

239246
return POST("TextGetRankedKeywords", "text", parameters);
240247
}
248+
#endregion
241249

250+
#region GetLanguage
242251
public string URLGetLanguage(string url)
243252
{
244253
CheckURL(url);
@@ -284,7 +293,9 @@ public string TextGetLanguage(string text, AlchemyAPI_LanguageParams parameters)
284293

285294
return POST("TextGetLanguage", "text", parameters);
286295
}
296+
#endregion
287297

298+
#region GetCategory
288299
public string URLGetCategory(string url)
289300
{
290301
CheckURL(url);
@@ -330,7 +341,9 @@ public string TextGetCategory(string text, AlchemyAPI_CategoryParams parameters)
330341

331342
return POST("TextGetCategory", "text", parameters);
332343
}
333-
344+
#endregion
345+
346+
#region GetText
334347
public string URLGetText(string url)
335348
{
336349
CheckURL(url);
@@ -361,7 +374,9 @@ public string HTMLGetText(string html, string url,AlchemyAPI_TextParams paramete
361374

362375
return POST("HTMLGetText", "html", parameters);
363376
}
377+
#endregion
364378

379+
#region GetRawText
365380
public string URLGetRawText(string url)
366381
{
367382
CheckURL(url);
@@ -392,7 +407,9 @@ public string HTMLGetRawText(string html, string url, AlchemyAPI_BaseParams para
392407

393408
return POST("HTMLGetRawText", "html", parameters);
394409
}
410+
#endregion
395411

412+
#region GetTitle
396413
public string URLGetTitle(string url)
397414
{
398415
CheckURL(url);
@@ -424,7 +441,9 @@ public string HTMLGetTitle(string html, string url, AlchemyAPI_BaseParams parame
424441

425442
return POST("HTMLGetTitle", "html", parameters);
426443
}
444+
#endregion
427445

446+
#region GetFeedLinks
428447
public string URLGetFeedLinks(string url)
429448
{
430449
CheckURL(url);
@@ -455,7 +474,9 @@ public string HTMLGetFeedLinks(string html, string url, AlchemyAPI_BaseParams pa
455474

456475
return POST("HTMLGetFeedLinks", "html", parameters);
457476
}
477+
#endregion
458478

479+
#region GetMicroformats
459480
public string URLGetMicroformats(string url)
460481
{
461482
CheckURL(url);
@@ -486,7 +507,9 @@ public string HTMLGetMicroformats(string html, string url, AlchemyAPI_BaseParams
486507

487508
return POST("HTMLGetMicroformatData", "html", parameters);
488509
}
510+
#endregion
489511

512+
#region GetConstraintQuery
490513
public string URLGetConstraintQuery(string url, string query)
491514
{
492515
CheckURL(url);
@@ -553,7 +576,9 @@ public string HTMLGetConstraintQuery(string html, string url, AlchemyAPI_Constra
553576

554577
return POST("HTMLGetConstraintQuery", "html", parameters);
555578
}
579+
#endregion
556580

581+
#region GetTextSentiment
557582
public string URLGetTextSentiment(string url)
558583
{
559584
CheckURL(url);
@@ -599,7 +624,9 @@ public string TextGetTextSentiment(string text, AlchemyAPI_BaseParams parameters
599624

600625
return POST("TextGetTextSentiment", "text", parameters);
601626
}
602-
//------
627+
#endregion
628+
629+
#region GetTargetedSentiment
603630
public string URLGetTargetedSentiment(string url, string target)
604631
{
605632
CheckURL(url);
@@ -658,8 +685,9 @@ public string TextGetTargetedSentiment(string text, string target, AlchemyAPI_Ta
658685

659686
return POST("TextGetTargetedSentiment", "text", parameters);
660687
}
661-
//------
688+
#endregion
662689

690+
#region GetRelations
663691
public string URLGetRelations(string url)
664692
{
665693
CheckURL(url);
@@ -705,6 +733,24 @@ public string TextGetRelations(string text, AlchemyAPI_RelationParams parameters
705733

706734
return POST("TextGetRelations", "text", parameters);
707735
}
736+
#endregion
737+
738+
#region GetCombinedData
739+
public string URLGetCombinedData(string url, AlchemyAPI_CombinedDataParams parameters)
740+
{
741+
CheckURL(url);
742+
parameters.setUrl(url);
743+
744+
return GET ("URLGetCombinedData", "url", parameters);
745+
}
746+
public string TextGetCombinedData(string text, AlchemyAPI_CombinedDataParams parameters)
747+
{
748+
CheckText(text);
749+
parameters.setText(text);
750+
751+
return POST ("TextGetCombinedData", "text", parameters);
752+
}
753+
#endregion
708754

709755
private void CheckHTML(string html, string url)
710756
{

0 commit comments

Comments
 (0)