Skip to content
This repository has been archived by the owner on Oct 3, 2020. It is now read-only.

Commit

Permalink
added NNS sorting system
Browse files Browse the repository at this point in the history
  • Loading branch information
fulton committed Nov 23, 2019
1 parent 0f36724 commit 26e327b
Show file tree
Hide file tree
Showing 2 changed files with 54 additions and 2 deletions.
3 changes: 2 additions & 1 deletion src/main/java/com/andromeda/araserver/Run.java
Original file line number Diff line number Diff line change
Expand Up @@ -57,7 +57,8 @@ private Run(int port) throws IOException {
model = new ParserModel(is);
parser = ParserFactory.create(model);
keyWord = new KeyWord(is);
//System.out.println(new SortWords(keyWord, "where is a starbucks near me").getTopics(parser));
System.out.println(" reeeeesut");
System.out.println(" " +new SortWords(keyWord, "where is a starbucks near me").getNNS(parser));

}
// Static function, to be run on start.
Expand Down
53 changes: 52 additions & 1 deletion src/main/java/com/andromeda/araserver/util/SortWords.kt
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,65 @@ class SortWords(keyWord: KeyWord, mainVal: String) {
private fun sortForNoun(graph: Parse): ArrayList<WordGraph> {
val toReturn = ArrayList<WordGraph>()
for (i in graph.children!!) {
print(i.coveredText+ " " + i.type)
if (i.type == "NN" || i.type == "JJ"|| i.type == "PRP"|| i.type == "IN") {
toReturn.add(WordGraph(i.coveredText, i.type))
}
if (i.childCount > 0) toReturn.addAll(sortForNoun(i))
}
return toReturn

}
fun getNNS(parse: Parser): String {
var toReturn = "qwertyuio"

var graph = key.getKeyWords(mainText,parse)?.get(0)
graph?.show()


var working = true
if (graph != null) {
graph.show()

while (working) {
when {
graph?.childCount == 1 -> {
graph = graph.children?.get(0)
}
graph?.childCount == 0 -> {
working = false
}
else -> {
if (graph != null) {
val toTest = sortForNNS(graph)
if(toTest != "")toReturn = toTest
}
working = false
}

}
}
} else {
print("null")
println("fail")
}
return toReturn


}

private fun sortForNNS(graph: Parse): String {
var toReturn = ""
for (i in graph.children!!) {
print(i.coveredText+ " " + i.type)
if (i.type == "NNS" ) {
toReturn = i.coveredText
}
if (i.childCount > 0){ val toTest = sortForNNS(i)
if(toTest != "")toReturn = toTest
}
}
return toReturn

}

fun getActions() {
Expand Down

0 comments on commit 26e327b

Please sign in to comment.