コード例 #1
0
    def delete(word):
        try:
            service = WordClassificationService()
            service.delete(word)

            return make_response({}, HTTPStatus.OK)
        # except ValueError as err:
        #    return jsonify('Word [' + word + '] not found: ' + repr(err)), HTTPStatus.NOT_FOUND
        except Exception as err:
            return jsonify('Internal server error: ' +
                           repr(err)), HTTPStatus.INTERNAL_SERVER_ERROR
コード例 #2
0
    def get(word):
        try:
            service = WordClassificationService()
            entity = service.find_one(word)

            if not entity:
                raise ValueError(
                    'WordClassificationService did not return a result')

            return jsonify({'word': word}), HTTPStatus.OK
        except ValueError as err:
            return jsonify('Word [' + word + '] not found: ' +
                           repr(err)), HTTPStatus.NOT_FOUND
        except Exception as err:
            return jsonify('Internal server error: ' +
                           repr(err)), HTTPStatus.INTERNAL_SERVER_ERROR
コード例 #3
0
    def __init__(self):
        self.synonym_service = SynonymService()
        self.word_classification_service = WordClassificationService()
        self.word_condition_service = VirtualWordConditionService()
        self.name_processing_service = NameProcessingService()

        self.builder = None
        self.token_classifier = None

        self.entity_type = None
コード例 #4
0
    def put(word):
        json_input = request.get_json()
        if not json_input:
            return jsonify('No input data provided'), HTTPStatus.BAD_REQUEST

        try:
            service = WordClassificationService()
            entity = service.create_or_update(json_input)

            if not entity:
                raise ValueError(
                    'WordClassificationService did not return a result')
            data = entity.json()
            return jsonify(data), HTTPStatus.OK
        except ValueError as err:
            return jsonify('Word [' + word + '] not found: ' +
                           repr(err)), HTTPStatus.NOT_FOUND
        except Exception as err:
            return jsonify('Internal server error: ' +
                           repr(err)), HTTPStatus.INTERNAL_SERVER_ERROR
コード例 #5
0
ファイル: name_processing.py プロジェクト: rarmitag/namex
 def __init__(self):
     self.synonym_service = SynonymService()
     self.word_classification_service = WordClassificationService()
     self.virtual_word_condition_service = VirtualWordConditionService()
     self.name_as_submitted = None
     self._name_first_part = None
     self.name_as_submitted_tokenized = None
     self.name_original_tokens = None
     self.processed_name = None
     self.name_tokens = None
     self.distinctive_word_tokens = None
     self.descriptive_word_tokens = None
     self.unclassified_word_tokens = None
コード例 #6
0
ファイル: word_classification.py プロジェクト: rarmitag/namex
    def put():
        response = None

        if request.is_json:
            try:
                service = WordClassificationService()
                # Execute analysis using the supplied builder
                entity = service.create_or_update(request.json)

                if not entity:
                    raise ValueError('WordClassificationService did not return a result')

                payload = jsonpickle.encode(entity)

                response = make_response(payload, HTTPStatus.OK)
            except Exception as error:
                print('Error: ' + repr(error))
                raise
        else:
            response = make_response(HTTPStatus.BAD_REQUEST)

        return response