stemmer-string-distance-ser.../api/resources/Jaccard.py

16 lines
401 B
Python
Raw Permalink Normal View History

2020-09-30 12:49:12 +00:00
import distance
from flask import request
from flask_restful import Resource
from stempel import StempelStemmer
stemmer = StempelStemmer.polimorf()
class JaccardResource(Resource):
def post(self):
request_json = request.get_json()
str1 = stemmer.stem(request_json['str1'])
str2 = stemmer.stem(request_json['str2'])
return {"dist": distance.jaccard(str1, str2)}