Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
3 changes: 1 addition & 2 deletions examples/address_similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get match score (similarity) of two addresses.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -36,4 +35,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
Example code to call Rosette API to get the category of a document (at a given URL).
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -48,4 +47,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
5 changes: 2 additions & 3 deletions examples/entities.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get entities from a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand All @@ -27,7 +26,7 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
entities_text_data = "The Securities and Exchange Commission today announced the leadership of the agency’s trial unit. Bridget Fitzpatrick has been named Chief Litigation Counsel of the SEC and David Gottesman will continue to serve as the agency’s Deputy Chief Litigation Counsel. Since December 2016, Ms. Fitzpatrick and Mr. Gottesman have served as Co-Acting Chief Litigation Counsel. In that role, they were jointly responsible for supervising the trial unit at the agency’s Washington D.C. headquarters as well as coordinating with litigators in the SEC’s 11 regional offices around the country."
params = DocumentParameters()
params["content"] = entities_text_data
params["genre"] = "social-media"

try:
return api.entities(params)
except RosetteException as exception:
Expand All @@ -43,4 +42,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/info.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get information such as version and build
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -32,4 +31,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/language.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to determine the language of a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -36,4 +35,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/language_multilingual.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to determine the language of a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -38,4 +37,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/morphology_complete.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get the complete morphological analysis of a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/morphology_compound-components.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get de-compounded words from a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/morphology_han-readings.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get Chinese readings of words in a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -41,4 +40,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/morphology_lemmas.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get lemmas for words in a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/morphology_parts-of-speech.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get part-of-speech tags for words in a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/name_deduplication.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to deduplicate a list of names.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -37,4 +36,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/name_similarity.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get match score (similarity) of two names.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -37,4 +36,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/name_translation.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to translate a name from one language to another.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -38,4 +37,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/ping.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to send Rosette API a ping to check its reachability.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -32,4 +31,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/relationships.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get entities's relationships from a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -34,4 +33,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
4 changes: 1 addition & 3 deletions examples/semantic_vectors.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get text vectors from a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -42,5 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False,
sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/sentences.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get sentences in a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -36,4 +35,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
4 changes: 1 addition & 3 deletions examples/sentiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
"""
Example code to call Rosette API to get the sentiment of a local file.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -57,5 +56,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False,
sort_keys=True).encode("utf8"))
print(RESULT)
4 changes: 1 addition & 3 deletions examples/similar_terms.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get similar terms for an input.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -42,5 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False,
sort_keys=True).encode("utf8"))
print(RESULT)
4 changes: 1 addition & 3 deletions examples/syntax_dependencies.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get the syntactic dependencies of a document (at a given URL).
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -34,5 +33,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False,
sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/tokens.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get the tokens (words) in a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -42,4 +41,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
3 changes: 1 addition & 2 deletions examples/topics.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to get the topics (key phrases and concepts) in a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -43,4 +42,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False, sort_keys=True).encode("utf8"))
print(RESULT)
4 changes: 1 addition & 3 deletions examples/transliteration.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@
"""
Example code to call Rosette API to transliterate a piece of text.
"""
from __future__ import print_function

import argparse
import json
Expand Down Expand Up @@ -44,5 +43,4 @@ def run(key, alt_url='https://api.rosette.com/rest/v1/'):
if __name__ == '__main__':
ARGS = PARSER.parse_args()
RESULT = run(ARGS.key, ARGS.url)
print(json.dumps(RESULT, indent=2, ensure_ascii=False,
sort_keys=True).encode("utf8"))
print(RESULT)
7 changes: 4 additions & 3 deletions rosette/api.py
Original file line number Diff line number Diff line change
Expand Up @@ -153,12 +153,14 @@ class DocumentParameters(_DocumentParamSetBase):
def __init__(self):
"""Create a L{DocumentParameters} object."""
_DocumentParamSetBase.__init__(
self, ("content", "contentUri", "language", "genre", "profileId"))
self, ("content", "contentUri", "genre", "language", "profileId"))
self.file_name = ""
self.use_multipart = False

def validate(self):
"""Internal. Do not use."""
if self["genre"] is not None:
warnings.warn("genre is deprecated and will be removed in the next release.")
if self["content"] is None:
if self["contentUri"] is None:
raise RosetteException(
Expand Down Expand Up @@ -236,8 +238,7 @@ def __init__(self):
"sourceLanguageOfUse",
"sourceScript",
"targetScript",
"targetScheme",
"genre"))
"targetScheme"))

def validate(self):
"""Internal. Do not use."""
Expand Down