def __NERrecognizer(self, text, kb): ''' Call NER tool. @text - input text for processing @kb - instance of loaded KB ''' return recognize(kb, text, False, False)
def handle_request(self, *flags, **kw): '''Deprecated''' txt = kw.get("text") kb = self.kbmanager.getKB("KBstatsMetrics") result = recognize(kb, txt.encode("utf-8"), False, False) rg = parse_result(result, kb, 'classic') return rg
def index(self, text): ''' Handling request for "/parser" @text - string contains data from ?=text http argument ''' txt = text print len(txt.encode('ascii','replace')) result = recognize(self.kb, txt.encode('ascii','replace'), False, False) rg = parse_result(result, self.kb, False) cherrypy.response.headers['Content-Type'] = "application/json" return json.dumps(rg)
def ner_api(): try: text = request.json['text'] #request içinden text alınıyor if type(text) == str: # eğer input str ise devam et output = recognize(text) # adlı varlıklar belirleniyor return jsonify({"output": output}) else: return jsonify({"error": "only string input, please"}) except: return jsonify( {"error": "Did you mean to send: {'text': 'some text'}"})
def call(self, input_data, asset, params ): kb = asset.getPart(self.assetPart) ner.dictionary=None data = ner.recognize(kb, input_data, False, False, False, params.get("lower", False), params.get("remove accent", False), params.get("name_recognize", False)) return data
def call(self, input_data, asset, params): kb = asset.getPart(self.assetPart) ner.dictionary=None data = ner.recognize(kb, input_data, False, False, False, params["lower"], params["remove accent"]) print data return data