craigtrim / fast-parse-time

A fast and efficient English NLP Parser for Time References in Textg
1 stars 0 forks source link

Change API and Create Method to Classify any presence of a Date #1

Open craigtrim opened 5 months ago

craigtrim commented 5 months ago

The current API needs to be changed

#!/usr/bin/env python
# -*- coding: UTF-8 -*-
""" Analyze Time References in Text """

from datetime import datetime

class Singleton(object):

    __analyze = None
    __resolve = None

    def resolve(self) -> object:
        if not self.__resolve:
            from fast_parse_time.svc import ResolveTimeReferences
            self.__resolve = ResolveTimeReferences().process
        return self.__resolve

    def analyze(self) -> object:
        if not self.__analyze:
            from fast_parse_time.svc import AnalyzeTimeReferences
            self.__analyze = AnalyzeTimeReferences().process
        return self.__analyze

s = Singleton()

def transform(input_text: str) -> str:
    current_time = datetime.now()

    d_result = s.analyze()(input_text)
    solutions = d_result['result']

    if solutions and len(solutions):
        return s.resolve()(
            solutions=solutions,
            current_time=current_time)

I want a traditional API with well documented methods and proper test cases.

craigtrim commented 5 months ago

I like the notion of returning a slot with frames, but this requires a well-documented dataclass.

craigtrim commented 5 months ago

Pre Classify Explicit Dates

determines if a string of text might contain an explicit date. returning True is not a guarantee that an explicit date exists but it is a useful tool for determining if it's worth the computational cost of performing full tokenization and parsing of the sentence