Created
February 4, 2018 12:14
-
-
Save ettorerizza/8929b71e32df2ac91a917b5bf0a1ba6a to your computer and use it in GitHub Desktop.
rosette api test
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| 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