protected String getChunkTag(Node node) { String tag = node.getSyntacticTag(); String phraseTag = tag.substring(tag.lastIndexOf(":") + 1); while (phraseTag.endsWith("-")) { phraseTag = phraseTag.substring(0, phraseTag.length() - 1); } // maybe we should use only np, vp and pp, but will keep ap and advp. if (phraseTag.equals("np") || phraseTag.equals("vp") || phraseTag.equals("pp") || phraseTag.equals("ap") || phraseTag.equals("advp") || phraseTag.equals("adjp")) { phraseTag = StringUtil.toUpperCase(phraseTag); } else { phraseTag = OTHER; } return phraseTag; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); // print itself and its children for (int i = 0; i < this.getLevel(); i++) { sb.append("="); } sb.append(this.getSyntacticTag()); if (this.getMorphologicalTag() != null) { sb.append(this.getMorphologicalTag()); } sb.append("\n"); for (TreeElement element : elems) { sb.append(element.toString()); } return sb.toString(); } }
protected String getChunkTag(Node node) { String tag = node.getSyntacticTag(); String phraseTag = tag.substring(tag.lastIndexOf(":") + 1); while (phraseTag.endsWith("-")) { phraseTag = phraseTag.substring(0, phraseTag.length() - 1); } // maybe we should use only np, vp and pp, but will keep ap and advp. if (phraseTag.equals("np") || phraseTag.equals("vp") || phraseTag.equals("pp") || phraseTag.equals("ap") || phraseTag.equals("advp") || phraseTag.equals("adjp")) { phraseTag = StringUtil.toUpperCase(phraseTag); } else { phraseTag = OTHER; } return phraseTag; }
return super.getChunkTag(node, parent, index); else { String tag = node.getSyntacticTag(); String funcTag = tag.substring(0, tag.lastIndexOf(":"));
return super.getChunkTag(node, parent, index); else { String tag = node.getSyntacticTag(); String funcTag = tag.substring(0, tag.lastIndexOf(":"));
private void processNode(Node node, List<String> sentence, List<String> lemmas, List<String> tags, List<String> target, String inheritedTag) { String phraseTag = getChunkTag(node.getSyntacticTag()); boolean inherited = false; if (phraseTag.equals("O") && inheritedTag != null) { phraseTag = inheritedTag; inherited = true; } TreeElement[] elements = node.getElements(); for (int i = 0; i < elements.length; i++) { if (elements[i].isLeaf()) { boolean isIntermediate = false; if (i > 0 && elements[i - 1].isLeaf() && phraseTag != null && !phraseTag.equals("O")) { isIntermediate = true; } if (inherited && target.size() > 0 && target.get(target.size() - 1).endsWith(phraseTag)) { isIntermediate = true; } processLeaf((Leaf) elements[i], isIntermediate, phraseTag, sentence, lemmas, tags, target); } else { processNode((Node) elements[i], sentence, lemmas, tags, target, phraseTag); } } }
private void processNode(Node node, List<String> sentence, List<String> lemmas, List<String> tags, List<String> target, String inheritedTag) { String phraseTag = getChunkTag(node.getSyntacticTag()); boolean inherited = false; if (phraseTag.equals("O") && inheritedTag != null) { phraseTag = inheritedTag; inherited = true; } TreeElement[] elements = node.getElements(); for (int i = 0; i < elements.length; i++) { if (elements[i].isLeaf()) { boolean isIntermediate = false; if (i > 0 && elements[i - 1].isLeaf() && phraseTag != null && !phraseTag.equals("O")) { isIntermediate = true; } if (inherited && target.size() > 0 && target.get(target.size() - 1).endsWith(phraseTag)) { isIntermediate = true; } processLeaf((Leaf) elements[i], isIntermediate, phraseTag, sentence, lemmas, tags, target); } else { processNode((Node) elements[i], sentence, lemmas, tags, target, phraseTag); } } }
protected String getChunkTag(Node node, String parent, int index) { String tag = node.getSyntacticTag(); String phraseTag = tag.substring(tag.lastIndexOf(":") + 1); while (phraseTag.endsWith("-")) { phraseTag = phraseTag.substring(0, phraseTag.length() - 1); } if("adjp".equals(phraseTag) && !"NP".equals(parent)) { phraseTag = "np"; } // maybe we should use only np, vp and pp, but will keep ap and advp. if (phraseTag.equals("np") || phraseTag.equals("vp") || phraseTag.equals("pp") || phraseTag.equals("ap") || phraseTag.equals("advp") // || phraseTag.equals("adjp") // || phraseTag.equals("cu") // || phraseTag.equals("sq") ) { phraseTag = phraseTag.toUpperCase(); } else { phraseTag = OTHER; } return phraseTag; }
protected String getChunkTag(Node node, String parent, int index) { String tag = node.getSyntacticTag(); String phraseTag = tag.substring(tag.lastIndexOf(":") + 1); while (phraseTag.endsWith("-")) { phraseTag = phraseTag.substring(0, phraseTag.length() - 1); } if("adjp".equals(phraseTag) && !"NP".equals(parent)) { phraseTag = "np"; } // maybe we should use only np, vp and pp, but will keep ap and advp. if (phraseTag.equals("np") || phraseTag.equals("vp") || phraseTag.equals("pp") || phraseTag.equals("ap") || phraseTag.equals("advp") // || phraseTag.equals("adjp") // || phraseTag.equals("cu") // || phraseTag.equals("sq") ) { phraseTag = phraseTag.toUpperCase(); } else { phraseTag = OTHER; } return phraseTag; }
protected String getChunkTag(Node node) { String tag = node.getSyntacticTag(); String phraseTag = tag.substring(tag.lastIndexOf(":") + 1); while (phraseTag.endsWith("-")) { phraseTag = phraseTag.substring(0, phraseTag.length() - 1); } // maybe we should use only np, vp and pp, but will keep ap and advp. if (phraseTag.equals("np") || phraseTag.equals("vp") || phraseTag.equals("pp") || phraseTag.equals("ap") || phraseTag.equals("advp") || phraseTag.equals("adjp")) { phraseTag = StringUtil.toUpperCase(phraseTag); } else { phraseTag = OTHER; } return phraseTag; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); // print itself and its children for (int i = 0; i < this.getLevel(); i++) { sb.append("="); } sb.append(this.getSyntacticTag()); if (this.getMorphologicalTag() != null) { sb.append(this.getMorphologicalTag()); } sb.append("\n"); for (TreeElement element : elems) { sb.append(element.toString()); } return sb.toString(); } }
@Override public String toString() { StringBuilder sb = new StringBuilder(); // print itself and its children for (int i = 0; i < this.getLevel(); i++) { sb.append("="); } sb.append(this.getSyntacticTag()); if (this.getMorphologicalTag() != null) { sb.append(this.getMorphologicalTag()); } sb.append("\n"); for (TreeElement element : elems) { sb.append(element.toString()); } return sb.toString(); } }