-
Notifications
You must be signed in to change notification settings - Fork 4
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #13 from uts-cic/develop
Merge Develop for Initial 0.1 release
- Loading branch information
Showing
19 changed files
with
394 additions
and
48 deletions.
There are no files selected for viewing
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,8 @@ | ||
language: scala | ||
scala: | ||
- 2.12.0 | ||
- 2.12.2 | ||
jdk: | ||
- oraclejdk8 | ||
- oraclejdk8 | ||
|
||
install: | ||
sudo apt-get install libc6-i386 |
This file contains 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
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
sbt.version = 0.13.15 |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,9 @@ | ||
addSbtPlugin("com.timushev.sbt" % "sbt-updates" % "0.3.0") | ||
addSbtPlugin("net.virtual-void" % "sbt-dependency-graph" % "0.8.2") | ||
//addSbtPlugin("org.scalariform" % "sbt-scalariform" % "1.6.0") | ||
//addSbtPlugin("org.scalastyle" %% "scalastyle-sbt-plugin" % "0.8.0") | ||
addSbtPlugin("org.scoverage" % "sbt-scoverage" % "1.5.0") | ||
addSbtPlugin("org.scoverage" % "sbt-coveralls" % "1.1.0") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-native-packager" % "1.2.0-M9") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-site" % "1.2.0") | ||
addSbtPlugin("com.typesafe.sbt" % "sbt-ghpages" % "0.5.4") |
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,14 @@ | ||
<?xml version="1.0" encoding="ISO-8859-1"?> | ||
<configuration debug="false"> | ||
<appender name="STDOUT" class="ch.qos.logback.core.ConsoleAppender"> | ||
<encoder> | ||
<pattern>%green(%date{yyyyMMdd_HH:mm:ss.SSS, Australia/Sydney}) %highlight(%-5level) %cyan(%logger{36}) %yellow(%X{akkaSource}) - %msg%n</pattern> | ||
</encoder> | ||
</appender> | ||
<logger name="com.zaxxer.hikari.pool.HikariPool" level="INFO" /> | ||
<logger name="slick.compiler" level="INFO" /> | ||
|
||
<root level="DEBUG"> | ||
<appender-ref ref="STDOUT" /> | ||
</root> | ||
</configuration> |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,17 +1,17 @@ | ||
package au.edu.utscic.athanorserver.athanor | ||
|
||
import au.edu.utscic.athanorserver.data.RhetoricalTypes.{ConstituentTree, Dependencies, LexicalNodes, ParsedSentence} | ||
import au.edu.utscic.athanorserver.data.RhetoricalImplicits | ||
import au.edu.utscic.athanorserver.data.RhetoricalTypes._ | ||
import com.typesafe.config.{Config, ConfigFactory} | ||
import com.xerox.jatanor.JAtanor | ||
import org.json4s.JsonAST.JValue | ||
import org.json4s.NoTypeHints | ||
import org.json4s.jackson.JsonMethods.parse | ||
import org.json4s.jackson.Serialization | ||
import org.json4s.jackson.Serialization.write | ||
import org.json4s.{DefaultFormats, NoTypeHints} | ||
|
||
import scala.io.Source | ||
|
||
|
||
/** | ||
* Created by [email protected] on 28/6/17. | ||
*/ | ||
|
@@ -21,41 +21,41 @@ object Athanor { | |
lazy val path: String = config.getString("app.path") | ||
lazy val athanor = new JAtanor | ||
lazy val handler = athanor.LoadProgram(program,"") | ||
lazy val program: String = fullPath("apply.kif") | ||
lazy val testSentence: String = fullPath("sentence.json") | ||
lazy val demoFile:String = Source.fromFile(testSentence).getLines.mkString | ||
|
||
def fullPath(file:String): String = { | ||
s"$path/scripts/$file" | ||
} | ||
|
||
def program: String = fullPath("apply.kif") | ||
|
||
|
||
def testSentence: String = fullPath("sentence.json") | ||
def parseJsonSentence(sent:String):ParsedSentence = { | ||
|
||
def demoFile:String = { | ||
Source.fromFile(testSentence).getLines.mkString | ||
} | ||
import RhetoricalImplicits._ | ||
|
||
def demoParsed:ParsedSentence = { | ||
implicit val formats = DefaultFormats | ||
val sent = demoFile | ||
val json:JValue = parse(sent) | ||
val lexNodes:LexicalNodes = json(0).extract[LexicalNodes] | ||
val lexNodes:LexicalNodes = json(0) | ||
val constTree:ConstituentTree = json(1).extract[ConstituentTree] | ||
val deps:Dependencies = json(2).extract[Dependencies] | ||
(lexNodes,constTree,deps) | ||
} | ||
|
||
def process(json:String):List[String] = { | ||
athanor.ExecuteFunctionArray(handler,"Apply",List(json).toArray).toList | ||
def parsedSentenceToJsonString(parsedSent:ParsedSentence):String = { | ||
implicit val formats = Serialization.formats(NoTypeHints) | ||
val l = write(parsedSent._1) | ||
val c = write(parsedSent._2) | ||
val d = write(parsedSent._3) | ||
s"[$l,$c,$d]" | ||
} | ||
|
||
def process(parsed:ParsedSentence):List[String] = { | ||
implicit val formats = Serialization.formats(NoTypeHints) | ||
val l = write(parsed._1) | ||
val c = write(parsed._2) | ||
val d = write(parsed._3) | ||
val output:String = s"[$l,$c,$d]" | ||
this.process(output) | ||
def analyseParsedSentence(parsed:ParsedSentence):List[String] = { | ||
val jsonStr:String = parsedSentenceToJsonString(parsed) | ||
this.analyseJson(jsonStr) | ||
} | ||
|
||
def analyseJson(json:String):List[String] = { | ||
athanor.ExecuteFunctionArray(handler,"Apply",List(json).toArray).toList | ||
} | ||
|
||
} | ||
|
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ package au.edu.utscic.athanorserver.corenlp | |
|
||
import au.edu.utscic.athanorserver.data.RhetoricalTypes | ||
import au.edu.utscic.athanorserver.data.RhetoricalTypes._ | ||
import edu.stanford.nlp.ling.CoreAnnotations.{LemmaAnnotation, PartOfSpeechAnnotation, TextAnnotation} | ||
import edu.stanford.nlp.ling.CoreAnnotations._ | ||
import edu.stanford.nlp.ling.CoreLabel | ||
import edu.stanford.nlp.semgraph.SemanticGraph | ||
import edu.stanford.nlp.trees.Tree | ||
|
||
import scala.collection.JavaConverters._ | ||
import scala.collection.immutable.ListMap | ||
import scala.collection.immutable.SortedMap | ||
|
||
/** | ||
* Created by [email protected] on 12/7/17. | ||
|
@@ -22,18 +22,27 @@ object SentenceParser { | |
(ln,ct,dp) | ||
} | ||
|
||
private def getOpt[T](a:Any):Option[T] = a match { | ||
case s:T => Some(s) | ||
case null => None | ||
case _ => None | ||
} | ||
|
||
def getNodes(tokens:List[CoreLabel]):LexicalNodes = { | ||
|
||
val nodes = tokens.zipWithIndex.map { case(token,i) => | ||
val index = i+1 | ||
val word = token.get(classOf[TextAnnotation]) | ||
val lemma = token.get(classOf[LemmaAnnotation]) | ||
val pos = token.get(classOf[PartOfSpeechAnnotation]) | ||
//val ne = token.get(classOf[NamedEntityTagAnnotation]) | ||
(index,RhetoricalTypes.Node(index,pos,Some(word),Some(lemma))) | ||
val ne = token.get(classOf[NamedEntityTagAnnotation]) | ||
val spk = token.get(classOf[SpeakerAnnotation]) | ||
val left = token.beginPosition() | ||
val right = token.endPosition() | ||
(index,RhetoricalTypes.Node(index,pos,getOpt[String](word),getOpt[String](lemma),getOpt[String](ne),getOpt[String](spk),getOpt[Int](left),getOpt[Int](right))) | ||
} | ||
|
||
ListMap() ++ nodes | ||
SortedMap[Int,Node](0 -> Node(0,"ROOT",None,None,None,None,None,None)) ++ nodes | ||
} | ||
|
||
def getTree(constituentTree: Tree):ConstituentTree = { | ||
|
This file contains 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
17 changes: 17 additions & 0 deletions
17
src/main/scala/au/edu/utscic/athanorserver/data/RhetoricalImplicits.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,17 @@ | ||
package au.edu.utscic.athanorserver.data | ||
|
||
import au.edu.utscic.athanorserver.data.RhetoricalTypes._ | ||
import org.json4s.DefaultFormats | ||
import org.json4s.JsonAST.JValue | ||
|
||
import scala.collection.immutable.SortedMap | ||
|
||
/** | ||
* Created by [email protected] on 19/7/17. | ||
*/ | ||
object RhetoricalImplicits { | ||
|
||
implicit val formats = DefaultFormats | ||
implicit def jvalueToLexicalNodes(jvalue:JValue):LexicalNodes = SortedMap[Int,Node]() ++ jvalue.extract[Map[Int,Node]] | ||
|
||
} |
14 changes: 10 additions & 4 deletions
14
src/main/scala/au/edu/utscic/athanorserver/data/RhetoricalTypes.scala
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,22 +1,28 @@ | ||
package au.edu.utscic.athanorserver.data | ||
|
||
import scala.collection.immutable.ListMap | ||
import scala.collection.immutable.SortedMap | ||
|
||
/** | ||
* Created by [email protected] on 29/6/17. | ||
*/ | ||
|
||
object RhetoricalTypes { | ||
type ConstituentTree = List[Serializable] | ||
type LexicalNodes = ListMap[Int,Node] | ||
|
||
type LexicalNodes = SortedMap[Int,Node] | ||
type ConstituentTree = List[Any] | ||
type Dependencies = List[Dependency] | ||
|
||
type ParsedSentence = (LexicalNodes,ConstituentTree,Dependencies) | ||
|
||
case class Node( | ||
id:Int, | ||
POS:String, | ||
surface:Option[String], | ||
lemma:Option[String] | ||
lemma:Option[String], | ||
NER:Option[String] = None, | ||
Speaker:Option[String] = None, | ||
left:Option[Int] = None, | ||
right:Option[Int] = None | ||
) | ||
|
||
case class Dependency( | ||
|
Oops, something went wrong.