Skip to content

Commit

Permalink
Check affix flags
Browse files Browse the repository at this point in the history
This is an oversight from porting spylls' `is_good_form` method. We need
to check that a prefix is allowed to be used on a stem by comparing the
Word's flag set against the affix's flag. This fixes lookups for
incorrect words like "undrink". It's a valid construction of a prefix
("un") with a word from the dic ("drink") but the "un" prefix is not
in "drink"'s flags, so it should be rejected.
  • Loading branch information
the-mikedavis committed Aug 23, 2023
1 parent 597cbc3 commit 4829482
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions src/checker.rs
Original file line number Diff line number Diff line change
Expand Up @@ -494,6 +494,17 @@ impl<'a> Checker<'a> {
}
}

if is_some_and(form.prefixes[0].as_ref(), |prefix| {
!all_flags.contains(&prefix.flag)
}) {
return false;
}
if is_some_and(form.suffixes[0].as_ref(), |suffix| {
!all_flags.contains(&suffix.flag)
}) {
return false;
}

if let Some(flag) = self.aff.circumfix_flag {
let has_suffix = is_some_and(form.suffixes[0].as_ref(), |suffix| {
suffix.flags.contains(&flag)
Expand Down

0 comments on commit 4829482

Please sign in to comment.