From 693e4c0d93a44785c6dabdec75a2af770ef597ac Mon Sep 17 00:00:00 2001 From: austin Date: Mon, 30 Dec 2024 21:39:31 -0500 Subject: [PATCH] clause types --- .../conversation/parser/depend/Clause.java | 42 +++++++++++++-- .../conversation/parser/depend/Predicate.java | 54 +++++++++++++++++++ 2 files changed, 91 insertions(+), 5 deletions(-) diff --git a/src/main/java/org/studiorailgun/conversation/parser/depend/Clause.java b/src/main/java/org/studiorailgun/conversation/parser/depend/Clause.java index 2e715ed..c925c51 100644 --- a/src/main/java/org/studiorailgun/conversation/parser/depend/Clause.java +++ b/src/main/java/org/studiorailgun/conversation/parser/depend/Clause.java @@ -13,7 +13,38 @@ import edu.stanford.nlp.trees.GrammaticalRelation; * Parses the macro structure of the sentence */ public class Clause { + + /** + * The type of a clause + */ + public static enum ClauseType { + + /** + * A main clause + */ + MAIN, + + /** + * A conjugate clause + */ + CONJUGATE, + + /** + * A clause that depends on the main clause + */ + DEPENDENT, + + /** + * A paratactic clause + */ + PARATACTIC, + } + /** + * The type of this clause + */ + ClauseType type; + /** * The predicate of the sentence */ @@ -54,7 +85,7 @@ public class Clause { throw new Error("Unable to parse sentences with roots != 1!"); } IndexedWord root = graph.getFirstRoot(); - Clause rVal = parse(graph,root); + Clause rVal = Clause.parse(graph,root, ClauseType.MAIN); // throw new Error("\n" + graph); return rVal; } @@ -65,8 +96,9 @@ public class Clause { * @param root The root to parse from * @return The macro structure */ - private static Clause parse(SemanticGraph graph, IndexedWord root){ + private static Clause parse(SemanticGraph graph, IndexedWord root, ClauseType type){ Clause rVal = new Clause(); + rVal.type = type; List children = graph.getChildList(root); //the root is (typically) the predicate @@ -161,7 +193,7 @@ public class Clause { //a collapsed clause case "conj_collapsed": { - Clause clause = Clause.parse(graph, child); + Clause clause = Clause.parse(graph, child, ClauseType.CONJUGATE); rVal.clauses.add(clause); } break; @@ -175,7 +207,7 @@ public class Clause { * A dependent clause */ case "dependent": { - Clause clause = Clause.parse(graph, child); + Clause clause = Clause.parse(graph, child, ClauseType.DEPENDENT); rVal.clauses.add(clause); } break; @@ -183,7 +215,7 @@ public class Clause { * A paratactic construct (A clause that is very loosely related to the main clause) */ case "parataxis": { - Clause clause = Clause.parse(graph, child); + Clause clause = Clause.parse(graph, child, ClauseType.PARATACTIC); rVal.clauses.add(clause); } break; diff --git a/src/main/java/org/studiorailgun/conversation/parser/depend/Predicate.java b/src/main/java/org/studiorailgun/conversation/parser/depend/Predicate.java index 8c4f0b7..f4cdfca 100644 --- a/src/main/java/org/studiorailgun/conversation/parser/depend/Predicate.java +++ b/src/main/java/org/studiorailgun/conversation/parser/depend/Predicate.java @@ -9,6 +9,47 @@ import edu.stanford.nlp.ling.IndexedWord; * A linguistic predicate */ public class Predicate { + + /** + * The types of nonverbal predicates that can exist + */ + public static enum NonVerbalPredicateType { + + /** + * Stating an identity/equality (He is my father) + */ + EQUATION, + + /** + * Attributing a value to something (She is intelligent) + */ + ATTRIBUTION, + + /** + * Quantifying something (There are two) + */ + QUANTIFICATION, + + /** + * Stating the location of something (The book is above the bed) + */ + LOCATION, + + /** + * Stating the possessor of something (The can is hers) + */ + POSSESSION, + + /** + * Stating the benefactor of something (The car is his) + */ + BENEFACTION, + + /** + * Stating the existence of something (There is a god) + */ + EXISTENCE, + } /** * The root of the predicate @@ -36,6 +77,11 @@ public class Predicate { */ IndexedWord phrasalVerbParticle; + /** + * The nonverbal predicate type + */ + NonVerbalPredicateType nonVerbalType; + /** * Constructor * @param root The root of the predicate @@ -68,6 +114,14 @@ public class Predicate { return adverbs; } + /** + * Sets the copular for this predicate + * @param copularWord The copular word + */ + public void setCopular(IndexedWord copularWord){ + + } + /** * Sets the existential status of the predicate * @param existential true if existential, false otherwise