Skip to content
Snippets Groups Projects
Commit fcf19b28 authored by ilor's avatar ilor
Browse files

Use WCCLFile parsing in data-droven tag rule and match rule tests

parent 85e9f1fe
Branches
No related merge requests found
Showing
with 45 additions and 15 deletions
......@@ -165,29 +165,21 @@ void test_one_rule_item_actual(const rule_compare_test& c)
std::ifstream is(rf.c_str());
BOOST_REQUIRE(is.good());
boost::shared_ptr<Wccl::WcclFile> parsed;
parsed = parser.parseWcclFile(is, LIBWCCL_TEST_DATA_DIR);
boost::shared_ptr<Wccl::TagRuleSequence> rules;
boost::shared_ptr<Wccl::MatchRule> matchr;
std::string fn = c.rule_file.filename();
if (fn.find("match") == fn.npos) {
rules = parser.parseTagRuleSequence(is);
} else {
matchr = parser.parseMatchRule(is);
}
for (size_t i = 0; i < chunk->sentences().size(); ++i) {
Corpus2::Sentence::Ptr sentence = chunk->sentences()[i]->clone_shared();
Corpus2::Sentence::Ptr expected_sentence = expected->sentences()[i];
BOOST_REQUIRE_EQUAL(sentence->size(), expected_sentence->size());
if (rules) {
rules->execute_once(sentence);
} else if (matchr) {
if (parsed->has_tag_rules()) {
parsed->get_tag_rules_ptr()->execute_once(sentence);
}
if (parsed->has_match_rules()) {
boost::shared_ptr<Corpus2::AnnotatedSentence> annotated;
annotated = boost::dynamic_pointer_cast<Corpus2::AnnotatedSentence>(sentence);
BOOST_REQUIRE(annotated);
matchr->apply(annotated);
} else {
BOOST_ERROR("Dark forces");
parsed->get_match_rules_ptr()->apply_all(annotated);
}
check_sentences(i, tagset, sentence, expected_sentence);
}
......
match_rules(
apply
(
match
......@@ -11,3 +12,4 @@ apply
mark(M, M, :2, "NP")
)
)
)
match_rules(
apply(
match(
is('N_NOM')
......@@ -6,3 +7,4 @@ apply(
mark(M, 'COPY')
)
)
)
match_rules(
apply(
match(
regex( base[0], 'wyżyna' ),
......@@ -14,3 +15,4 @@ apply(
)
)
)
match_rules(
apply(
......@@ -13,3 +14,4 @@ apply(
)
)
)
match_rules(
apply(
match(
is( 'city_trigger' ),
......@@ -10,3 +11,4 @@ apply(
mark(:2, 'CITY_NAM')
)
)
)
match_rules(
apply(
match(
inter( base[0], 'wyżyna' ),
......@@ -12,3 +13,4 @@ apply(
mark(:2, 'Highland')
)
)
)
match_rules(
apply(
match(
inter( base[0], 'wyżyna' ),
......@@ -12,3 +13,4 @@ apply(
mark(:2, 'Highland')
)
)
)
match_rules(
apply(
match(
is("A")
......@@ -9,3 +10,4 @@ apply(
mark(M, "C")
)
)
)
match_rules(
apply(
match(
is("B")
......@@ -9,3 +10,4 @@ apply(
mark(M, "C")
)
)
)
match_rules(
apply(
match(repeat(equal(class[0], adj))),
cond(ann(M, "B")),
actions(mark(M,"C"))
)
)
match_rules(
apply(
match(repeat(equal(class[0], adj))),
cond(annsub(M, "B")),
actions(mark(M,"C"))
)
)
match_rules(
apply(
match(
repeat(
......@@ -12,3 +13,4 @@ apply(
//cond(debug(orth[first(M)])),
actions(mark(M,"C"))
)
)
match_rules(
apply(
match(
optional(repeat(inter(class[0], {adj}))),
......@@ -10,3 +11,4 @@ apply(
mark(M, "NP")
)
)
)
match_rules(
apply(
match(
optional(repeat(inter(class[0], {adj}))),
......@@ -10,3 +11,4 @@ apply(
mark(M, "NP")
)
)
)
match_rules(
apply(
match(
optional(repeat(inter(class[0], {adj, pact, ppas}))),
......@@ -7,3 +8,4 @@ apply(
mark(M, 'NP')
)
)
)
match_rules(
apply(
match(
repeat(
......@@ -10,3 +11,4 @@ apply(
mark(M, 'MultiNP')
)
)
)
match_rules(
apply(
match(
and( inter(class[0], {subst, ger, depr}), inter(cas[0], {nom}) )
......@@ -6,3 +7,4 @@ apply(
mark($m:_M, 'N_NOM')
)
)
)
match_rules(
apply(
match(
text("Sp. z o.o.")
......@@ -6,3 +7,4 @@ apply(
mark(M, "Co")
)
)
)
match_rules(
apply(
match(
text("Sp."),
......@@ -10,3 +11,4 @@ apply(
mark(:3, "O")
)
)
)
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment