Skip to content

Instantly share code, notes, and snippets.

@myedibleenso
Created February 18, 2016 02:09
Show Gist options
  • Save myedibleenso/827786a1542b24063046 to your computer and use it in GitHub Desktop.
Save myedibleenso/827786a1542b24063046 to your computer and use it in GitHub Desktop.
odin example
// requires processors library: https://github.com/clulab/processors/blob/master/README.md
import edu.arizona.sista.odin._
import edu.arizona.sista.processors.fastnlp.FastNLPProcessor
val proc = new FastNLPProcessor
// a couple of simple examples to test the rules against.
val text = "a tiger is a kind of big cat. an eye is a part of a tiger."
val doc = proc annotate text
// link points to raw content of a gist (rules file)
val rulesPath = "https://gist.githubusercontent.com/myedibleenso/465192e9d229b9f25731/raw/d91b0c47f3327fa8d96c30470f390041dc21666e/test.yml"
val rules = io.Source.fromURL(rulesPath).mkString("")
val ee = ExtractorEngine(rules)
val mentions = ee extractFrom doc
// print the text any Mention with the "PartOf" label
def partOfDisplay(m: Mention): String =
s"""|-------------------------------------
|label: ${m.label}
|text: "${m.text}"
|args:
| holonym: "${m.arguments("holonym").head.text}"
| meronym: "${m.arguments("meronym").head.text}"
|-------------------------------------
""".stripMargin
mentions filter ( _ matches "PartOf") foreach (m => println(partOfDisplay(m)))
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment