<commit_before>from flask import Flask, jsonify
app = Flask(__name__)

@app.route("/")
def hello():
    return jsonify({'yo': 'face'})<commit_msg>Mock annotation endpoint<commit_after>import json

from flask import Flask, jsonify, request
app = Flask(__name__)


VERB_TOKENS = frozenset(['am', 'eat'])
ADJ_TOKENS = frozenset(['funny', 'yellow'])


@app.route('/')
def hello():
    return jsonify({'yo': 'face'})


@app.route('/annotation/', methods=['POST'])
def annotation():
	"""
	Takes in an object representing a sentence and returns annotations for the words in that
	sentence.
	"""
	sentence = json.loads(request.data)
	sentence['errorMsg'] = None
	sentence['isError'] = False

	for word in sentence['words']:
		if word['text'] in VERB_TOKENS:
			word['annotation'] = 'verb'
		elif word['text'] in ADJ_TOKENS:
			word['annotation'] = 'adj'
		else:
			word['annotation'] = None

		if word['text'] == 'cance':
			sentence['errorMsg'] = 'i said no cance'
			sentence['isError']	= True

	if not sentence['isError'] and sentence['words'] and \
			sentence['words'][-1]['text'].endswith('.'):
		sentence['isComplete'] = True
	else:
		sentence['isComplete'] = False

	return jsonify(sentence)

{'fraction_non_alphanumeric': 0.174496644295302, 'fraction_numerical': 0.0008389261744966443, 'mean_word_length': 4.994974874371859, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '7622312', 'n_tokens_mistral': 437, 'n_tokens_neox': 392, 'n_words': 105}