Skip to content
markfarrell edited this page Oct 10, 2014 · 3 revisions

Help us define more patterns for extracting knowledge!

Suppose we can't extract knowledge from the following sentence:

scala> Compile(Parse("This possibility has been explored in two contexts: axon regeneration
and endogenous neural precursor recruitment."))
res0: Tree[String] \/ List[Relation] = -\/(<tree>)
scala> println(res0.shows)

Study the structure of the sentence:

(ROOT
  (S
    (@S
      (NP (DT This) (NN possibility))
      (VP (VBZ has)
        (VP (VBN been)
          (VP (VBN explored)
            (PP (IN in)
              (NP
                (@NP
                  (NP (CD two) (NNS contexts))
                  (: :))
                (NP
                  (@NP
                    (NP (NN axon) (NN regeneration))
                    (CC and))
                  (NP
                    (@NP
                      (@NP (JJ endogenous) (JJ neural))
                      (NN precursor))
                    (NN recruitment)))))))))
    (. .)))

In this case, we need to add pattern matching for the colon constituent:

  object PredicateArgumentsExpression extends ConstituentPattern {

    def apply(tree : Tree[String]) : Option[Stream[Literal]] = tree match {

      case Tree.Node(NP|AtNP, Stream(
        Tree.Node(AtNP, Stream(
          PredicateArgumentsExpression(args1),
          Tree.Node(CC|COMMA|CONJP|COLON, _) // <- Add pattern matching for colon constituent
        )),
        PredicateArgumentsExpression(args2)
      )) =>

        args1.some |+| args2.some

  ...

  }

Now we can extract knowledge from the sentence:

scala> Compile(Parse("This possibility has been explored in two contexts: axon regeneration and endogenous neural precursor recruitment.")).shows
res1: String = \/-([
  <relation:explore(<literal:possibility>, <literal:two context>)>,     
  <relation:explore(<literal:possibility>, <literal:axon regeneration>)>,
  <relation:explore(<literal:possibility>, <literal:precursor recruitment>)>
])

Add a test case:

...

  test("Colon") {

    val expect = Stream(
      Relation(Literal("explore"), List(
        Literal("possibility"),
        Literal("two context")
      )),
      Relation(Literal("explore"), List(
        Literal("possibility"),
        Literal("axon regeneration")
      )),
      Relation(Literal("explore"), List(
        Literal("possibility"),
        Literal("precursor recruitment")
      ))
    ).some

    expect assert_=== extract("This possibility has been explored in two contexts: axon regeneration and endogenous neural precursor recruitment.")

  } 

...

That's it!

  1. Find experimental biology articles.
  2. Try to extract knowledge from each sentence.
  3. If you can't extract knowledge from a sentence, define more patterns for extracting knowledge.
  4. Add a test case.
Clone this wiki locally