Created
November 11, 2014 18:25
-
-
Save AmirHooshangi/424e6351e5df8bb28bc0 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def recursiveTypefinder(parse: opennlp.tools.parser.Parse): Unit = { | |
if (parse.getType().equals("NN") || parse.getType().equals("JJ") | |
|| parse.getType().equals("NNS") | |
|| parse.getType().equals("NNP")) { | |
println(parse.getCoveredText) | |
concepts.add(parse.getCoveredText) | |
} | |
for (child <- parse.getChildren) { | |
recursiveTypefinder(child) | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
def recursiveTypefinder(parse: opennlp.tools.parser.Parse): List[String] = {
val concepts = parse.getType match {
case "NN" | "JJ" | ... => List(parse.getCoveredText)
case _ => Nil
}
concepts :: parse.getChildren.flatMap(recursiveTypefinder)
}