def test_rank(self): a = topic.ngrams("i like cat on toast in the sunny morning".split(), 'en') b = topic.ngrams("i like dog on toast in the sunny morning dog dog dog".split(), 'en') + topic.ngrams( "i like dog on toast in the sunny morning".split(), 'en') data = dict( test_ngrams=a, offset_ngrams=b ) res = self.app.post('/topics/ranked?lang=en', data=data) assert json.loads(res.data) == rank_ok
def api_ngrams(): text = request.args['text'] lang = request.args['lang'] res = ngrams(text.split(), lang) return jsonify(ngrams = res)