public String discreteValue(Object __example) { if (!(__example instanceof Relation)) { String type = __example == null ? "null" : __example.getClass().getName(); System.err.println("Classifier 'headText(Relation)' defined on line 33 of extent.lbj received '" + type + "' as input."); new Exception().printStackTrace(); System.exit(1); } Relation r = (Relation) __example; return "" + (r.getTarget().toString().toLowerCase()); }
public String discreteValue(Object __example) { if (!(__example instanceof Relation)) { String type = __example == null ? "null" : __example.getClass().getName(); System.err.println("Classifier 'headText(Relation)' defined on line 33 of extent.lbj received '" + type + "' as input."); new Exception().printStackTrace(); System.exit(1); } Relation r = (Relation) __example; return "" + (r.getTarget().toString().toLowerCase()); }
public String discreteValue(Object __example) { if (!(__example instanceof Relation)) { String type = __example == null ? "null" : __example.getClass().getName(); System.err.println("Classifier 'headText(Relation)' defined on line 33 of extent.lbj received '" + type + "' as input."); new Exception().printStackTrace(); System.exit(1); } Relation r = (Relation) __example; return "" + (r.getTarget().toString().toLowerCase()); }
public static String getTokenSequence(TextAnnotation ta, int start, int end) { return new Constituent("", "", ta, start, end).toString(); }
public static String getTokenSequence(TextAnnotation ta, int start, int end) { return new Constituent("", "", ta, start, end).toString(); }
@Override public String toString() { StringBuilder bldr = new StringBuilder( source.toString() ); bldr.append( "--" ).append( getRelationName() ).append("--> "); bldr.append( target ).append("(").append( getScore() ).append( ")" ); return bldr.toString(); }
@Override public String toString() { StringBuilder bldr = new StringBuilder( source.toString() ); bldr.append( "--" ).append( getRelationName() ).append("--> "); bldr.append( target ).append("(").append( getScore() ).append( ")" ); return bldr.toString(); }
public String discreteValue(Object __example) { if (!(__example instanceof Relation)) { String type = __example == null ? "null" : __example.getClass().getName(); System.err.println("Classifier 'CapitalizationExtent(Relation)' defined on line 167 of extent.lbj received '" + type + "' as input."); new Exception().printStackTrace(); System.exit(1); } Relation r = (Relation) __example; if (r.getSource().toString().equals(r.getSource().toString().toLowerCase())) { return "false"; } return "true"; }
public String discreteValue(Object __example) { if (!(__example instanceof Relation)) { String type = __example == null ? "null" : __example.getClass().getName(); System.err.println("Classifier 'CapitalizationExtent(Relation)' defined on line 167 of extent.lbj received '" + type + "' as input."); new Exception().printStackTrace(); System.exit(1); } Relation r = (Relation) __example; if (r.getSource().toString().equals(r.getSource().toString().toLowerCase())) { return "false"; } return "true"; }
public String discreteValue(Object __example) { if (!(__example instanceof Relation)) { String type = __example == null ? "null" : __example.getClass().getName(); System.err.println("Classifier 'CapitalizationExtent(Relation)' defined on line 167 of extent.lbj received '" + type + "' as input."); new Exception().printStackTrace(); System.exit(1); } Relation r = (Relation) __example; if (r.getSource().toString().equals(r.getSource().toString().toLowerCase())) { return "false"; } return "true"; }
/** * Extracts the wordNet document names of the given Constituent. * Helps nominals when crossing domains. * The size of the Constituent should be 1 */ public static String getWordNetTags(WordNetManager wordnet, Constituent c){ List<String> ret = null; try { ret = wordnet.getLexicographerFileNames(c.toString().toLowerCase(), true); } catch (Exception e){ e.printStackTrace(); } String retStr = ""; for (String s : ret){ retStr += s + ","; } return retStr; }
/** * Normalize temporal Phrase * @param temporal_phrase * @return * @throws Exception */ private String heidelTimeNormalize(Constituent temporal_phrase) throws Exception { // If user didn't specify document creation date, use the current date if (this.dct == null) { this.dct = new Date(); } String xml_res = this.heidelTime.process(temporal_phrase.toString(), this.dct); Document document = builder.parse(new InputSource(new StringReader(xml_res))); Element rootElement = document.getDocumentElement(); String res = recurseNormalizedTimeML(rootElement, temporal_phrase, this.timex); return res; }
/** * Normalize temporal Phrase * @param temporal_phrase * @return * @throws Exception */ private String heidelTimeNormalize(Constituent temporal_phrase) throws Exception { // If user didn't specify document creation date, use the current date if (this.dct == null) { this.dct = new Date(); } String xml_res = this.heidelTime.process(temporal_phrase.toString(), this.dct); Document document = builder.parse(new InputSource(new StringReader(xml_res))); Element rootElement = document.getDocumentElement(); String res = recurseNormalizedTimeML(rootElement, temporal_phrase, this.timex); return res; }
@Override public String toString() { StringBuilder sb = new StringBuilder(); Set<Constituent> entities = this.getCanonicalEntities(); for (Constituent canonical : Sorters.sortSet(entities, TextAnnotationUtilities.constituentStartComparator)) { sb.append(canonical.toString()).append(" (").append(canonical.getStartSpan()) .append(", ").append(canonical.getEndSpan()).append(")\n"); for (Relation referant : getFilteredOutgoingRelations(canonical)) { sb.append("\t").append(referant.getTarget().toString()).append(" (") .append(referant.getTarget().getStartSpan()).append(", ") .append(referant.getTarget().getEndSpan()).append(") \n"); } sb.append("\n"); } return sb.toString(); }
@Override public String toString() { StringBuilder sb = new StringBuilder(); Set<Constituent> entities = this.getCanonicalEntities(); for (Constituent canonical : Sorters.sortSet(entities, TextAnnotationUtilities.constituentStartComparator)) { sb.append(canonical.toString()).append(" (").append(canonical.getStartSpan()) .append(", ").append(canonical.getEndSpan()).append(")\n"); for (Relation referant : getFilteredOutgoingRelations(canonical)) { sb.append("\t").append(referant.getTarget().toString()).append(" (") .append(referant.getTarget().getStartSpan()).append(", ") .append(referant.getTarget().getEndSpan()).append(") \n"); } sb.append("\n"); } return sb.toString(); }
/** * Helper function for print essential information of a relation * @param r Input Relation */ public static void printRelation (Relation r){ TextAnnotation ta = r.getSource().getTextAnnotation(); Constituent source = r.getSource(); Constituent target = r.getTarget(); Constituent source_head = RelationFeatureExtractor.getEntityHeadForConstituent(source, ta, ""); Constituent target_head = RelationFeatureExtractor.getEntityHeadForConstituent(target, ta, ""); System.out.println(ta.getSentenceFromToken(source.getStartSpan())); System.out.println(r.getRelationName()); System.out.println(r.getAttribute("RelationType") + ":" + r.getAttribute("RelationSubtype")); System.out.println(source.toString() + " || " + target.toString()); System.out.println(source_head.toString() + " || " + target_head.toString()); }
/** * Lexical Feature Extractor Part F * @Extracts Head forms * @return A List of String features */ public List<String> getLexicalFeaturePartF(Relation r){ List<String> ret_features = new ArrayList<String>(); Constituent source = r.getSource(); Constituent target = r.getTarget(); Constituent sourceHead = getEntityHeadForConstituent(source, source.getTextAnnotation(), "EntityHeads"); Constituent targetHead = getEntityHeadForConstituent(target, target.getTextAnnotation(), "EntityHeads"); String sourceHeadWord = sourceHead.toString(); String targetHeadWord = targetHead.toString(); ret_features.add("HM1_" + sourceHeadWord); ret_features.add("HM2_" + targetHeadWord); ret_features.add("HM12_" + sourceHeadWord + "_" + targetHeadWord); return ret_features; }
/** * compile a list of predicates. * @param tree the tree with the data. * @param tokenmap the token maps with the terminal nodes. * @return the string indicating the leaves. */ public String printableLinks(Tree<Constituent> tree, HashMap<Integer, Tree<Constituent>> tokenmap) { StringBuffer sb = new StringBuffer(); for (SRLLink link : links) { Tree<Constituent> node = tokenmap.get(link.where.getFirst()); for (int i = link.where.getSecond(); i > 0 && node.getParent() != null; i--) { Tree<Constituent> up = node.getParent(); node = up; } sb.append(link.link + node.getLabel().toString()); } return sb.toString(); }
protected Tree<String> buildTree(Constituent root) { Tree<String> t; if (isDependencyTree) t = new Tree<>(root.toString()); else t = new Tree<>(root.getLabel()); for (Relation r : root.getOutgoingRelations()) { if (!isDependencyTree) t.addSubtree(buildTree(r.getTarget())); else t.addSubtree(buildTree(r.getTarget()), r.getRelationName()); } return t; }
protected Tree<String> buildTree(Constituent root) { Tree<String> t; if (isDependencyTree) t = new Tree<>(root.toString()); else t = new Tree<>(root.getLabel()); for (Relation r : root.getOutgoingRelations()) { if (!isDependencyTree) t.addSubtree(buildTree(r.getTarget())); else t.addSubtree(buildTree(r.getTarget()), r.getRelationName()); } return t; }