Skip to content

Commit 1936657

Browse files
author
Chris Park
committed
Modified examples to new format
1 parent e1901a6 commit 1936657

17 files changed

+36
-21
lines changed

examples/__init__.py

Lines changed: 0 additions & 1 deletion
This file was deleted.

examples/base64_input.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,16 +9,16 @@
99
import os
1010
import base64
1111

12-
from rosette.api import API, DocumentParameters
12+
from rosette.api import API, DocumentParameters, DataFormat
1313

1414

1515
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
1616
# Create an API instance
1717
api = API(user_key=key, service_url=altUrl)
1818
params = DocumentParameters()
19-
text = base64.b64encode(u"Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS ")
20-
params["content"] = text
21-
params["contentType"] = "text/html"
19+
entities_text_data = "Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS"
20+
params["content"] = entities_text_data
21+
params["contentType"] = DataFormat.UNSPECIFIED
2222
return api.entities(params) # entity linking is turned off
2323

2424
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint')

examples/categories.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,8 @@
1212

1313

1414
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
15-
url = "Sony Pictures is planning to shoot a good portion of the new "Ghostbusters" in Boston as well."
15+
categories_url_data = "http://www.onlocationvacations.com/2015/03/05/the-new-ghostbusters-movie-begins-filming-in-boston-in-june/"
16+
url = categories_url_data
1617
# Create an API instance
1718
api = API(user_key=key, service_url=altUrl)
1819
params = DocumentParameters()

examples/entities.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -14,8 +14,9 @@
1414
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
1515
# Create an API instance
1616
api = API(user_key=key, service_url=altUrl)
17+
entities_text_data = "Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS"
1718
params = DocumentParameters()
18-
params["content"] = u"Bill Murray will appear in new Ghostbusters film: Dr. Peter Venkman was spotted filming a cameo in Boston this… http://dlvr.it/BnsFfS "
19+
params["content"] = entities_text_data
1920
return api.entities(params) # entity linking is turned off
2021

2122
parser = argparse.ArgumentParser(formatter_class=argparse.ArgumentDefaultsHelpFormatter, description='Calls the ' + os.path.splitext(os.path.basename(__file__))[0] + ' endpoint')

examples/entities_linked.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ def run(key, altUrl='https://api.rosette.com/rest/v1/'):
1515
# Create an API instance
1616
api = API(user_key=key, service_url=altUrl)
1717

18+
entities_linked_text_data = "Last month director Paul Feig announced the movie will have an all-star female cast including Kristen Wiig, Melissa McCarthy, Leslie Jones and Kate McKinnon."
1819
params = DocumentParameters()
19-
params["content"] = u"Last month director Paul Feig announced the movie will have an all-star female cast including Kristen Wiig, Melissa McCarthy, Leslie Jones and Kate McKinnon."
20+
params["content"] = entities_linked_text_data
2021
return api.entities(params, True) # entity linking is turned on
2122

2223

examples/language.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@ def run(key, altUrl='https://api.rosette.com/rest/v1/'):
1515
# Create an API instance
1616
api = API(user_key=key, service_url=altUrl)
1717

18+
language_data = "Por favor Señorita, says the man."
1819
params = DocumentParameters()
1920

20-
params["content"] = u"Por favor Señorita, says the man."
21+
params["content"] = language_data
2122
return api.language(params)
2223

2324

examples/matched-name.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,11 @@ def run(key, altUrl='https://api.rosette.com/rest/v1/'):
1515
# Create an API instance
1616
api = API(user_key=key, service_url=altUrl)
1717

18+
matched_name_data1 = "Michael Jackson"
19+
matched_name_data2 = "迈克尔·杰克逊"
1820
params = NameMatchingParameters()
19-
params["name1"] = {"text": "Michael Jackson", "language": "eng", "entityType": "PERSON"}
20-
params["name2"] = {"text": "迈克尔·杰克逊", "entityType": "PERSON"}
21+
params["name1"] = {"text": matched_name_data1, "language": "eng", "entityType": "PERSON"}
22+
params["name2"] = {"text": matched_name_data2, "entityType": "PERSON"}
2123
return api.matched_name(params)
2224

2325

examples/morphology_complete.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ def run(key, altUrl='https://api.rosette.com/rest/v1/'):
1515
# Create an API instance
1616
api = API(user_key=key, service_url=altUrl)
1717

18+
morphology_complete_data = "The quick brown fox jumped over the lazy dog. Yes he did."
1819
params = DocumentParameters()
19-
params["content"] = u"The quick brown fox jumped over the lazy dog. Yes he did."
20+
params["content"] = morphology_complete_data
2021
return api.morphology(params)
2122

2223

examples/morphology_compound-components.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ def run(key, altUrl='https://api.rosette.com/rest/v1/'):
1515
# Create an API instance
1616
api = API(user_key=key, service_url=altUrl)
1717

18+
morphology_compound_components_data = "Rechtsschutzversicherungsgesellschaften"
1819
params = DocumentParameters()
19-
params["content"] = u"Rechtsschutzversicherungsgesellschaften"
20+
params["content"] = morphology_compound_components_data
2021
return api.morphology(params, MorphologyOutput.COMPOUND_COMPONENTS)
2122

2223

examples/morphology_han-readings.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,9 @@ def run(key, altUrl='https://api.rosette.com/rest/v1/'):
1515
# Create an API instance
1616
api = API(user_key=key, service_url=altUrl)
1717

18+
morphology_han_readings_data = "北京大学生物系主任办公室内部会议"
1819
params = DocumentParameters()
19-
params["content"] = u"北京大学生物系主任办公室内部会议"
20+
params["content"] = morphology_han_readings_data
2021
return api.morphology(params, MorphologyOutput.HAN_READINGS)
2122

2223

0 commit comments

Comments
 (0)