示例#1
0
def test_parse_results_are_correct(s: str, positions: Optional[str],
                                   refs: Optional[List[Reference]],
                                   act_refs: Optional[List[str]]) -> None:
    parsed = GrammaticalAnalyzer().analyze(s, print_result=True)
    if refs is None:
        return
    parsed_refs = []
    parsed_act_refs = []
    parsed_pos_chars = [" "] * len(s)
    for reference in parsed.element_references:
        parsed_pos_chars[reference.start_pos] = '<'
        parsed_pos_chars[reference.end_pos - 1] = '>'
        parsed_refs.append(reference.reference)

    for reference in parsed.act_references:
        parsed_pos_chars[reference.start_pos] = '['
        parsed_pos_chars[reference.end_pos - 1] = ']'
        parsed_act_refs.append(reference.reference.act)

    parsed_pos_string = "".join(parsed_pos_chars)
    assert refs == parsed_refs
    assert act_refs == parsed_act_refs
    if positions is not None:
        assert positions == parsed_pos_string
示例#2
0
def test_text_amendment_parsing(s: str, correct_metadata: Tuple[Repeal, ...]) -> None:
    parsed = GrammaticalAnalyzer().analyze(s, print_result=True)
    parsed_metadata = parsed.semantic_data
    assert correct_metadata == parsed_metadata
示例#3
0
def test_enforcement_date_parsing(
        s: str, correct_metadata: Tuple[EnforcementDate, ...]) -> None:
    parsed = GrammaticalAnalyzer().analyze(s, print_result=True)
    parsed_metadata = parsed.semantic_data
    assert correct_metadata == parsed_metadata
示例#4
0
def test_new_abbreviations(s: str, abbrevs: List[ActIdAbbreviation]) -> None:
    parsed = GrammaticalAnalyzer().analyze(s, print_result=True)
    new_abbrevs = list(parsed.act_id_abbreviations)
    assert new_abbrevs == abbrevs
示例#5
0
def test_article_title_amendment_parsing(
        s: str, correct_metadata: Tuple[ArticleTitleAmendment, ...]) -> None:
    parsed = GrammaticalAnalyzer().analyze(s, print_result=True)
    parsed_metadata = parsed.semantic_data
    assert correct_metadata == parsed_metadata
示例#6
0
def test_block_amendment_parsing(s: str, correct_metadata: BlockAmendment) -> None:
    parsed = GrammaticalAnalyzer().analyze(s, print_result=True)
    parsed_metadata = parsed.semantic_data
    assert (correct_metadata, ) == parsed_metadata