/** * Given a SemanticGraph, creates a SemgrexPattern string based off of this graph. * NOTE: the word() value of the vertice is the name to reference * NOTE: currently presumes there is only one root in this graph. * TODO: see if Semgrex can allow multiroot patterns * @param sg SemanticGraph to base this pattern on. */ public static String semgrexFromGraph(SemanticGraph sg, boolean matchTag, boolean matchWord, Map<IndexedWord, String> nodeNameMap) throws Exception { return semgrexFromGraph(sg, null, matchTag, matchWord, nodeNameMap); }
/** * Given a set of edges that form a rooted and connected graph, returns a Semgrex pattern * corresponding to it. * @throws Exception */ public static String semgrexFromGraph(Iterable<SemanticGraphEdge> edges, boolean matchTag, boolean matchWord, Map<IndexedWord, String> nodeNameMap) throws Exception { SemanticGraph sg = SemanticGraphFactory.makeFromEdges(edges); return semgrexFromGraph(sg, matchTag, matchWord, nodeNameMap); }
public static String semgrexFromGraph(SemanticGraph sg, Collection<IndexedWord> wildcardNodes, boolean useTag, boolean useWord, Map<IndexedWord, String> nodeNameMap) throws Exception { Function<IndexedWord, String> transformNode = o ->{ String str = ""; if(useWord) str = "{word: /" + Pattern.quote(o.word()) + "/"; if(useTag){ if(!str.isEmpty()) str += "; "; str = "tag: " + o.tag(); } if(!str.isEmpty()) str += "}"; return str; }; return semgrexFromGraph(sg, wildcardNodes, nodeNameMap, transformNode); }
/** * Given a SemanticGraph, creates a SemgrexPattern string based off of this graph. * NOTE: the word() value of the vertice is the name to reference * NOTE: currently presumes there is only one root in this graph. * TODO: see if Semgrex can allow multiroot patterns * @param sg SemanticGraph to base this pattern on. */ public static String semgrexFromGraph(SemanticGraph sg, boolean matchTag, boolean matchWord, Map<IndexedWord, String> nodeNameMap) throws Exception { return semgrexFromGraph(sg, null, matchTag, matchWord, nodeNameMap); }
/** * Given a SemanticGraph, creates a SemgrexPattern string based off of this graph. * NOTE: the word() value of the vertice is the name to reference * NOTE: currently presumes there is only one root in this graph. * TODO: see if Semgrex can allow multiroot patterns * @param sg SemanticGraph to base this pattern on. */ public static String semgrexFromGraph(SemanticGraph sg, boolean matchTag, boolean matchWord, Map<IndexedWord, String> nodeNameMap) throws Exception { return semgrexFromGraph(sg, null, matchTag, matchWord, nodeNameMap); }
/** * Given a set of edges that form a rooted and connected graph, returns a Semgrex pattern * corresponding to it. * @throws Exception */ public static String semgrexFromGraph(Iterable<SemanticGraphEdge> edges, boolean matchTag, boolean matchWord, Map<IndexedWord, String> nodeNameMap) throws Exception { SemanticGraph sg = SemanticGraphFactory.makeFromEdges(edges); return semgrexFromGraph(sg, matchTag, matchWord, nodeNameMap); }
/** * Given a set of edges that form a rooted and connected graph, returns a Semgrex pattern * corresponding to it. * @throws Exception */ public static String semgrexFromGraph(Iterable<SemanticGraphEdge> edges, boolean matchTag, boolean matchWord, Map<IndexedWord, String> nodeNameMap) throws Exception { SemanticGraph sg = SemanticGraphFactory.makeFromEdges(edges); return semgrexFromGraph(sg, matchTag, matchWord, nodeNameMap); }
public static String semgrexFromGraph(SemanticGraph sg, Collection<IndexedWord> wildcardNodes, boolean useTag, boolean useWord, Map<IndexedWord, String> nodeNameMap) throws Exception { Function<IndexedWord, String> transformNode = o ->{ String str = ""; if(useWord) str = "{word: /" + Pattern.quote(o.word()) + "/"; if(useTag){ if(!str.isEmpty()) str += "; "; str = "tag: " + o.tag(); } if(!str.isEmpty()) str += "}"; return str; }; return semgrexFromGraph(sg, wildcardNodes, nodeNameMap, transformNode); }
public static String semgrexFromGraph(SemanticGraph sg, Collection<IndexedWord> wildcardNodes, boolean useTag, boolean useWord, Map<IndexedWord, String> nodeNameMap) throws Exception { Function<IndexedWord, String> transformNode = o ->{ String str = ""; if(useWord) str = "{word: /" + Pattern.quote(o.word()) + "/"; if(useTag){ if(!str.isEmpty()) str += "; "; str = "tag: " + o.tag(); } if(!str.isEmpty()) str += "}"; return str; }; return semgrexFromGraph(sg, wildcardNodes, nodeNameMap, transformNode); }