This commit is contained in:
parent
bdcf63c421
commit
693e4c0d93
@ -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<IndexedWord> 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;
|
||||
|
||||
|
||||
@ -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
|
||||
|
||||
Loading…
Reference in New Issue
Block a user