@Override public void process(JCas jCas) throws AnalysisEngineProcessException { for (IdentifiedAnnotation mention : JCasUtil.select(jCas, IdentifiedAnnotation.class)) { Boolean oldgeneric = mention.getGeneric(); mention.setGeneric( GenericAttributeClassifier.getGeneric(jCas, mention) ); // System.err.println("Word:"+mention.getCoveredText()+", overwrote generic "+oldgeneric+" with "+mention.getGeneric()); } } }
@Override public void process(JCas jCas) throws AnalysisEngineProcessException { for (IdentifiedAnnotation mention : JCasUtil.select(jCas, IdentifiedAnnotation.class)) { Boolean oldgeneric = mention.getGeneric(); mention.setGeneric( GenericAttributeClassifier.getGeneric(jCas, mention) ); // System.err.println("Word:"+mention.getCoveredText()+", overwrote generic "+oldgeneric+" with "+mention.getGeneric()); } } }
private void checkForAttrValue(IdentifiedAnnotation eMention, String role, String value) { if (role.contains("_normalization")) { if (role.startsWith("conditional")) { eMention.setConditional(Boolean.valueOf(value)); } else if (role.startsWith("generic")) { eMention.setGeneric(Boolean.valueOf(value)); } else if (role.startsWith("negation_indicator")) { // assumes that the string from Knowtator is exactly "negation_present" if (value.equals("negation_present")) { eMention.setPolarity(CONST.NE_POLARITY_NEGATION_PRESENT); } else { eMention.setPolarity(CONST.NE_POLARITY_NEGATION_ABSENT); } } else if (role.startsWith("subject")) { // assumes that the strings from Knowtator are exactly what's in the type system eMention.setSubject(value); } else if (role.startsWith("uncertainty_indicator")) { // assumes that the string from Knowtator is exactly "indicator_present" if (value.equals("indicator_present")) { eMention.setUncertainty(CONST.NE_UNCERTAINTY_PRESENT); } else { eMention.setUncertainty(CONST.NE_UNCERTAINTY_ABSENT); } } else if (role.startsWith("generic")) { eMention.setGeneric(Boolean.valueOf(value)); } } }
private void checkForAttrValue(IdentifiedAnnotation eMention, String role, String value) { if (role.contains("_normalization")) { if (role.startsWith("conditional")) { eMention.setConditional(Boolean.valueOf(value)); } else if (role.startsWith("generic")) { eMention.setGeneric(Boolean.valueOf(value)); } else if (role.startsWith("negation_indicator")) { // assumes that the string from Knowtator is exactly "negation_present" if (value.equals("negation_present")) { eMention.setPolarity(CONST.NE_POLARITY_NEGATION_PRESENT); } else { eMention.setPolarity(CONST.NE_POLARITY_NEGATION_ABSENT); } } else if (role.startsWith("subject")) { // assumes that the strings from Knowtator are exactly what's in the type system eMention.setSubject(value); } else if (role.startsWith("uncertainty_indicator")) { // assumes that the string from Knowtator is exactly "indicator_present" if (value.equals("indicator_present")) { eMention.setUncertainty(CONST.NE_UNCERTAINTY_PRESENT); } else { eMention.setUncertainty(CONST.NE_UNCERTAINTY_ABSENT); } } else if (role.startsWith("generic")) { eMention.setGeneric(Boolean.valueOf(value)); } } }
@Override public void setClassLabel( IdentifiedAnnotation entityOrEventMention, Instance<String> instance ) throws AnalysisEngineProcessException { if ( this.isTraining() ) { boolean generic = entityOrEventMention.getGeneric(); // downsampling. initialize probabilityOfKeepingADefaultExample to 1.0 for no downsampling if ( !generic && coin.nextDouble() >= this.probabilityOfKeepingADefaultExample ) { return; } instance.setOutcome( "" + generic ); } else { String label = this.classifier.classify( instance.getFeatures() ); entityOrEventMention.setGeneric( Boolean.parseBoolean( label ) ); } }
@Override public void setClassLabel(IdentifiedAnnotation entityOrEventMention, Instance<String> instance) throws AnalysisEngineProcessException { if (this.isTraining()) { boolean generic = entityOrEventMention.getGeneric(); // downsampling. initialize probabilityOfKeepingADefaultExample to 1.0 for no downsampling if (!generic && coin.nextDouble() >= this.probabilityOfKeepingADefaultExample) { return; } instance.setOutcome(""+generic); } else { String label = this.classifier.classify(instance.getFeatures()); entityOrEventMention.setGeneric(Boolean.parseBoolean(label)); } } public static FeatureSelection<String> createFeatureSelection(double threshold) {
@Override public void setClassLabel(IdentifiedAnnotation entityOrEventMention, Instance<String> instance) throws AnalysisEngineProcessException { if (this.isTraining()) { boolean generic = entityOrEventMention.getGeneric(); // downsampling. initialize probabilityOfKeepingADefaultExample to 1.0 for no downsampling if (!generic && coin.nextDouble() >= this.probabilityOfKeepingADefaultExample) { return; } instance.setOutcome(""+generic); } else { String label = this.classifier.classify(instance.getFeatures()); entityOrEventMention.setGeneric(Boolean.parseBoolean(label)); } } public static FeatureSelection<String> createFeatureSelection(double threshold) {
static private void fillProperties( final IdentifiedAnnotation annotation, final int polarity, final int uncertainty, final boolean generic, final boolean conditional, final String subject, final float confidence ) { annotation.setPolarity( polarity ); annotation.setUncertainty( uncertainty ); annotation.setGeneric( generic ); annotation.setConditional( conditional ); annotation.setSubject( subject ); annotation.setConfidence( confidence ); }
static private void fillProperties( final IdentifiedAnnotation annotation, final int polarity, final int uncertainty, final boolean generic, final boolean conditional, final String subject, final float confidence ) { annotation.setPolarity( polarity ); annotation.setUncertainty( uncertainty ); annotation.setGeneric( generic ); annotation.setConditional( conditional ); annotation.setSubject( subject ); annotation.setConfidence( confidence ); }
break; case GENERIC: mention.setGeneric(CONST.NE_GENERIC_FALSE); break; case HISTORYOF:
break; case GENERIC: mention.setGeneric(CONST.NE_GENERIC_FALSE); break; case HISTORYOF:
annotation.setUncertainty(-2); annotation.setConditional(false); annotation.setGeneric(false); annotation.setUncertainty(0); annotation.setConditional(false); annotation.setGeneric(false); annotation.setUncertainty(0); annotation.setConditional(false); annotation.setGeneric(false); annotation.setUncertainty(0); annotation.setConditional(false); annotation.setGeneric(false); annotation.setUncertainty(0); annotation.setConditional(false); annotation.setGeneric(false); annotation.setUncertainty(0); annotation.setConditional(true); // NOT DEFAULT VALUE annotation.setGeneric(false); annotation.setUncertainty(1); // NOT DEFAULT VALUE annotation.setConditional(false); annotation.setGeneric(false); } else
annotation.setUncertainty(-2); annotation.setConditional(false); annotation.setGeneric(false); annotation.setUncertainty(0); annotation.setConditional(false); annotation.setGeneric(false); annotation.setUncertainty(0); annotation.setConditional(false); annotation.setGeneric(false); annotation.setUncertainty(0); annotation.setConditional(false); annotation.setGeneric(false); annotation.setUncertainty(0); annotation.setConditional(false); annotation.setGeneric(false); annotation.setUncertainty(0); annotation.setConditional(true); // NOT DEFAULT VALUE annotation.setGeneric(false); annotation.setUncertainty(1); // NOT DEFAULT VALUE annotation.setConditional(false); annotation.setGeneric(false); } else
break; case GENERIC: m.setGeneric(mention.getGeneric()); break; case HISTORYOF:
break; case GENERIC: m.setGeneric(mention.getGeneric()); break; case HISTORYOF:
/** * * @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(); }
extensions.addAll( resource.getModifierExtension() ); if ( FhirElementParser.hasExtension( GENERIC_EXT, extensions ) ) { annotation.setGeneric( true );
mention.setConfidence(original.getConfidence()); mention.setDiscoveryTechnique(original.getDiscoveryTechnique()); mention.setGeneric(original.getGeneric()); mention.setOntologyConceptArr(original.getOntologyConceptArr()); mention.setPolarity(original.getPolarity());