public static List<Feature> getCharFeatures(char ch, String prefix){ List<Feature> feats = new ArrayList<>(); feats.add(new Feature(prefix+"_Id", ch == '\n' ? "<LF>" : ch)); feats.add(new Feature(prefix+"_Upper", Character.isUpperCase(ch))); feats.add(new Feature(prefix+"_Lower", Character.isLowerCase(ch))); feats.add(new Feature(prefix+"_Digit", Character.isDigit(ch))); feats.add(new Feature(prefix+"_Space", Character.isWhitespace(ch))); feats.add(new Feature(prefix+"_Type"+Character.getType(ch), true)); return feats; }
private static Collection<? extends Feature> hashToFeatureList( HashMap<String, Boolean> featsIn) { Collection<Feature> featsOut = new HashSet<>(); for (String featName : featsIn.keySet()) { featsOut.add(new Feature(featName,featsIn.get(featName))); } return featsOut; }
private static Collection<? extends Feature> hashToFeatureList( HashMap<String, Boolean> featsIn) { Collection<Feature> featsOut = new HashSet<>(); for (String featName : featsIn.keySet()) { featsOut.add(new Feature(featName,featsIn.get(featName))); } return featsOut; }
private static Collection<? extends Feature> hashToFeatureList( HashMap<String, Boolean> featsIn ) { Collection<Feature> featsOut = new HashSet<>(); for ( String featName : featsIn.keySet() ) { featsOut.add( new Feature( featName, featsIn.get( featName ) ) ); } return featsOut; }
private static Collection<? extends Feature> hashToFeatureList( HashMap<String, Boolean> featsIn) { Collection<Feature> featsOut = new HashSet<>(); for (String featName : featsIn.keySet()) { featsOut.add(new Feature(featName,featsIn.get(featName))); } return featsOut; }
private static Collection<? extends Feature> hashToFeatureList( HashMap<String, Boolean> featsIn) { Collection<Feature> featsOut = new HashSet<>(); for (String featName : featsIn.keySet()) { featsOut.add(new Feature(featName,featsIn.get(featName))); } return featsOut; }
private static Collection<? extends Feature> hashToFeatureList( HashMap<String, Boolean> featsIn) { Collection<Feature> featsOut = new HashSet<>(); for (String featName : featsIn.keySet()) { featsOut.add(new Feature(featName,featsIn.get(featName))); } return featsOut; }
public List<Feature> extract(JCas view, T focusAnnotation) throws CleartkExtractorException { if (strList.contains(focusAnnotation.getCoveredText())) return Arrays.asList(new Feature(fName)); else return Arrays.asList(); }
@Override public List<Feature> extract(JCas jCas, Markable mention) throws CleartkExtractorException { List<Feature> feats = new ArrayList<>(); feats.add(new Feature("MC_MENTION_SALIENCE", mention.getConfidence())); return feats; }
@Override public List<Feature> extract(JCas jCas, Annotation ann) throws CleartkExtractorException { IdentifiedAnnotation idAnn = (IdentifiedAnnotation)ann; return Arrays.asList(new Feature("TypeID", String.valueOf(idAnn.getTypeID()))); } };
@Override public List<Feature> extract(JCas view, IdentifiedAnnotation focusAnnotation) throws CleartkExtractorException { List<Feature> featList = new ArrayList<>(); IdentifiedAnnotation mention = focusAnnotation; featList.add(new Feature("IsNegated", mention.getPolarity() == CONST.NE_POLARITY_NEGATION_PRESENT)); return featList; }
@Override public List<Feature> extract(JCas jCas, Annotation ann) throws CleartkExtractorException { IdentifiedAnnotation idAnn = (IdentifiedAnnotation)ann; return Arrays.asList(new Feature("TypeID", String.valueOf(idAnn.getTypeID()))); } };
@Override public List<Feature> apply(@Nullable Feature input) { String featureName = Feature.createName(DEFAULT_NAME, input.getName()); Object featureValue = input.getValue(); if(featureValue instanceof String){ return Collections.singletonList(new Feature(featureName, word2class.containsKey(featureValue) ? word2class.get(featureValue) : "NoCluster")); } return Collections.emptyList(); }
@Override public List<Feature> apply(@Nullable Feature input) { String featureName = Feature.createName(DEFAULT_NAME, input.getName()); Object featureValue = input.getValue(); if(featureValue instanceof String){ return Collections.singletonList(new Feature(featureName, word2class.containsKey(featureValue) ? word2class.get(featureValue) : "NoCluster")); } return Collections.emptyList(); }
@Override public List<Feature> extract(JCas jCas, IdentifiedAnnotation arg1, IdentifiedAnnotation arg2) throws AnalysisEngineProcessException { List<Feature> feats = new ArrayList<>(); feats.add(new Feature("TOK_DIST", JCasUtil.selectCovered(jCas, BaseToken.class, arg1.getBegin(), arg2.getEnd()).size() / (double)CorefConsts.TOKDIST)); feats.add(new Feature("SENT_DIST", JCasUtil.selectCovered(jCas, Sentence.class, arg1.getBegin(), arg2.getEnd()).size() / (double) CorefConsts.NEDIST)); return feats; }
@Override public List<Feature> extract(JCas jCas, Markable mention) throws CleartkExtractorException { List<Feature> feats = new ArrayList<>(); ConllDependencyNode mentionHead = MapFactory.get(getKey(jCas), mention); if(mentionHead != null){ feats.add(new Feature("MentionRel", mentionHead.getDeprel())); } return feats; }
@Override public List<Feature> extract(JCas view, Annotation focusAnnotation) throws CleartkExtractorException { String text = focusAnnotation.getCoveredText(); return ccpf.apply(new Feature(null, text)); }
public ContextFeature(String baseName, int position, int oobPosition, String featureName) { this.feature = new Feature(featureName, String.format(Locale.ROOT, "OOB%d", oobPosition)); this.setName(Feature.createName(baseName, String.valueOf(position), featureName)); this.setValue(this.feature.getValue()); }
public WindowedContextFeature( String baseName, int position, int oobPosition, String featureName ) { this.feature = new Feature( featureName, String.format( Locale.ROOT, "OOB%d", oobPosition ) ); this.setName( Feature.createName( baseName, String.valueOf( position ), featureName ) ); this.setValue( this.feature.getValue() ); }
@Override protected Feature transform(Feature feature) { int tf = (Integer) feature.getValue(); double tfidf = tf * this.idfMap.getIDF(feature.getName()); return new Feature("TF-IDF_" + feature.getName(), tfidf); }