<commit_before>package org.clulab.processors

import org.clulab.processors.bionlp.BioNLPProcessor
import org.scalatest._

/**
  * Tests BioNLPProcessor
  * User: mihais
  * Date: 10/29/14
  * Last Modified: Update for BE KBs.
  */
class TestBioNLPProcessor extends FlatSpec with Matchers {
  var proc:Processor = new BioNLPProcessor()

  "BioNLPProcessor" should "recognize correct NEs in text 1" in {
    val doc = proc.mkDocumentFromSentences(List(
      "Co-immunoprecipitation analysis confirmed that Bis interacted with Bcl-2 in vivo.",
      "The Ras protein is phosphorylated by TBRI."), keepText = false)

    annotate(doc)

    var i = 0
    for(s <- doc.sentences) {
      println(s"Labels for sentence #$i: " + s.entities.get.mkString(" "))
      i += 1
    }

    doc.sentences(0).entities.get(4) should be ("B-Gene_or_gene_product")
    doc.sentences(0).entities.get(7) should be ("B-Gene_or_gene_product")
    doc.sentences(0).entities.get(8) should be ("O")

    doc.sentences(1).entities.get(1) should be ("B-Family")
    doc.sentences(1).entities.get(2) should be ("O")
    doc.sentences(1).entities.get(6) should be ("B-Gene_or_gene_product")

  }

  it should "recognize correct NEs in text 2" in {
    val doc = proc.mkDocument(<commit_msg>Added 1 more unit test<commit_after>package org.clulab.processors

import org.clulab.processors.bionlp.BioNLPProcessor
import org.scalatest._

/**
  * Tests BioNLPProcessor
  * User: mihais
  * Date: 10/29/14
  * Last Modified: Update for BE KBs.
  */
class TestBioNLPProcessor extends FlatSpec with Matchers {
  var proc:Processor = new BioNLPProcessor()

  "BioNLPProcessor" should "recognize some tricky entity names" in {
    var doc = proc.mkDocument("We tested the level of neurofibromin present in the sample")
    annotate(doc)

    var es = doc.sentences(0).entities.get
    println(s"Tricky entities: ${es.mkString(", ")}")
    es(5) should be ("B-Gene_or_gene_product")

    doc = proc.mkDocument("XRCC1 stimulates DNA-PK enzymatic activity")
    annotate(doc)

    es = doc.sentences(0).entities.get
    println(s"Tricky entities: ${es.mkString(", ")}")
    es(0) should be ("B-Gene_or_gene_product")
    es(2) should be ("B-Gene_or_gene_product")
  }

  "BioNLPProcessor" should "recognize correct NEs in text 1" in {
    val doc = proc.mkDocumentFromSentences(List(
      "Co-immunoprecipitation analysis confirmed that Bis interacted with Bcl-2 in vivo.",
      "The Ras protein is phosphorylated by TBRI."), keepText = false)

    annotate(doc)

    var i = 0
    for(s <- doc.sentences) {
      println(s"Labels for sentence #$i: " + s.entities.get.mkString(" "))
      i += 1
    }

    doc.sentences(0).entities.get(4) should be ("B-Gene_or_gene_product")
    doc.sentences(0).entities.get(7) should be ("B-Gene_or_gene_product")
    doc.sentences(0).entities.get(8) should be ("O")

    doc.sentences(1).entities.get(1) should be ("B-Family")
    doc.sentences(1).entities.get(2) should be ("O")
    doc.sentences(1).entities.get(6) should be ("B-Gene_or_gene_product")

  }

  it should "recognize correct NEs in text 2" in {
    val doc = proc.mkDocument(
{'fraction_non_alphanumeric': 0.12687280841568377, 'fraction_numerical': 0.01689512272872171, 'mean_word_length': 3.6283185840707963, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '5326665', 'n_tokens_mistral': 1161, 'n_tokens_neox': 1076, 'n_words': 270}