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

Extract variable-length MWE using a user-defined POS regex pattern. #65

Merged
merged 13 commits into from
Jun 26, 2023

Conversation

leobeeson
Copy link
Collaborator

Resolves #19 and closes #42

Problem

Currently, only two-word MWEs are supported by the MWE class.

Objective

Enable the extraction of higher-order Ngrams.

Results

  • Created class HigherOrderMWEExtractor with workhorse method extract_higher_order_mwes() for extracting variable length MWE given a user pattern of POS tags.
  • Wrote unit tests for validating class instantiation arguments. All are passing.
  • Wrote unit tests for validating extraction of variable-length MWE from user-defined POS patterns. All are passing.
  • Pre-commit hooks pass.

Considerations for Future Work

  • The class HigherOrderMWEExtractor was designed to be decoupled from the rest of the dataset; unlike the class MWE that is coupled with the entire corpus via its df attribute.
    • HigherOrderMWEExtractor operates atomically on a single sentence input and for a specific pattern for that input. This allows for vectorising using different patterns
  • We might want to refactor the class and method names, but must be done in conjunction with refactoring the name of the MWE class, as the latter is significantly broader than just a MWE. MWE could be renamed to MWEExtractor (although this is still too generic), and HigherOrderMWEExtractor could be renamed to VariableLengthMWEExtractor, POSPatternMWEExtractor, etc.
  • It would be good at some point to benchmark the efficiency of HigherOrderMWEExtractor.extract_higher_order_mwes() as it uses nltk.RegexpParser, i.e. uses regex pattern matching, which could have efficiency implications.
  • I can't run pre-commit hooks with language-version python3.9 (as I'm only using 3.10), but for some reason mypy would not let me run pre-commit hooks without also committing the .pre-commit-config.yaml. It feels like not committing this file should be whitelisted by mypy, but I could be wrong.

@leobeeson leobeeson requested a review from meghdadFar June 1, 2023 00:26
Copy link
Owner

@meghdadFar meghdadFar left a comment

Choose a reason for hiding this comment

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

Looks good but what do you think about renaming extract_higher_order_mwes because it returns MWE candidates (and their counts) for certain patterns? They are not exactly MWEs.

To extract valid MWEs, the calculate_am function should be first updated to be able to calculate AM scores for a variable length sequence and then it should be applied to MWE candidates returned by extract_higher_order_mwes.

We can upgrade calculate_am() in a different PR.

tests/mwe/test_mwe.py Outdated Show resolved Hide resolved
@meghdadFar meghdadFar merged commit ca55f44 into main Jun 26, 2023
3 checks passed
@meghdadFar meghdadFar deleted the higher-order-mwe branch July 19, 2023 14:23
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.

Enable User-Defined POS Pattern, Variable-Length MWE Candidate Generation Higher order MWEs
2 participants