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

BioNLPProcessor.annotate fails when withRuleNER is set to false #781

Open
kwalcock opened this issue Feb 17, 2023 · 1 comment
Open

BioNLPProcessor.annotate fails when withRuleNER is set to false #781

kwalcock opened this issue Feb 17, 2023 · 1 comment

Comments

@kwalcock
Copy link
Member

This was an issue filed under processors, but I believe that BioNLPProcessor is part of reach in the meantime. The original issue is at clulab/processors#255. Part of the discussion is pasted below:

@MihaiSurdeanu, it seems that BioNLPProcessor.annotate now fails when withRuleNER is set to false, even if withCRFNER is set to true:

java.util.NoSuchElementException: None.get
  at scala.None$.get(Option.scala:347)
  at scala.None$.get(Option.scala:345)
  at org.clulab.processors.clu.bio.BioNERPostProcessor.process(BioNERPostProcessor.scala:23)
  at org.clulab.processors.bionlp.BioNLPProcessor$$anonfun$recognizeNamedEntities$1.apply(BioNLPProcessor.scala:59)
  at org.clulab.processors.bionlp.BioNLPProcessor$$anonfun$recognizeNamedEntities$1.apply(BioNLPProcessor.scala:58)
  at scala.collection.IndexedSeqOptimized$class.foreach(IndexedSeqOptimized.scala:33)
  at scala.collection.mutable.ArrayOps$ofRef.foreach(ArrayOps.scala:186)
  at org.clulab.processors.bionlp.BioNLPProcessor.recognizeNamedEntities(BioNLPProcessor.scala:58)
  at org.clulab.processors.Processor$class.annotate(Processor.scala:89)
  at org.clulab.processors.shallownlp.ShallowNLPProcessor.annotate(ShallowNLPProcessor.scala:29)
  at org.clulab.processors.Processor$class.annotate(Processor.scala:59)
  at org.clulab.processors.shallownlp.ShallowNLPProcessor.annotate(ShallowNLPProcessor.scala:29)

This is due to BioNERPostProcessor attempting to access the .entities attribute of each sentence it processes.

One option is to change recognizeNamedEntities:

  override def recognizeNamedEntities(doc:Document) {
    hybridNER.recognizeNamedEntities(doc, namedEntitySanityCheck(doc))

    for {
      sentence <- doc.sentences
      // only post-process if we have entities
      if sentence.entities.nonEmpty
    } { nerPostProcessor.process(sentence) }
  }

I think it would be better to handle it in BioNERPostProcessor.process instead, though.

@MihaiSurdeanu
Copy link
Contributor

I agree with the proposed solution. And also with the fact that it should be addressed in BioNLPProcessor.
Thanks!

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

No branches or pull requests

2 participants