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 3
Expand file tree
/
Copy pathparameters.pl
More file actions
59 lines (39 loc) · 1.53 KB
/
parameters.pl
File metadata and controls
59 lines (39 loc) · 1.53 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
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
#!/usr/bin/perl -w
############################################################################
#
# AlchemyAPI Perl Example: SDK Parameters
# Author: Orchestr8, LLC
# Copyright (C) 2009-2010, Orchestr8, LLC.
#
############################################################################
use strict;
use AlchemyAPI;
# Create the AlchemyAPI object.
my $alchemyObj = new AlchemyAPI();
# Load the API key from disk.
if ($alchemyObj->LoadKey("api_key.txt") eq "error")
{
die "Error loading API key. Edit api_key.txt and insert your API key.";
}
my $result = '';
my $keywordParams = new AlchemyAPI_KeywordParams();
$keywordParams->SetMaxRetrieve(1);
$keywordParams->SetKeywordExtractMode(AlchemyAPI_KeywordParams::KEYWORD_EXTRACT_MODE_STRICT);
# Get a list of topic keywords for a text string.
$result = $alchemyObj->TextGetRankedKeywords("Microsoft released a new product today. Microsoft wants you to try it out. Download it here.", $keywordParams);
printf $result;
my $entityParams = new AlchemyAPI_EntityParams();
$entityParams->SetMaxRetrieve(2);
$entityParams->SetDisambiguate(1);
$entityParams->SetSentiment(1);
$entityParams->SetOutputMode(AlchemyAPI_BaseParams::OUTPUT_MODE_RDF);
# Get a ranked list of named entities for a web URL.
$result = $alchemyObj->URLGetRankedNamedEntities("http://www.gigaom.com/", $entityParams);
if ($result ne "error")
{
printf $result;
}
# Get a list of topic keywords for a HTML document.
#$result = $alchemyObj->HTMLGetRankedKeywords($HTMLContent, "http://www.test.com/");
#printf $result;
printf "Done";