Skip to content

Instantly share code, notes, and snippets.

@fmarten
Created August 11, 2017 08:45
Show Gist options
  • Save fmarten/f2ae648e3ccca9f3e2584d8d675d653c to your computer and use it in GitHub Desktop.
Save fmarten/f2ae648e3ccca9f3e2584d8d675d653c to your computer and use it in GitHub Desktop.
Extract dependencies from conll file
#!/usr/bin/env scalas
/***
scalaVersion := "2.11.8"
resolvers ++= Seq(
"Will's bintray" at "https://dl.bintray.com/willb/maven/",
"jitpack" at "https://jitpack.io"
)
libraryDependencies ++= Seq(
"com.github.fmarten" % "scala-conll-format" % "-SNAPSHOT"
)
*/
val path = "/tmp/conll.csv"
new java.io.PrintWriter(path) {
write("""# parser = MaltParser Language: English. Parser configuration: Stack. Transition system: Projective. Model: de.tudarmstadt.ukp.dkpro.core.maltparser-upstream-parser-en-linear. Model version: 20120312.
# text = Website Usability Tips, Tricks and Mistakes.
0 Website Website NNP NNP 2 nn 2:nn O
1 Usability Usability NNP NNP 2 nn 2:nn O
2 Tips Tips NNP NNP 2 ROOT 2:ROOT O
""")
close()
}
import de.tudarmstadt.conll._
val reader = CoNLLFileReader.open(path)
val sentence = reader.nextSentence()
println(sentence.rows.mkString("\n"))
// TODO extract deps
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment