Skip to content

match()'s best_match and ignore_syntax arguments are never forwarded to the internal matcher - they have no effect #102

Description

@CyraxSector

Environment

  • quickumls==1.4.2 (pip)
  • Python 3.10
  • Index built with python -m quickumls.install -L -U -E ENG

Summary
QuickUMLS.match() accepts best_match and ignore_syntax parameters, but never passes them through to the internal _match() call:

def match(self, text, best_match=True, ignore_syntax=False):                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
      parsed = self.nlp(u'{}'.format(text))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
      matches = self._match(parsed)   # best_match, ignore_syntax are dropped here                                                                                                                                                                                                                                                                                                                                                                                                                                                       
      return matches 

_match() has its own defaults (best_match=True, ignore_syntax=False) and always runs with those, regardless of what was passed to match(). As a result, calling matcher.match(text, best_match=False) (or ignore_syntax=True) silently behaves identically to matcher.match(text) — the arguments have no effect.

Expected: matcher.match(text, best_match=False) returns all overlapping candidates, as documented.

Actual: it returns the same result as best_match=True, because the argument is never forwarded.

Suggested fix

def match(self, text, best_match=True, ignore_syntax=False):                                                                                                                                                                                                                                                                                                                                                                                                                                                                           
      parsed = self.nlp(u'{}'.format(text))                                                                                                                                                                                                                                                                                                                                                                                                                                                                                              
      matches = self._match(parsed, best_match=best_match, ignore_syntax=ignore_syntax)                                                                                                                                                                                                                                                                                                                                                                                                                                                  
      return matches

Workaround in the meantime: call matcher._match(doc, best_match=..., ignore_syntax=...) directly instead of the public match().

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions