-
Notifications
You must be signed in to change notification settings - Fork 38
Getting Started
Christopher Park edited this page Sep 8, 2017
·
4 revisions
You'll need a Rosette API key to start. Head to developer.rosette.com to start your 30-day trial of the Rosette API. Check out the documentation first, then find your API key in your developer portal and pass it in as a parameter every time your code opens an API connection.
The Python binding requires Python 2.6 or greater and is available through pip:
pip install rosette_api
# 1. Set utf-8 encoding.
# -*- coding: utf-8 -*-
# 2. Imports from rosette.api.
from rosette.api import API, DocumentParameters, RosetteException
# 3. Create API object.
api = API("[your_api-key]")
# 4. Create parameters object
params = DocumentParameters()
# 5. Set parameters.
params["content"] = "The quick brown fox jumped over the lazy dog. Yes he did."
# 6. Make a call.
result = api.morphology(params)
# result is a Python dictionary that contains
{u'tokens': [u'The', u'quick', u'brown', u'fox', u'jumped', u'over', u'the', u'lazy', u'dog', u'.', u'Yes', u'he', u'did', u'.'], u'posTags': [u'DET', u'ADJ', u'ADJ', u'NOUN', u'VERB', u'ADP', u'DET', u'ADJ', u'NOUN', u'PUNCT', u'VERB', u'PRON', u'VERB', u'PUNCT'], u'compoundComponents': [None, None, None, None, None, None, None, None, None, None, None, None, None, None], u'lemmas': [u'the', u'quick', u'brown', u'fox', u'jump', u'over', u'the', u'lazy', u'dog', u'.', u'yes', u'he', u'do', u'.'], u'hanReadings': [None, None, None, None, None, None, None, None, None, None, None, None, None, None]}