List of usage examples for edu.stanford.nlp.semgraph SemanticGraph valueOf
public static SemanticGraph valueOf(String s)
From source file:opendial.bn.values.RelationalVal.java
License:Open Source License
public RelationalVal(String string) { this.graph = new SemanticGraph(); StringBuilder current = new StringBuilder(); int openedBrackets = 0; recordRelations(string);// w w w. j a va 2 s .co m for (int i = 0; i < string.length(); i++) { char c = string.charAt(i); if (openedBrackets == 0 && !current.toString().trim().isEmpty() && (c == ' ' || c == '[' || i == string.length() - 1)) { addGraph(SemanticGraph.valueOf(current.toString())); current = new StringBuilder(); } current.append(c); if (c == '[') { openedBrackets++; } else if (c == ']') { openedBrackets--; if (openedBrackets == 0 && current.length() > 2) { addGraph(SemanticGraph.valueOf(current.toString())); current = new StringBuilder(); } } } }