public String toString() { return "TextAnnotation: " + this.getText(); }
String getOriginalText() { return m_text.getText(); }
String getOriginalHyp() { return m_hyp.getText(); }
public String toString() { return "TextAnnotation: " + this.getText(); }
public static String printTextAnnotation(TextAnnotation ta ) throws IOException { StringBuilder bldr = new StringBuilder(); bldr.append( "TextAnnotation for text: " ); bldr.append( ta.getText() ); for ( String vName: ta.getAvailableViews() ) { bldr.append(printView( ta.getView( vName ))); } return bldr.toString(); }
public static String printTextAnnotation(TextAnnotation ta ) throws IOException { StringBuilder bldr = new StringBuilder(); bldr.append( "TextAnnotation for text: " ); bldr.append( ta.getText() ); for ( String vName: ta.getAvailableViews() ) { bldr.append(printView( ta.getView( vName ))); } return bldr.toString(); }
@Override public String getText() { int start = sentenceConstituent.getStartCharOffset(); int end = sentenceConstituent.getEndCharOffset(); return textAnnotation.getText().substring(start, end); }
@Override public String getText() { int start = sentenceConstituent.getStartCharOffset(); int end = sentenceConstituent.getEndCharOffset(); return textAnnotation.getText().substring(start, end); }
static public void printTextAnnotation(PrintStream out, TextAnnotation ta) { out.println("TextAnnotation with id: " + ta.getId()); String rawText = ta.getText(); out.println("Raw Text: " + rawText); out.println(getLineFill()); out.println("TextAnnotation Views:"); for (String name : ta.getAvailableViews()) { out.println("View Name: " + name); out.println(ta.getView(name).toString()); out.println(getLineFill()); } }
static public void printTextAnnotation(PrintStream out, TextAnnotation ta) { out.println("TextAnnotation with id: " + ta.getId()); String rawText = ta.getText(); out.println("Raw Text: " + rawText); out.println(getLineFill()); out.println("TextAnnotation Views:"); for (String name : ta.getAvailableViews()) { out.println("View Name: " + name); out.println(ta.getView(name).toString()); out.println(getLineFill()); } }
protected String getNERString() { List<Constituent> constituents = new ArrayList<>(view.getConstituents()); Collections.sort(constituents, TextAnnotationUtilities.constituentStartComparator); StringBuilder sb = new StringBuilder(); String text = textAnnotation.getText(); int where = 0; for (Constituent c : constituents) { int start = c.getStartCharOffset(); String startstring = text.substring(where, start); sb.append(startstring).append("[").append(c.getLabel()).append(" ") .append(c.getTokenizedSurfaceForm()).append(" ] "); where = c.getEndCharOffset(); } return sb.toString(); } }
public void addView(TextAnnotation ta, boolean overwrite) { TextAnnotation newTA = null; try { newTA = annotate(ta.getText(), overwrite); } catch (Exception e) { e.printStackTrace(); } for (String vu : viewsToAdd) { ta.addView(vu, newTA.getView(vu)); } }
public void addView(TextAnnotation ta, boolean overwrite) { TextAnnotation newTA = null; try { newTA = annotate(ta.getText(), overwrite); } catch (Exception e) { e.printStackTrace(); } for (String vu : viewsToAdd) { ta.addView(vu, newTA.getView(vu)); } }
public VerbSenseLabeler() throws Exception { WordNetManager.loadConfigAsClasspathResource(true); log.info("Initializing pre-processor"); TextPreProcessor.initialize(); log.info("Creating manager"); manager = VerbSenseClassifierMain.getManager(false); log.info("Loading models"); loadModel(); TextAnnotation ta = initializeDummySentenceVerb(); log.info("Testing on sentence {}", ta.getText()); TokenLabelView prediction = getPrediction(ta); log.info("Output: {}", prediction.toString()); }
public VerbSenseLabeler() throws Exception { WordNetManager.loadConfigAsClasspathResource(true); log.info("Initializing pre-processor"); TextPreProcessor.initialize(); log.info("Creating manager"); manager = VerbSenseClassifierMain.getManager(false); log.info("Loading models"); loadModel(); TextAnnotation ta = initializeDummySentenceVerb(); log.info("Testing on sentence {}", ta.getText()); TokenLabelView prediction = getPrediction(ta); log.info("Output: {}", prediction.toString()); }
public TokenLabelView getPrediction(TextAnnotation ta) throws Exception { log.debug("Input: {}", ta.getText()); List<Constituent> predicates = manager.getPredicateDetector().getPredicates(ta); // If there are no verb identified, return an empty TokenLabelView if (predicates.isEmpty()) return new TokenLabelView(SenseManager.getPredictedViewName(), VerbSenseConstants.systemIdentifier, ta, 1.0); ILPSolverFactory solver = new ILPSolverFactory(ILPSolverFactory.SolverType.JLISCuttingPlaneGurobi); ILPInference inference = manager.getInference(solver, predicates); return inference.getOutputView(); } }
public TokenLabelView getPrediction(TextAnnotation ta) throws Exception { log.debug("Input: {}", ta.getText()); List<Constituent> predicates = manager.getPredicateDetector().getPredicates(ta); // If there are no verb identified, return an empty TokenLabelView if (predicates.isEmpty()) return new TokenLabelView(SenseManager.getPredictedViewName(), VerbSenseConstants.systemIdentifier, ta, 1.0); ILPSolverFactory solver = new ILPSolverFactory(ILPSolverFactory.SolverType.JLISCuttingPlaneGurobi); ILPInference inference = manager.getInference(solver, predicates); return inference.getOutputView(); } }
public PredicateArgumentView getSRL(TextAnnotation ta) throws Exception { log.debug("Input: {}", ta.getText()); List<Constituent> predicates; if (manager.getSRLType() == SRLType.Verb) predicates = manager.getHeuristicPredicateDetector().getPredicates(ta); else predicates = manager.getLearnedPredicateDetector().getPredicates(ta); if (predicates.isEmpty()) return null; ILPSolverFactory s = new ILPSolverFactory(properties.getILPSolverType(false)); SRLILPInference inference = new SRLILPInference(s, manager, predicates); return inference.getOutputView(); }
/** * given a {@link TextAnnotation} for a sentence with annotations, map its annotations into a * TextAnnotation object for a longer text containing that sentence. * @param sentenceTa annotated TextAnnotation for sentence * @param textTa TextAnnotation for longer text containing sentence, without annotations for that sentence * @param sentenceId index of the sentence in the longer text */ static public void mapSentenceAnnotationsToText(TextAnnotation sentenceTa, TextAnnotation textTa, int sentenceId ) { assert(sentenceId < textTa.getNumberOfSentences()); assert(sentenceTa.getText().equals(textTa.getSentence(sentenceId).getText())); int start = textTa.getSentence(sentenceId).getStartSpan(); int end = textTa.getSentence(sentenceId).getEndSpan(); copyViewsFromTo(sentenceTa, textTa, start, end, start); }
/** * given a {@link TextAnnotation} for a sentence with annotations, map its annotations into a * TextAnnotation object for a longer text containing that sentence. * @param sentenceTa annotated TextAnnotation for sentence * @param textTa TextAnnotation for longer text containing sentence, without annotations for that sentence * @param sentenceId index of the sentence in the longer text */ static public void mapSentenceAnnotationsToText(TextAnnotation sentenceTa, TextAnnotation textTa, int sentenceId ) { assert(sentenceId < textTa.getNumberOfSentences()); assert(sentenceTa.getText().equals(textTa.getSentence(sentenceId).getText())); int start = textTa.getSentence(sentenceId).getStartSpan(); int end = textTa.getSentence(sentenceId).getEndSpan(); copyViewsFromTo(sentenceTa, textTa, start, end, start); }