Example
# Description: Multi-Document Summarizer API usage example.
# Copyright: (C) 2015 EffectiveSoft Ltd. All Rights Reserved.
# Technical support: technical-support@effective-soft.com
# This example requires LWP and JSON libraries.
use JSON;
use LWP::UserAgent;
require HTTP::Request;
# list of urls for information extraction
my $urls = '["http://www.infoplease.com/biography/var/barackobama.html",
"http://millercenter.org/president/biography/obama-life-in-brief"]';
# returned data from Intellexer API
my $results = "";
# create connection to the Multi-Document Summarizer API service
my $ua = LWP::UserAgent->new or die "Cannot create connection!";
# set the URL for POST request, summarization parameters and API key for authorization purposes (change YourAPIKey to the Intellexer API key)
my $api_url = "http://api.intellexer.com/multiUrlSummary?apikey=YourAPIKey&summaryRestriction=10&returnedTopicsCount=1&relatedFactsRequest=\"Obama\"&maxRelatedFactsConcepts=20&maxRelatedFactsSentences=5";
my $req = HTTP::Request->new(POST => $api_url);
$req->header('content-type' => 'application/json');
$req->content($urls);
# perform the request
my $resp = $ua->request($req);
# error checking
if ($resp->is_success)
{
$results = $resp->decoded_content;
# parse JSON results
my $json_results = decode_json($results);
# print multi-document summary
print "Multi-Document summary: \n";
my @items = @{$json_results->{'items'}};
foreach my $item ( @items )
{
print $item->{'text'}, "\n";
}
# print facts related to the user query
print "\n";
printTree($json_results->{'relatedFactsTree'}, 0);
}
else
{
print "HTTP POST error code: ", $resp->code, "\t", "HTTP POST error message: ", $resp->message, "\n";
}
# print related facts tree
sub printTree()
{
my $node = shift;
my $tree_height = shift;
for (my $i = 0; $i < $tree_height; $i++)
{
print "\t";
}
print $node->{"text"}, "\n";
my @children = @{$node->{'children'}};
$tree_height++;
foreach my $child ( @children )
{
printTree($child, $tree_height);
}
}
Output
Multi-Document summary:
Barack Obama - Read this biography of Barack Obama, the 44th president of the United States and the winner of the 2009 Nobel Peace Prize.
The Miller Center is able to work to expand understanding of the presidency, policy, and political history only thanks to contributions from groups and individuals who support our mission.
On January 14, 2009, the Obama Transition team released the first official portrait for President Barack Obama.
Barack Obama was inaugurated as the 44th President of the United States-becoming the first African American to serve in that office-on January 20, 2009.
Leaving the state to attend college, he earned degrees from Columbia University and Harvard Law School.
When President Obama took office, he faced very significant challenges.
The economy was officially in a recession, and the outgoing administration of George W. Bush had begun to implement a controversial "bail-out" package to try to help struggling financial institutions.
Still the President spent significant time and political effort negotiating, for the most part unsuccessfully, with Congressional Republicans about taxes, budgets, and the deficit.
Although the initial impact of sequestration was limited, Obama warned about its long-term effects on the economy.
Agreement between the President and Congressional Republicans to craft a budget plan to end sequestration seemed unlikely to materialize quickly.
Related Facts
miller center
The Miller Center is able to work to expand understanding of the presidency, policy, and political history only thanks to contributions from groups and individuals who support our mission.
united state
In foreign affairs, the United States still had troops deployed in Iraq and Afghanistan, and warfare had broken out between Israel and Hamas in the Gaza Strip, illustrating the ongoing instability of the Middle East.
george bush
The economy was officially in a recession, and the outgoing administration of George W. Bush had begun to implement a controversial "bail-out" package to try to help struggling financial institutions.
keynote speech
Barack Obama shot to national fame after delivering a stirring keynote speech in support of John Kerry at the 2004 Democratic national convention.
The title of the latter book was also the title of his 2004 keynote speech, and both books won Grammys for best spoken word album.
democratic convention
He named Delaware senator Joe Biden to be his running mate at the Democratic Convention that August, and they defeated Republican nominees John McCain and Sarah Palin in the November general election.
bringing peace
His 2008 Grammy for The Audacity of Hope beat books by two former presidents: Bill Clinton 's Giving: How Each of Us Can Change the World and Jimmy Carter 's Sunday Mornings in Plains: Bringing Peace to a Changing World .
congressional republican
Still the President spent significant time and political effort negotiating, for the most part unsuccessfully, with Congressional Republicans about taxes, budgets, and the deficit.
Agreement between the President and Congressional Republicans to craft a budget plan to end sequestration seemed unlikely to materialize quickly.
constitutional law
He also taught constitutional law for 12 years at the University of Chicago.
columbia university
He earned an undergraduate degree from Columbia University in 1983 and a law degree from Harvard in 1991.
Leaving the state to attend college, he earned degrees from Columbia University and Harvard Law School.
immigration reform
After winning reelection in 2012, Obama began his second term focused on immigration reform and gun control.
former lady
Obama ran for president in 2008, defeating a Democratic primary field that included New York Sen. Hillary Clinton , the former First Lady.
significant challenge
When President Obama took office, he faced very significant challenges.
long-term effect
Although the initial impact of sequestration was limited, Obama warned about its long-term effects on the economy.
extraordinary effort
Obama was awarded the Nobel Peace Prize in 2009, for "his extraordinary efforts to strengthen international diplomacy and cooperation between peoples."
community organizer
Obama worked as a community organizer in Chicago, where he met and married Michelle LaVaughn Robinson in 1992.
pete souza
The photograph was taken by Pete Souza, the newly announced official White House photographer.
digital camera
It was the first time that an official presidential portrait was taken with a digital camera.
barack obama
Barack Obama has spoken often of his multicultural background: his father was from Kenya, his mother from Kansas, and they met at the University of Hawaii.
Barack Obama published the personal memoir Dreams from My Father in 1995, and published a second book, The Audacity of Hope , in 2006.
Barack Obama - Read this biography of Barack Obama, the 44th president of the United States and the winner of the 2009 Nobel Peace Prize.
On January 14, 2009, the Obama Transition team released the first official portrait for President Barack Obama.
Barack Obama was inaugurated as the 44th President of the United States-becoming the first African American to serve in that office-on January 20, 2009.
barnhill galland
He then joined the Chicago law firm of Miner, Barnhill & Galland, which specialized in civil rights legislation.