Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(single_char_filter): add char_only filter #891

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

ksqsf
Copy link
Member

@ksqsf ksqsf commented Jun 10, 2024

Pull request

Issue tracker

Fixes will automatically close the related issue

Fixes #

Feature

Describe feature of pull request

Allow single_char_filter to keep only char candidates. Also allow toggling the filter with an option.

engine:
  filters:
    - single_char_filter
single_char_filter:
  type: char_only  # char_only | char_first
  option_name: single_char

Unit test

  • Done

Manual test

  • Done

Code Review

  1. Unit and manual test pass
  2. GitHub Action CI pass
  3. At least one contributor reviews and votes
  4. Can be merged clean without conflicts
  5. PR will be merged by rebase upstream base

Additional Info


SingleCharOnlyTranslation::SingleCharOnlyTranslation(
an<Translation> translation)
: translation_(translation) {}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The library expects a Translation to be ready to query with Peek() or exhausted() in its initial state.
Not only in Next(), but also in the constructor, we need to locate the next available single-char candidate and set exhausted_ depending on whether there is any single-char candidate available. Usually I extract a function from Next and call it in both places.

The interface will be improved in r2ime. Migrating the class to C++ iterator seems to be a large change.

Copy link
Member Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

should be fixed. PTAL

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants