예제 #1
0
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    params = DocumentParameters()
    params["content"] = u"The quick brown fox jumped over the lazy dog. Yes he did."
    return api.morphology(params)
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    params = DocumentParameters()
    params["content"] = u"Rechtsschutzversicherungsgesellschaften"
    return api.morphology(params, MorphologyOutput.COMPOUND_COMPONENTS)
예제 #3
0
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    params = DocumentParameters()
    params["content"] = u"The fact is that the geese just went back to get a rest and I'm not banking on their return soon"
    return api.morphology(params, MorphologyOutput.PARTS_OF_SPEECH)
예제 #4
0
파일: tt.py 프로젝트: OmkarB/pecan
def run(input, key=user_key, alt_url=ros_url):
    api = API(user_key=key, service_url=alt_url)
    content = ''.join(ch.lower() for ch in input if ch not in set(string.punctuation))
    params = DocumentParameters()
    params["content"] = content
    params["language"] = "eng"
    return api.morphology(params, MorphologyOutput.LEMMAS)
예제 #5
0
파일: tt.py 프로젝트: OmkarB/pecan
def proper_noun(key_word, key=user_key, alt_url=ros_url):
    api = API(user_key=key, service_url=alt_url)
    params = DocumentParameters()
    params["content"] = key_word
    params["language"] = "eng"
    api = api.morphology(params, MorphologyOutput.PARTS_OF_SPEECH)
    return "PROP" in str(json.loads(json.dumps(api, indent=2, ensure_ascii=False)))
예제 #6
0
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    params = DocumentParameters()
    params["content"] = u"北京大学生物系主任办公室内部会议"
    return api.morphology(params, MorphologyOutput.HAN_READINGS)
예제 #7
0
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    morphology_compound_components_data = "Rechtsschutzversicherungsgesellschaften"
    params = DocumentParameters()
    params["content"] = morphology_compound_components_data
    return api.morphology(params, MorphologyOutput.COMPOUND_COMPONENTS)
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    morphology_complete_data = "The quick brown fox jumped over the lazy dog. Yes he did."
    params = DocumentParameters()
    params["content"] = morphology_complete_data
    return api.morphology(params)
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    morphology_han_readings_data = "北京大学生物系主任办公室内部会议"
    params = DocumentParameters()
    params["content"] = morphology_han_readings_data
    return api.morphology(params, MorphologyOutput.HAN_READINGS)
예제 #10
0
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    morphology_lemmas_data = "The fact is that the geese just went back to get a rest and I'm not banking on their return soon"
    params = DocumentParameters()
    params["content"] = morphology_lemmas_data
    return api.morphology(params, MorphologyOutput.LEMMAS)
예제 #11
0
파일: tt.py 프로젝트: OmkarB/pecan
def find_similar(key_word, key=user_key, alt_url=ros_url):
    api = API(user_key=key, service_url=alt_url)
    if len(key_word.split()) > 1:
        key_word = "_".join(key_word.split())
    params = DocumentParameters()
    params["content"] = key_word
    params["language"] = "eng"
    json_obj = json.loads(json.dumps(api.morphology(params, MorphologyOutput.LEMMAS),
                                     indent=2, ensure_ascii=False))
    return search_for(json_obj['lemmas'][0]['lemma'])
예제 #12
0
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    morphology_parts_of_speech_data = "The fact is that the geese just went back to get a rest and I'm not banking on their return soon"
    params = DocumentParameters()
    params["content"] = morphology_parts_of_speech_data
    try:
        return api.morphology(params, MorphologyOutput.PARTS_OF_SPEECH)
    except RosetteException as e:
        print(e)
예제 #13
0
def run(key, altUrl='https://api.rosette.com/rest/v1/'):
    # Create an API instance
    api = API(user_key=key, service_url=altUrl)

    morphology_han_readings_data = "北京大学生物系主任办公室内部会议"
    params = DocumentParameters()
    params["content"] = morphology_han_readings_data
    try:
        return api.morphology(params, api.morphology_output['HAN_READINGS'])
    except RosetteException as e:
        print(e)
def run(key, alt_url='https://api.rosette.com/rest/v1/'):
    """ Run the example """
    # Create an API instance
    api = API(user_key=key, service_url=alt_url)

    morphology_complete_data = "The quick brown fox jumped over the lazy dog. Yes he did."
    params = DocumentParameters()
    params["content"] = morphology_complete_data
    try:
        return api.morphology(params)
    except RosetteException as exception:
        print(exception)
예제 #15
0
def run(key, alt_url='https://api.rosette.com/rest/v1/'):
    """ Run the example """
    # Create an API instance
    api = API(user_key=key, service_url=alt_url)

    morphology_lemmas_data = "The fact is that the geese just went back to get a rest and I'm not banking on their return soon"
    params = DocumentParameters()
    params["content"] = morphology_lemmas_data
    try:
        return api.morphology(params, api.morphology_output['LEMMAS'])
    except RosetteException as exception:
        print(exception)
def run(key, alt_url='https://api.rosette.com/rest/v1/'):
    """ Run the example """
    # Create an API instance
    api = API(user_key=key, service_url=alt_url)

    morphology_compound_components_data = "Rechtsschutzversicherungsgesellschaften"
    params = DocumentParameters()
    params["content"] = morphology_compound_components_data
    try:
        return api.morphology(params,
                              api.morphology_output['COMPOUND_COMPONENTS'])
    except RosetteException as exception:
        print(exception)
예제 #17
0
def send_request_to_rosette(word_list=None):
    api = API(user_key='d710f6b45bc1a291f43cd3310312160b')

    if not word_list:
        respone = api.ping()
    else:
        params = DocumentParameters()
        params['language'] = 'ara'
        params['content'] = word_list
        try:
            respone = api.morphology(params, api.morphology_output['LEMMAS'])
        except RosetteException as e:
            respone = None
            print(e)

    return respone
예제 #18
0
def lemmatize(lemma_data, key='c573c91d6f074690b5bb6af453fed596'):
    print "lemmas"
    api = API(user_key=key)
    params = DocumentParameters()
    params["content"] = lemma_data
    results = api.morphology(params, MorphologyOutput.LEMMAS)
    ans = json.dumps(results, indent=2, ensure_ascii=False,
                     sort_keys=True).encode('utf-8').decode('utf-8')
    ans_json = json.loads(ans)
    print "lemmas finished"
    tokens = ans_json['tokens']
    lemmas = ans_json['lemmas']
    for i in range(len(tokens)):
        if lemmas[i] is None:
            lemmas[i] = tokens[i]
    return tokens, lemmas
예제 #19
0
def run(key, alt_url='https://api.rosette.com/rest/v1/'):
    """ Run the example """
    # Create an API instance
    api = API(user_key=key, service_url=alt_url)
    # Set selected API options.
    # For more information on the functionality of these
    # and other available options, see Rosette Features & Functions
    # https://developer.rosette.com/features-and-functions#morphological-analysis-introduction

    # api.set_option('modelType','perceptron') #Valid for Chinese and Japanese only

    morphology_han_readings_data = "北京大学生物系主任办公室内部会议"
    params = DocumentParameters()
    params["content"] = morphology_han_readings_data
    try:
        return api.morphology(params, api.morphology_output['HAN_READINGS'])
    except RosetteException as exception:
        print(exception)
def run(key, alt_url='https://api.rosette.com/rest/v1/'):
    """ Run the example """
    # Create an API instance
    api = API(user_key=key, service_url=alt_url)

    # Set selected API options.
    # For more information on the functionality of these
    # and other available options, see Rosette Features & Functions
    # https://developer.rosette.com/features-and-functions#morphological-analysis-introduction

    # api.set_option('modelType','perceptron') # Valid for Chinese and Japanese only

    morphology_parts_of_speech_data = "The fact is that the geese just went back to get a rest and I'm not banking on their return soon"
    params = DocumentParameters()
    params["content"] = morphology_parts_of_speech_data
    try:
        return api.morphology(params, api.morphology_output['PARTS_OF_SPEECH'])
    except RosetteException as exception:
        print(exception)
예제 #21
0
def run(key, alt_url='https://api.rosette.com/rest/v1/'):
    """ Run the example """
    # Create an API instance
    api = API(user_key=key, service_url=alt_url)

    # Set selected API options.
    # For more information on the functionality of these
    # and other available options, see Rosette Features & Functions
    # https://developer.rosette.com/features-and-functions#morphological-analysis-introduction

    # api.set_option('modelType','perceptron') #Valid for Chinese and Japanese only

    morphology_complete_data = "The quick brown fox jumped over the lazy dog. 👍🏾 Yes he did. B)"
    params = DocumentParameters()
    params["content"] = morphology_complete_data
    try:
        return api.morphology(params)
    except RosetteException as exception:
        print(exception)
def run(key, alt_url='https://api.rosette.com/rest/v1/'):
    """ Run the example """
    # Create an API instance
    api = API(user_key=key, service_url=alt_url)

    # Set selected API options.
    # For more information on the functionality of these
    # and other available options, see Rosette Features & Functions
    # https://developer.rosette.com/features-and-functions#morphological-analysis-introduction

    # api.set_option('modelType','perceptron') #Valid for Chinese and Japanese only

    morphology_compound_components_data = "Rechtsschutzversicherungsgesellschaften"
    params = DocumentParameters()
    params["content"] = morphology_compound_components_data
    try:
        return api.morphology(params,
                              api.morphology_output['COMPOUND_COMPONENTS'])
    except RosetteException as exception:
        print(exception)
# -*- coding: utf-8 -*-

"""
Example code to call Rosette API to get de-compounded words from a piece of text.
"""

import argparse
import pprint

from rosette.api import API, DocumentParameters, MorphologyOutput

parser = argparse.ArgumentParser(description="Get de-compounded words from a piece of text")
parser.add_argument("--key", required=True, help="Rosette API key")
parser.add_argument("--service_url", nargs="?", help="Optional user service URL")
args = parser.parse_args()

# Create an API instance
if args.service_url:
    api = API(service_url=args.service_url, user_key=args.key)
else:
    api = API(user_key=args.key)

params = DocumentParameters()
params["content"] = u"Rechtsschutzversicherungsgesellschaften"
result = api.morphology(params, MorphologyOutput.COMPOUND_COMPONENTS)

pprint.pprint(result)
# -*- coding: utf-8 -*-

"""
Example code to call Rosette API to get Chinese readings of words in a piece of text.
"""

import argparse
import pprint

from rosette.api import API, DocumentParameters, MorphologyOutput

parser = argparse.ArgumentParser(description="Get Chinese readings of words in a piece of text")
parser.add_argument("--key", required=True, help="Rosette API key")
parser.add_argument("--service_url", nargs="?", help="Optional user service URL")
args = parser.parse_args()

# Create an API instance
if args.service_url:
    api = API(service_url=args.service_url, user_key=args.key)
else:
    api = API(user_key=args.key)

params = DocumentParameters()
params["content"] = u"北京大学生物系主任办公室内部会议"
result = api.morphology(params, MorphologyOutput.HAN_READINGS)

pprint.pprint(result)
예제 #25
0
# -*- coding: utf-8 -*-

"""
Example code to call Rosette API to get lemmas for words in a piece of text.
"""

import argparse
import pprint

from rosette.api import API, DocumentParameters, MorphologyOutput

parser = argparse.ArgumentParser(description="Get lemmas for words in a piece of text")
parser.add_argument("--key", required=True, help="Rosette API key")
parser.add_argument("--service_url", nargs="?", help="Optional user service URL")
args = parser.parse_args()

# Create an API instance
if args.service_url:
    api = API(service_url=args.service_url, user_key=args.key)
else:
    api = API(user_key=args.key)

params = DocumentParameters()
params["content"] = u"The fact is that the geese just went back to get a rest and I'm not banking on their return soon"
result = api.morphology(params, MorphologyOutput.LEMMAS)

pprint.pprint(result)
예제 #26
0
# -*- coding: utf-8 -*-

"""
Example code to call Rosette API to get the complete morphological analysis of a piece of text.
"""

import argparse
import pprint

from rosette.api import API, DocumentParameters

parser = argparse.ArgumentParser(description="Get the complete morphological analysis of a piece of text")
parser.add_argument("--key", required=True, help="Rosette API key")
parser.add_argument("--service_url", nargs="?", help="Optional user service URL")
args = parser.parse_args()

# Create an API instance
if args.service_url:
    api = API(service_url=args.service_url, user_key=args.key)
else:
    api = API(user_key=args.key)

params = DocumentParameters()
params["content"] = u"The quick brown fox jumped over the lazy dog. Yes he did."
result = api.morphology(params)

pprint.pprint(result)