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

[BUG] join queries fail when combining metadata filters and odinson queries with exact range quantifiers #394

Open
myedibleenso opened this issue Feb 17, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@myedibleenso
Copy link
Member

myedibleenso commented Feb 17, 2024

When used in conjunction with a metadata filter (parent query), a pattern (Odinson query) with an exact range quantifier (>=2) will fail to match.

import ai.lum.odinson.test.utils.OdinsonTest

val ot = new OdinsonTest()

// metadata":[{"$type":"ai.lum.odinson.TokensField","name":"doc_id","tokens":["step-bros"]}]
// "John", "C.", "Reilly", "played", ...
val ee = ot.mkExtractorEngine("step-bros")

val pattern = "[lemma=play] >nsubj [tag=NNP]{,3}"
val mf = "doc_id == 'step-bros'"
val oq = ee.mkFilteredQuery(query = pattern, metadataFilter = mf)

val res = ee.query(oq)

// both of these unexpectedly fail
numMatches(res) == 1
existsMatchWithSpan(odinResults = res, doc = 0, start = 0, end = 3) == 1

Associated unit tests (ghp/join-query-bug branch)

  • it should "match events referencing existing mentions when an in-memory state is used along with a metadataFilter" in {
    val ee = extractorEngineWithSpecificState(getDocument("step-bros"), "memory")
    val grammar = """
    metadataFilters: doc_id == 'step-bros'
    rules:
    - name: person-rule
    type: basic
    priority: 1
    label: Person
    pattern: |
    [tag=NNP]{3}
    - name: state-based-rule
    type: event
    label: EventBasedPersonRule
    priority: 2
    pattern: |
    trigger = [lemma=play]
    # NOTE: ending with @Person won't work
    arg: Person = >nsubj
    """
    val extractors = ee.compileRuleString(grammar).toVector
    val mentions = ee.extractMentions(
    extractors = extractors,
    allowTriggerOverlaps = false,
    disableMatchSelector = false
    ).toVector
    getMentionsWithLabel(mentions, "EventBasedPersonRule") should have size (1)
    }
  • it should "match simple patterns with exact range quantifiers (>=2) and a metadata filter" in {
    // create in-memory engine w/ a single doc w/ a single sentence
    val ee = mkExtractorEngine("step-bros")
    // "John", "C.", "Reilly", "played" ...
    val pattern = "[lemma=play] >nsubj [tag=NNP]{3}"
    val mf = "doc_id == 'step-bros'"
    val oq = ee.mkFilteredQuery(query = pattern, metadataFilter = mf)
    val res = ee.query(oq)
    numMatches(res) should be (1)
    existsMatchWithSpan(odinResults = res, doc = 0, start = 0, end = 3) should be (true)
    }
@myedibleenso myedibleenso added the bug Something isn't working label Feb 17, 2024
@myedibleenso myedibleenso changed the title bug when combining metadata filters and odinson queries [BUG] join queries fail when combining metadata filters and odinson queries with exact range quantifiers Feb 17, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant