Example

Example

"""
Description: Multi-Document Summarizer API usage example.
Copyright: (C) 2016 EffectiveSoft Ltd. All Rights Reserved.
Technical support: technical-support@effective-soft.com
"""

import json
import urllib
import urllib2

# list of urls for information extraction
urls = "[\"http://www.infoplease.com/biography/var/barackobama.html\",\"http://millercenter.org/president/biography/obama-life-in-brief\"]";

# set the URL for POST request, summarization parameters and API key for authorization purposes (change YourAPIKey to the Intellexer API key)
api_url = "http://api.intellexer.com/multiUrlSummary?apikey=YourAPIKey&summaryRestriction=10&returnedTopicsCount=1&relatedFactsRequest=\"Obama\"&maxRelatedFactsConcepts=20&maxRelatedFactsSentences=5"

# print related facts tree
def print_tree(node, height):
	for i in range(0, height):
		print "\t",
	print node.get('text').encode('utf-8')
	children = node.get('children')
	height += 1
	for child in children:
		print_tree(child, height)

# print response results
def print_response(response):
	print "Multi-Document summary:";
	items = response.get('items')
	for item in items:
		print item.get('text').encode('utf-8')
	#print related facts tree
	print_tree(response.get('relatedFactsTree'), 0)

# create request to the Multi-Document Summarizer API service
def request_api(url, data):
	header = { 'Content-Type' : "application/json" }
	req = urllib2.Request(url, data, header)
	conn = urllib2.urlopen(req)
	try:
		json_response = json.loads(conn.read())
	finally:
		conn.close()
	print_response(json_response)

# perform the request
try:
	request_api(api_url, urls)
except urllib2.HTTPError as error:
	print 'HTTP error - %s' % error.read()

Output

Multi-Document summary:
Best known as: President of the United States, 2009-present
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.
After his parents divorced and his father returned to Africa, Obama stayed with his mother and was raised in Indonesia and Hawaii.
Obama ran for president in 2008, defeating a Democratic primary field that included New York Sen. Hillary Clinton , the former First Lady.
Barack Obama published the personal memoir Dreams from My Father in 1995, and published a second book, The Audacity of Hope , in 2006.
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 August 28, 2008, Senator Barack Obama accepted the Democratic nomination for President of the United States.
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.
When President Obama took office, he faced very significant challenges.
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.
	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.
	united state
		Best known as: President of the United States, 2009-present
		On August 28, 2008, Senator Barack Obama accepted the Democratic nomination for President of the United States.
		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.
	keynote speech
		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.
	constitutional law
		He also taught constitutional law for 12 years at the University of Chicago.
	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.
	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.
	former lady
		Obama ran for president in 2008, defeating a Democratic primary field that included New York Sen. Hillary Clinton , the former First Lady.
	immigration reform
		After winning reelection in 2012, Obama began his second term focused on immigration reform and gun control.
	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.
	international diplomacy
		Obama was awarded the Nobel Peace Prize in 2009, for "his extraordinary efforts to strengthen international diplomacy and cooperation between peoples."
	invesco field
		His campaign for the nomination had lasted more than a year and culminated with his speech at Invesco Field in Denver, Colorado.
	community organizer
		Obama worked as a community organizer in Chicago, where he met and married Michelle LaVaughn Robinson in 1992.
	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 shot to national fame after delivering a stirring keynote speech in support of John Kerry at the 2004 Democratic national convention.
		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 married the former Michelle Robinson in 1992.
		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.