public static boolean isPatient(IdentifiedAnnotation mention){ return mention.getSubject() == CONST.ATTR_SUBJECT_PATIENT; }
public static boolean isPatient(IdentifiedAnnotation mention){ return mention.getSubject() == CONST.ATTR_SUBJECT_PATIENT; }
static private String createBsvLine( final IdentifiedAnnotation annotation, final UmlsConcept concept, final String locationCuis ) { final StringBuilder sb = new StringBuilder(); sb.append( concept.getCode() ).append( '|' ) .append( concept.getPreferredText() ).append( '|' ) .append( SemanticTui.getTuiFromCode( concept.getTui() ).getGroupName() ).append( '|' ) .append( annotation.getPolarity() == CONST.NE_POLARITY_NEGATION_PRESENT ? "true" : "false" ).append( '|' ) .append( annotation.getSubject().equals( CONST.ATTR_SUBJECT_FAMILY_MEMBER ) ? "true" : "false" ).append( '|' ) .append( locationCuis ).append( '|' ) .append( annotation.getCoveredText() ); return sb.toString(); }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { for (IdentifiedAnnotation mention : JCasUtil.select(jCas, IdentifiedAnnotation.class)) { // For each mention, set the subject attribute // if (mention.getGeneric() == true ) { // mention.setSubject (null); // } else { String oldsubj = mention.getSubject(); mention.setSubject( SubjectAttributeClassifier.getSubject(jCas, mention) ); // System.err.println("Word:"+mention.getCoveredText()+", overwrote subject "+oldsubj+" with "+mention.getSubject()); // } } } }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { for (IdentifiedAnnotation mention : JCasUtil.select(jCas, IdentifiedAnnotation.class)) { // For each mention, set the subject attribute // if (mention.getGeneric() == true ) { // mention.setSubject (null); // } else { String oldsubj = mention.getSubject(); mention.setSubject( SubjectAttributeClassifier.getSubject(jCas, mention) ); // System.err.println("Word:"+mention.getCoveredText()+", overwrote subject "+oldsubj+" with "+mention.getSubject()); // } } } }
@Override public void setValueFrom(Map<String, ? extends TOP> annotationMap) { super.setValueFrom(annotationMap); if (mention.getSubject() == null) { mention.setSubject(CONST.ATTR_SUBJECT_PATIENT); } } });
@Override public void setValueFrom(Map<String, ? extends TOP> annotationMap) { super.setValueFrom(annotationMap); if (mention.getSubject() == null) { mention.setSubject(CONST.ATTR_SUBJECT_PATIENT); } } });
@Override public void setValueFrom(Map<String, ? extends TOP> annotationMap) { super.setValueFrom(annotationMap); if (mention.getSubject() == null) { mention.setSubject(CONST.ATTR_SUBJECT_PATIENT); } } });
@Override public void setValueFrom(Map<String, ? extends TOP> annotationMap) { super.setValueFrom(annotationMap); if (mention.getSubject() == null) { mention.setSubject(CONST.ATTR_SUBJECT_PATIENT); } } });
@Override public void setClassLabel(IdentifiedAnnotation entityOrEventMention, Instance<String> instance) throws AnalysisEngineProcessException { if (this.isTraining()) { String subj = entityOrEventMention.getSubject(); // downsampling. initialize probabilityOfKeepingADefaultExample to 1.0 for no downsampling if ("patient".equals(subj) && coin.nextDouble() >= this.probabilityOfKeepingADefaultExample) { return; } instance.setOutcome(subj); logger.log(Level.DEBUG, String.format("[%s] expected: ''; actual: ''; features: %s", this.getClass().getSimpleName(), instance.toString() )); } else { String label = this.classifier.classify(instance.getFeatures()); entityOrEventMention.setSubject(label); logger.log(Level.DEBUG, "SUBJECT is being set on an IdentifiedAnnotation: "+label+" "+entityOrEventMention.getSubject()); } } public static FeatureSelection<String> createFeatureSelection(double threshold) {
private String getAttrValueString(IdentifiedAnnotation mention, Selector s) { switch (s) { case CONDITIONAL: return String.valueOf(mention.getConditional()); case GENERIC: return String.valueOf(mention.getGeneric()); case HISTORYOF: return String.valueOf(mention.getHistoryOf()); case POLARITY: return String.valueOf(mention.getPolarity()); case SUBJECT: return String.valueOf(mention.getSubject()); case UNCERTAINTY: return String.valueOf(mention.getUncertainty()); default: return "?"; } }
@Override public void setClassLabel( IdentifiedAnnotation entityOrEventMention, Instance<String> instance ) throws AnalysisEngineProcessException { if ( this.isTraining() ) { String subj = entityOrEventMention.getSubject(); // downsampling. initialize probabilityOfKeepingADefaultExample to 1.0 for no downsampling if ( "patient".equals( subj ) && coin.nextDouble() >= this.probabilityOfKeepingADefaultExample ) { return; } instance.setOutcome( subj ); logger.log( Level.DEBUG, String.format( "[%s] expected: ''; actual: ''; features: %s", this.getClass().getSimpleName(), instance.toString() ) ); } else { String label = this.classifier.classify( instance.getFeatures() ); entityOrEventMention.setSubject( label ); logger.log( Level.DEBUG, "SUBJECT is being set on an IdentifiedAnnotation: " + label + " " + entityOrEventMention.getSubject() ); } }
private String getAttrValueString(IdentifiedAnnotation mention, Selector s) { switch (s) { case CONDITIONAL: return String.valueOf(mention.getConditional()); case GENERIC: return String.valueOf(mention.getGeneric()); case HISTORYOF: return String.valueOf(mention.getHistoryOf()); case POLARITY: return String.valueOf(mention.getPolarity()); case SUBJECT: return String.valueOf(mention.getSubject()); case UNCERTAINTY: return String.valueOf(mention.getUncertainty()); default: return "?"; } }
@Override public void setClassLabel(IdentifiedAnnotation entityOrEventMention, Instance<String> instance) throws AnalysisEngineProcessException { if (this.isTraining()) { String subj = entityOrEventMention.getSubject(); // downsampling. initialize probabilityOfKeepingADefaultExample to 1.0 for no downsampling if ("patient".equals(subj) && coin.nextDouble() >= this.probabilityOfKeepingADefaultExample) { return; } instance.setOutcome(subj); logger.log(Level.DEBUG, String.format("[%s] expected: ''; actual: ''; features: %s", this.getClass().getSimpleName(), instance.toString() )); } else { String label = this.classifier.classify(instance.getFeatures()); entityOrEventMention.setSubject(label); logger.log(Level.DEBUG, "SUBJECT is being set on an IdentifiedAnnotation: "+label+" "+entityOrEventMention.getSubject()); } } public static FeatureSelection<String> createFeatureSelection(double threshold) {
private void printContext(String text, IdentifiedAnnotation mention, int radius) { int mentionBegin = mention.getBegin(); int mentionEnd = mention.getEnd(); StringBuilder sb = new StringBuilder(); int snipBegin; int snipEnd; snipBegin = (mentionBegin-radius<0)? 0 : mentionBegin-radius; snipEnd = (mentionEnd+radius>text.length()-1)? text.length()-1 : mentionEnd+radius; String[] tmp = mention.getClass().getName().split("\\."); String semGroup = tmp[tmp.length-1]; sb.append(text.substring(snipBegin, mentionBegin)); sb.append("[[["+mention.getCoveredText()+"]]]"); sb.append(text.substring(mentionEnd, snipEnd)); // sb.toString().replaceAll("\\n", "\\n| "); System.out.println("| "+ sb.toString().replaceAll("\\n", "\n| ")); System.out.println(": "+ semGroup + " : beg=" + mention.getBegin() + " : end=" + mention.getEnd() + " : c=" + mention.getConditional() + " : g=" + mention.getGeneric() + " : h=" + mention.getHistoryOf() + " : p=" + mention.getPolarity() + " : s=" + mention.getSubject() + " : u=" + mention.getUncertainty()); }
private void printContext(String text, IdentifiedAnnotation mention, int radius) { int mentionBegin = mention.getBegin(); int mentionEnd = mention.getEnd(); StringBuilder sb = new StringBuilder(); int snipBegin; int snipEnd; snipBegin = (mentionBegin-radius<0)? 0 : mentionBegin-radius; snipEnd = (mentionEnd+radius>text.length()-1)? text.length()-1 : mentionEnd+radius; String[] tmp = mention.getClass().getName().split("\\."); String semGroup = tmp[tmp.length-1]; sb.append(text.substring(snipBegin, mentionBegin)); sb.append("[[["+mention.getCoveredText()+"]]]"); sb.append(text.substring(mentionEnd, snipEnd)); // sb.toString().replaceAll("\\n", "\\n| "); System.out.println("| "+ sb.toString().replaceAll("\\n", "\n| ")); System.out.println(": "+ semGroup + " : beg=" + mention.getBegin() + " : end=" + mention.getEnd() + " : c=" + mention.getConditional() + " : g=" + mention.getGeneric() + " : h=" + mention.getHistoryOf() + " : p=" + mention.getPolarity() + " : s=" + mention.getSubject() + " : u=" + mention.getUncertainty()); }
private Entity( final IdentifiedAnnotation annotation ) { _begin = annotation.getBegin(); _end = annotation.getEnd(); _coveredText = annotation.getCoveredText(); _polarity = annotation.getPolarity(); _uncertainty = annotation.getUncertainty(); _conditional = annotation.getConditional(); _generic = annotation.getGeneric(); _subject = annotation.getSubject(); _historyOf = annotation.getHistoryOf(); }
private Entity( final IdentifiedAnnotation annotation ) { _begin = annotation.getBegin(); _end = annotation.getEnd(); _coveredText = annotation.getCoveredText(); _polarity = annotation.getPolarity(); _uncertainty = annotation.getUncertainty(); _conditional = annotation.getConditional(); _generic = annotation.getGeneric(); _subject = annotation.getSubject(); _historyOf = annotation.getHistoryOf(); }
/** * * @param goldAnnotation * @param jcas */ private static void copyAnnotation(Annotation goldAnnotation, JCas jcas) { Annotation newAnno; if (goldAnnotation instanceof IdentifiedAnnotation) { IdentifiedAnnotation ia = new IdentifiedAnnotation(jcas); ia.setConditional(((IdentifiedAnnotation) goldAnnotation).getConditional()); ia.setConfidence(((IdentifiedAnnotation) goldAnnotation).getConfidence()); ia.setDiscoveryTechnique(((IdentifiedAnnotation)goldAnnotation).getDiscoveryTechnique()); ia.setGeneric(((IdentifiedAnnotation) goldAnnotation).getGeneric()); ia.setHistoryOf(((IdentifiedAnnotation) goldAnnotation).getHistoryOf()); ia.setPolarity(((IdentifiedAnnotation) goldAnnotation).getPolarity()); ia.setSegmentID(((IdentifiedAnnotation) goldAnnotation).getSegmentID()); ia.setSentenceID(((IdentifiedAnnotation) goldAnnotation).getSentenceID()); ia.setSubject(((IdentifiedAnnotation) goldAnnotation).getSubject()); ia.setTypeID(((IdentifiedAnnotation) goldAnnotation).getTypeID()); ia.setUncertainty(((IdentifiedAnnotation) goldAnnotation).getUncertainty()); newAnno = ia; } else { throw new RuntimeException("Unexpected class of object " + goldAnnotation.getClass()); } newAnno.setBegin(goldAnnotation.getBegin()); newAnno.setEnd(goldAnnotation.getEnd()); newAnno.addToIndexes(); }
/** * * @param goldAnnotation * @param jcas */ private static void copyAnnotation(Annotation goldAnnotation, JCas jcas) { Annotation newAnno; if (goldAnnotation instanceof IdentifiedAnnotation) { IdentifiedAnnotation ia = new IdentifiedAnnotation(jcas); ia.setConditional(((IdentifiedAnnotation) goldAnnotation).getConditional()); ia.setConfidence(((IdentifiedAnnotation) goldAnnotation).getConfidence()); ia.setDiscoveryTechnique(((IdentifiedAnnotation)goldAnnotation).getDiscoveryTechnique()); ia.setGeneric(((IdentifiedAnnotation) goldAnnotation).getGeneric()); ia.setHistoryOf(((IdentifiedAnnotation) goldAnnotation).getHistoryOf()); ia.setPolarity(((IdentifiedAnnotation) goldAnnotation).getPolarity()); ia.setSegmentID(((IdentifiedAnnotation) goldAnnotation).getSegmentID()); ia.setSentenceID(((IdentifiedAnnotation) goldAnnotation).getSentenceID()); ia.setSubject(((IdentifiedAnnotation) goldAnnotation).getSubject()); ia.setTypeID(((IdentifiedAnnotation) goldAnnotation).getTypeID()); ia.setUncertainty(((IdentifiedAnnotation) goldAnnotation).getUncertainty()); newAnno = ia; } else { throw new RuntimeException("Unexpected class of object " + goldAnnotation.getClass()); } newAnno.setBegin(goldAnnotation.getBegin()); newAnno.setEnd(goldAnnotation.getEnd()); newAnno.addToIndexes(); }