Skip to content

Instantly share code, notes, and snippets.

@ettorerizza
Created February 4, 2018 12:14
Show Gist options
  • Select an option

  • Save ettorerizza/8929b71e32df2ac91a917b5bf0a1ba6a to your computer and use it in GitHub Desktop.

Select an option

Save ettorerizza/8929b71e32df2ac91a917b5bf0a1ba6a to your computer and use it in GitHub Desktop.
rosette api test
from rosette.api import API, DocumentParameters, RosetteException
def rosette(text):
""" Run the example """
# Create an API instance
api = API(user_key="YOUR_KEY",
service_url="https://api.rosette.com/rest/v1/")
params = DocumentParameters()
params["content"] = text
params["genre"] = "social-media"
liste = []
try:
result = api.entities(params)
for i in result['entities']:
liste.append(i['type'] + "||" +
i['normalized'] + "||" + i['mention'])
return liste
except RosetteException as exception:
print(exception)
if __name__ == '__main__':
text = """Voici le bourgmestre de Morlanwelz, Charles-Ferdinand Dupont"""
test = rosette(text)
print(test)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment