-
Notifications
You must be signed in to change notification settings - Fork 37
Getting Started
lauren12292 edited this page Mar 29, 2016
·
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, MorphologyOutput
# 3. Create API object.
api = API("[your_api-key]")
# 4. Create parameters object
params = DocumentParameters()
# 5. Set parameters.
params["content"] = u""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
{
"tokens": [
"The",
"quick",
"brown",
"fox",
"jumped",
"over",
"the",
"lazy",
"dog",
".",
"Yes",
"he",
"did",
"."
],
"posTags": [
"DET",
"ADJ",
"ADJ",
"NOUN",
"VERB",
"ADP",
"DET",
"ADJ",
"NOUN",
"PUNCT",
"VERB",
"PRON",
"VERB",
"PUNCT"
],
"lemmas": [
"the",
"quick",
"brown",
"fox",
"jump",
"over",
"the",
"lazy",
"dog",
".",
"yes",
"he",
"do",
"."
],
"compoundComponents": [
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
],
"hanReadings": [
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null
]
}