Beispiel #1
0
def parse_all(user_input: str, culture: str) -> List[ModelResult]:
    return [
        # Number recognizer - This function will find any number from the input
        # E.g "I have two apples" will return "2".
        Recognizers.recognize_number(user_input, culture),

        # Ordinal number recognizer - This function will find any ordinal number
        # E.g "eleventh" will return "11".
        Recognizers.recognize_ordinal(user_input, culture),

        # Percentage recognizer - This function will find any number presented as percentage
        # E.g "one hundred percents" will return "100%"
        Recognizers.recognize_percentage(user_input, culture),

        # Age recognizer - This function will find any age number presented
        # E.g "After ninety five years of age, perspectives change" will return "95 Year"
        Recognizers.recognize_age(user_input, culture),

        # Currency recognizer - This function will find any currency presented
        # E.g "Interest expense in the 1988 third quarter was $ 75.3 million" will return "75300000 Dollar"
        Recognizers.recognize_currency(user_input, culture),

        # Dimension recognizer - This function will find any dimension presented
        # E.g "The six-mile trip to my airport hotel that had taken 20 minutes earlier in the day took more than three hours." will return "6 Mile"
        Recognizers.recognize_dimension(user_input, culture),

        # Temperature recognizer - This function will find any temperature presented
        # E.g "Set the temperature to 30 degrees celsius" will return "30 C"
        Recognizers.recognize_temperature(user_input, culture),

        # DateTime recognizer - This function will find any Date even if its write in colloquial language -
        # E.g "I'll go back 8pm today" will return "2017-10-04 20:00:00"
        Recognizers.recognize_datetime(user_input, culture)
    ]
def retrieve_punctuality(raw_value):
    p_result = Recognizers.recognize_percentage(raw_value, Culture.Chinese)
    if len(p_result) == 0:
        f_result = Recognizers.recognize_number(raw_value, Culture.Chinese)
        if len(f_result) == 0:
            return 0.0
        return float(f_result[0].resolution['value'])

    return float(p_result[0].resolution['value'].rstrip('%')) / 100
    def _parse_all_entities(user_input: str,
                            culture: str) -> List[Dict[Text, Any]]:
        """
        This is the main method that does the entity extraction work.

        For more details: https://github.com/Microsoft/Recognizers-Text/tree/master/Python#api-documentation
        """

        return [
            # Number recognizer - This function will find any number from the input
            # E.g "I have two apples" will return "2".
            Recognizers.recognize_number(user_input, culture),

            # Ordinal number recognizer - This function will find any ordinal number
            # E.g "eleventh" will return "11".
            Recognizers.recognize_ordinal(user_input, culture),

            # Percentage recognizer - This function will find any number presented as percentage
            # E.g "one hundred percents" will return "100%"
            Recognizers.recognize_percentage(user_input, culture),

            # Age recognizer - This function will find any age number presented
            # E.g "After ninety five years of age, perspectives change" will return
            # "95 Year"
            Recognizers.recognize_age(user_input, culture),

            # Currency recognizer - This function will find any currency presented
            # E.g "Interest expense in the 1988 third quarter was $ 75.3 million"
            # will return "75300000 Dollar"
            Recognizers.recognize_currency(user_input, culture),

            # Temperature recognizer - This function will find any temperature presented
            # E.g "Set the temperature to 30 degrees celsius" will return "30 C"
            Recognizers.recognize_temperature(user_input, culture),

            # DateTime recognizer - This function will find any Date even if its write in colloquial language -
            # E.g "I'll go back 8pm today" will return "2017-10-04 20:00:00"
            Recognizers.recognize_datetime(user_input, culture),

            # PhoneNumber recognizer will find any phone number presented
            # E.g "My phone number is ( 19 ) 38294427."
            Recognizers.recognize_phone_number(user_input, culture),

            # Email recognizer will find any phone number presented
            # E.g "Please write to me at [email protected] for more information on task
            # #A1"
            Recognizers.recognize_email(user_input, culture),
        ]
Beispiel #4
0
 def parse_all(user_input: str, culture: str):
     return [
         recognizers_suite.recognize_number(user_input, culture),
         recognizers_suite.recognize_dimension(user_input, culture),
     ]