예제 #1
0
def test_condition_sentence_parsing(
    condition_sentence_parser: ConditionSentenceParser,
    condition_sentence_data,
):
    condition_sentence, expected_results = condition_sentence_data
    components = list(condition_sentence_parser.parse(condition_sentence))
    assert len(expected_results) == len(components)
    for expected, actual in zip(expected_results, components):
        expected_condition, expected_component = expected
        actual_condition, actual_component = actual
        assert_attributes(expected_condition, actual_condition)
        assert_attributes(expected_component, actual_component)
예제 #2
0
 def __init__(
     self,
     workbasket: WorkBasket,
     base_date: date,
     defaults: Dict[str, Any] = {},
     duty_sentence_parser: DutySentenceParser = None,
     condition_sentence_parser: ConditionSentenceParser = None,
 ) -> None:
     self.workbasket = workbasket
     self.defaults = defaults
     self.duty_sentence_parser = duty_sentence_parser or DutySentenceParser.get(
         base_date, )
     self.condition_sentence_parser = (condition_sentence_parser
                                       or ConditionSentenceParser.get(
                                           base_date, ))
예제 #3
0
def condition_sentence_parser(
    duty_expressions,
    monetary_units,
    measurements,
    condition_codes,
    action_codes,
) -> ConditionSentenceParser:
    return ConditionSentenceParser(
        duty_expressions.values(),
        monetary_units.values(),
        measurements.values(),
        condition_codes.values(),
        action_codes.values(),
        2.00,
    )