Skip to content

Use each instrument's language for negation instead of always English (#142) - #143

Merged
woodthom2 merged 1 commit into
harmonydata:mainfrom
roshaneyshah:fix/negation-language-142
Oct 12, 2026
Merged

woodthom2 merged 1 commit into
harmonydata:mainfrom
roshaneyshah:fix/negation-language-142

Conversation

@roshaneyshah

Copy link
Copy Markdown
Contributor

Description

process_questions hardcoded negate(question_text, 'en'), so the pt, es, it, fr and de rules in negator.py never ran during matching. This maps each question text to its instrument's language field and passes it through, defaulting to "en". No language detection is run, so nothing is detected repeatedly on the same text.

Only matcher.py is changed, plus one new test file. No new dependencies.

Urdu negation rules will follow in a separate PR.

Fixes #142

Type of change

  • Bug fix (non-breaking change which fixes an issue)

Testing

Added tests/test_negation_language.py: checks that a Portuguese item is negated with Portuguese rules, and that the default stays English.

Ran locally: test_negation_language.py, test_negator.py, test_match_negative_polarity.py, 16 passed.

I have not yet run the Harmony API tests.

Test Configuration

  • Library version: 1.0.7
  • OS: Windows 11
  • Toolchain: Python 3.11, pytest 9.1.1

Checklist

  • My PR is for one issue, rather than for multiple unrelated fixes.
  • I have performed a self-review of my own code
  • I have added tests that prove my fix is effective or that my feature works
  • New and existing unit tests pass locally with my changes
  • I have checked my code and corrected any misspellings
  • I add third party dependencies only when necessary.

…harmonydata#142)

process_questions hardcoded negate(question_text, 'en'), so the pt, es,
it, fr and de rules in negator.py never ran during matching. Map each
question text to its instrument's language field and pass that through,
defaulting to "en". No language detection is run.
@woodthom2
woodthom2 merged commit 3bc436f into harmonydata:main Oct 12, 2026
2 checks passed
@woodthom2

Copy link
Copy Markdown
Contributor

Thanks so much!

Feel free to submit a PR with Urdu rules

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.

Negation always uses English rules, whatever the instrument language

2 participants