-
Notifications
You must be signed in to change notification settings - Fork 0
Api Documentation
Welcome to the Canworks wiki!
Args:
'text', type=to_unicode_or_bust, required=True, location="form"
'algorithm', type=str, required=True, location="form"
rightnow the algorithms that has been implemented are
logistic_regression_classifier
multinomial_nb_classifier
passive_aggressive_classifier
perceptron_classifier
ridge_regression_classifier
svm_classifier
ridge_regression_classifier
Errors:
if not bool(text):
return {
"error": True,
"success": False,
"error_code": 101,
"messege": "Text field cannot be left empty"
}
if not bool(algorithm):
return {
"error": True,
"success": False,
"error_code": 302,
"messege": "Algorithm field cannot be left empty"}
Result: return { "result": result, "success": True, "error": False, "overall_sentiment": '%.2f'%ProcessingWithBlob.new_blob_polarity(to_unicode_or_bust(text)), "noun_phrase": noun_phrase,}
Sample result:
with form arguments:
text = 'Went on a sunday afternoon for brunch with a few friends.. the food was good, the service was ok, but not as good as I expected from an international chain! Overall experiance was nice the ambiance was awesome, but I think it is more of an evening place, as even after strong airconditioning the sun was irritating the skin. Will love to go again during an afternoon.'
algorithm = "logistic_regression_classifier"
you will get the below mentioned result
{u'error': False,
u'noun_phrase': [u'sunday afternoon',
u'international chain',
u'overall experiance',
u'evening place'],
u'overall_sentiment': u'0.33',
u'result': [{u'customer_type': u'null',
u'noun_phrases': [u'sunday afternoon'],
u'polarity': {u'name': u'null', u'value': u'0.0'},
u'sentence': u'went on a sunday afternoon for brunch with a few friends ..',
u'tag': u'null'}, {u'customer_type': u'null', u'noun_phrases': [], u'polarity': {u'name': u'super-positive', u'value': u'0.0'}, u'sentence': u'the food was good , the service was ok ,', u'tag': u'food'}, {u'customer_type': u'null', u'noun_phrases': [u'international chain'], u'polarity': {u'name': u'negative', u'value': u'0.0'}, u'sentence': u'but not as good as i expected from an international chain !', u'tag': u'overall'}, {u'customer_type': u'null', u'noun_phrases': [u'overall experiance'], u'polarity': {u'name': u'super-positive', u'value': u'0.0'}, u'sentence': u'overall experiance was nice the ambiance was awesome ,', u'tag': u'overall'}, {u'customer_type': u'null', u'noun_phrases': [u'evening place'], u'polarity': {u'name': u'negative', u'value': u'0.0'}, u'sentence': u'but i think it is more of an evening place , as even after strong airconditioning the sun was irritating the skin .', u'tag': u'overall'}, {u'customer_type': u'null', u'noun_phrases': [], u'polarity': {u'name': u'super-positive', u'value': u'0.0'}, u'sentence': u'will love to go again during an afternoon .', u'tag': u'overall'}], u'success': True}
Args:
'sentence', type=to_unicode_or_bust, required=True, location="form"
'tag', type=str, required=True, location="form"
'review_id', type=str, required=True, location="form"
Errors:
if not os.path.exists(path):
return {"success": False,
"error": True,
"messege": "The tag {0} you mentioned doesnt exist in the learning model, ask admin to create this file".format(tag),
"error_code": 201,
Result: }
return {"success": True,
"error": False,
"messege": "The sentence --{0}-- with the changed tag --{1}-- with id --{2} has been uploaded".format(sentence, tag, review_id),
}
Args:
'sentence', type=to_unicode_or_bust, required=True, location="form"
'is_error', type=str, required=True, location="form"
'review_id', type=str, required=True, location="form"
'error_messege', type=str, required=True, location="form"
Errors:
if int(error) != 2:
return {"success": False,
"error": True,
"messege": "Only error sentences can be tagged, 'void' is an invalid tag",
"error_code": 207,
}
if not os.path.exists(path):
return {"success": False,
"error": True,
"messege": "some error occurred",
"error_code": 210,
}
Results:
return {"success": True,
"error": False,
"messege": "The sentence --{0}-- with the error messege --{1}-- with id --{2} has been uploaded".format(sentence, error_messege, review_id),
}
Args:
'sentence', type=str, required=True, location="form"
'is_error', type=str, required=True, location="form"
'review_id', type=str, required=True, location="form"
Errors:
if int(error) != 3:
return {"success": False,
"error": True,
"messege": "Only interjection sentences can be tagged, 'void' is an invalid tag",
"error_code": 207,}
if not os.path.exists(path):
return {"success": False,
"error": True,
"messege": "File doenst exists for interjection",
"error_code": 210,}
Results:
return {"success": True,
"error": False,
"messege": "The sentence --{0}-- with id --{1} has been uploaded for interjection erros".format(sentence, review_id),
}
Args:
'sentence', type=str, required=True, location="form"
'option_value', type=str, required=True, location="form"
'option_text', type=str, required=True, location="form"
'review_id', type=str, required=True, location="form"
Errors:
if int(option_value) != 2 and int(option_value) != 3:
return {"success": False,
"error": True,
"messege": "Only repeated customer or recommended customer sentences can be tagged, 'void' is an invalid tag",
"error_code": 206,}
if not os.path.exists(path):
return {"success": False,
"error": True,
"messege": "File for {0} doesnt exists in the backend, Please contact your asshole admin".format(option_text),
"error_code": 205,}
Results:
return {"success": True,
"error": False,
"messege": "The sentence --{0}-- with review id --{1} has been uploaded for {2}".format(sentence, review_id, option_text),
}
Args:
'city', type=str, required=True, location="form"
Results:
return {"success": False,
"error": True,
"result": result,
}
Args:
'eatery_id', type=str, required=True, location="form"
Results:
return {"success": False,
"error": True,
"result": result,
"classified_reviews": is_classified_reviews,
"unclassified_reviews": not_classified_reviews,
}
Args:
'review_id', type=str, required=True, location="form"
Errors:
if not reviews.find_one({'review_id': __id}):
return {"success": False,
"error": True,
"messege": "The review doesnt exists",
}
if reviews.find_one({'review_id': __id}).get("is_classified"):
return {"success": False,
"error": True,
"messege": "The reviews has already been marked classified, Please refresh the page",
}
Results:
return {"success": True,
"error": False,
"messege": "The reviews has been marked classified",
}
Args:
'review_id', type=str, required=True, location="form"
Errors:
if not reviews.find_one({'review_id': __id}):
return {"success": False,
"error": True,
"messege": "The review doesnt exists",
}
Results:
return {"success": True,
"error": False,
"result": result,
}
Args:
'sentence', type=str, required=True, location="form"
'grams', type=str, required=True, location="form"
Errors:
if not sentence:
return {"success": False,
"error": True,
"messege": "The text field cannot be left empty",
}
if not grams:
return {"success": False,
"error": True,
"messege": "The grams field cannot be left empty",
}
if grams == "void":
return {"success": False,
"error": True,
"messege": "The grams field cannot be equals to void",
}
Results:
return {"success": True,
"error": False,
"result": nltk_ngrams(sentence, grams),
}
Args:
'noun_phrase', type=str, required=True, location="form"
'review_id', type=str, required=True, location="form"
'sentence', type=str, required=True, location="form"
Errors:
if not reviews.find_one({'review_id': review_id}):
return {"success": False,
"error": True,
"messege": "The review doesnt exists",
}
if not noun_phrase:
return {"success": False,
"error": True,
"messege": "The Noun phrase field cannot be left empty",
}
Results:
return {"success": True,
"error": False,
"messege": "noun phrase --{0}-- for sentence --{1}-- with review id --<{2}>--has been uploaded".format(noun_phrase, sentence, review_id),
}
Args:
None,
Errors:
None,
Results:
return {"success": True,
"error": True,
"result": result,
}
Args:
'eatery_id', type=str, required=True, location="form"
Errors:
None
Results:
"success": True,
"error": True,
"result": {"start": "{0}-{1}-{2}".format(start_year, start_month, start_date),
"end": "{0}-{1}-{2}".format(end_year, end_month, end_date)},
}
Args:
'eatery_id', type=str, required=True, location="form"
'category', type=str, required=True, location="form"
'start_date', type=str, required=True, location="form"
'end_date', type=str, required=True, location="form"
Errors:
None
Results:
return {"success": True,
"error": True,
"result": result
}
Args:
'eatery_id', type=str, required=True, location="form"
'category', type=str, required=True, location="form"
'start_date', type=str, required=True, location="form"
'end_date', type=str, required=True, location="form"
Errors:
None,
Results:
return {"success": True,
"error": True,
"result": final_result[0:30],
}
Args:
'text', type=to_unicode_or_bust, required=True, location="form"
'sentences_with_classification', type=to_unicode_or_bust, required=True, location="form", action="append")
Errors:
None,
Results:
return{
"result": result,
"success": True,
"error": False,
}
Args:
None,
Errors:
None,
Results:
None,