public static CleartkExtractorException invalidTypePath(String path, Type type) { String key = KEY_PREFIX + "invalidTypePath"; return new CleartkExtractorException(DEFAULT_RESOURCE_BUNDLE, key, path, type); }
protected List<FeatureExtractor1<Markable>> getMentionExtractors(){ List<FeatureExtractor1<Markable>> extractors = new ArrayList<>(); // mention features from pairwise system: extractors.add(new MentionClusterAgreementFeaturesExtractor()); extractors.add(new MentionClusterSectionFeaturesExtractor()); extractors.add(new MentionClusterUMLSFeatureExtractor()); extractors.add(new MentionClusterDepHeadExtractor()); extractors.add(new MentionClusterSalienceFeaturesExtractor()); try { extractors.add(new MentionClusterMentionFeaturesExtractor()); } catch (CleartkExtractorException e) { e.printStackTrace(); } extractors.add(new MentionClusterAttributeFeaturesExtractor()); return extractors; }
@Override public List<org.cleartk.ml.Feature> extract(JCas view, Annotation focusAnnotation) throws CleartkExtractorException { if (this.type == null) this.type = JCasUtil.getType(view, this.focusClass); this.typeSystem = view.getTypeSystem(); if (!isValidPath(view)) throw CleartkExtractorException.invalidTypePath(path, type); String[] pathMembers = path.split("/"); List<Object> pathValues = new ArrayList<Object>(); _extract(view, focusAnnotation, pathMembers, pathValues); List<org.cleartk.ml.Feature> returnValues = new ArrayList<org.cleartk.ml.Feature>(); Set<Object> values = new HashSet<Object>(); for (Object pathValue : pathValues) { if (!uniqueValues || !values.contains(pathValue)) { returnValues.add(new TypePathFeature(null, pathValue, this.path, this.featureName)); values.add(pathValue); } } return returnValues; }
private static Object[] getPrimitiveArrayFeatureValue( JCas view, FeatureStructure featureStructure, Feature feature) throws CleartkExtractorException { TypeSystem typeSystem = view.getTypeSystem(); Type type = feature.getRange(); if (type.isArray()) { Type componentType = type.getComponentType(); FeatureStructure featureValue = featureStructure.getFeatureValue(feature); if (componentType.equals(typeSystem.getType("uima.cas.String"))) { return ((StringArray) featureValue).toArray(); } else if (componentType.equals(typeSystem.getType("uima.cas.Boolean"))) { return Arrays.asList(((BooleanArray) featureValue).toArray()).toArray(); } else if (componentType.equals(typeSystem.getType("uima.cas.Double"))) { return Arrays.asList(((DoubleArray) featureValue).toArray()).toArray(); } else if (componentType.equals(typeSystem.getType("uima.cas.Float"))) { return Arrays.asList(((FloatArray) featureValue).toArray()).toArray(); } else if (componentType.equals(typeSystem.getType("uima.cas.Byte"))) { return Arrays.asList(((ByteArray) featureValue).toArray()).toArray(); } else if (componentType.equals(typeSystem.getType("uima.cas.Short"))) { return Arrays.asList(((ShortArray) featureValue).toArray()).toArray(); } else if (componentType.equals(typeSystem.getType("uima.cas.Integer"))) { return Arrays.asList(((IntegerArray) featureValue).toArray()).toArray(); } else if (componentType.equals(typeSystem.getType("uima.cas.Long"))) { return Arrays.asList(((LongArray) featureValue).toArray()).toArray(); } } else throw CleartkExtractorException.notPrimitiveArray(feature); return null; }
return featureStructure.getStringValue(feature); else throw CleartkExtractorException.notPrimitive(feature);
protected List<FeatureExtractor1<Markable>> getMentionExtractors(){ List<FeatureExtractor1<Markable>> extractors = new ArrayList<>(); // mention features from pairwise system: extractors.add(new MentionClusterAgreementFeaturesExtractor()); extractors.add(new MentionClusterSectionFeaturesExtractor()); extractors.add(new MentionClusterUMLSFeatureExtractor()); extractors.add(new MentionClusterDepHeadExtractor()); extractors.add(new MentionClusterSalienceFeaturesExtractor()); try { extractors.add(new MentionClusterMentionFeaturesExtractor()); } catch (CleartkExtractorException e) { e.printStackTrace(); } extractors.add(new MentionClusterAttributeFeaturesExtractor()); return extractors; }
public static CleartkExtractorException moreThanOneName(String name1, String name2) { String key = KEY_PREFIX + "moreThanOneName"; return new CleartkExtractorException(DEFAULT_RESOURCE_BUNDLE, key, name1, name2); }
public static CleartkExtractorException wrongAnnotationType( Class<? extends Annotation> expectedType, Annotation actualAnnotation) { String key = KEY_PREFIX + "wrongAnnotationType"; return new CleartkExtractorException( DEFAULT_RESOURCE_BUNDLE, key, expectedType.getName(), actualAnnotation); }
public static CleartkExtractorException wrongNumberOfAnnotations( Class<? extends Annotation> expectedType, int expectedNumber, int actualNumber) { String key = KEY_PREFIX + "wrongNumberOfAnnotations"; return new CleartkExtractorException( DEFAULT_RESOURCE_BUNDLE, key, expectedType.getName(), expectedNumber, actualNumber); }
public static CleartkExtractorException noAnnotationInWindow( Class<? extends Annotation> expectedType, Annotation window) { String key = KEY_PREFIX + "noAnnotationInWindow"; return new CleartkExtractorException( DEFAULT_RESOURCE_BUNDLE, key, expectedType.getName(), window); }
public static CleartkExtractorException noAnnotationMatchingWindow( Class<? extends Annotation> expectedType, Annotation window) { String key = KEY_PREFIX + "noAnnotationMatchingWindow"; return new CleartkExtractorException( DEFAULT_RESOURCE_BUNDLE, key, expectedType.getName(), window); }
public ContinuousTextExtractor(String vecFile) throws CleartkExtractorException { super(); try { words = WordVectorReader.getEmbeddings(FileLocator.getAsStream(vecFile)); } catch (IOException e) { e.printStackTrace(); throw new CleartkExtractorException(e); } }
public ContinuousTextExtractor(String vecFile) throws CleartkExtractorException { super(); try { words = WordVectorReader.getEmbeddings(FileLocator.getAsStream(vecFile)); } catch (IOException e) { e.printStackTrace(); throw new CleartkExtractorException(e); } }
public ContinuousTextExtractor(String vecFile, OovStrategy oovStrategy) throws CleartkExtractorException { super(); try { words = WordVectorReader.getEmbeddings(FileLocator.getAsStream(vecFile)); } catch (IOException e) { e.printStackTrace(); throw new CleartkExtractorException(e); } this.oovStrategy = oovStrategy; } @Override
public ContinuousTextExtractor(String vecFile, OovStrategy oovStrategy) throws CleartkExtractorException { super(); try { words = WordVectorReader.getEmbeddings(FileLocator.getAsStream(vecFile)); } catch (IOException e) { e.printStackTrace(); throw new CleartkExtractorException(e); } this.oovStrategy = oovStrategy; } @Override
public static CleartkExtractorException notPrimitive(Feature feature) { String key = KEY_PREFIX + "notPrimitive"; return new CleartkExtractorException( DEFAULT_RESOURCE_BUNDLE, key, feature.getDomain(), feature.getRange()); }
public static CleartkExtractorException notPrimitiveArray(Feature feature) { String key = KEY_PREFIX + "notPrimitiveArray"; return new CleartkExtractorException( DEFAULT_RESOURCE_BUNDLE, key, feature.getDomain(), feature.getRange()); }
@Override public List<Feature> extract( JCas jcas, IdentifiedAnnotation focusAnnotation) throws CleartkExtractorException { List<Feature> feats = new ArrayList<>(); Sentence sent = _sentence; List<ConllDependencyNode> nodes = DependencyUtility.getDependencyNodes(jcas, sent); ConllDependencyNode headNode = DependencyUtility.getNominalHeadNode(jcas, focusAnnotation); try { boolean[] regexFeats = conAnal.findNegationContext(nodes, headNode); for(int j = 0; j < regexFeats.length; j++){ if(regexFeats[j]){ feats.add(new Feature("DepPath_" + conAnal.getRegexName(j))); //"NEG_DEP_REGEX_"+j)); } } } catch (Exception e) { e.printStackTrace(); throw new CleartkExtractorException(e); } return feats; }
@Override public List<Feature> extract(JCas jcas, IdentifiedAnnotation focusAnnotation) throws CleartkExtractorException { List<Feature> feats = new ArrayList<>(); Sentence sent = null; List<Sentence> sents = JCasUtil.selectCovering(jcas, Sentence.class, focusAnnotation.getBegin(), focusAnnotation.getEnd()); if(sents != null && sents.size() > 0){ sent = sents.get(0); }else{ return feats; } List<ConllDependencyNode> nodes = DependencyUtility.getDependencyNodes(jcas, sent); ConllDependencyNode headNode = DependencyUtility.getNominalHeadNode(jcas, focusAnnotation); try { boolean[] regexFeats = conAnal.findNegationContext(nodes, headNode); for(int j = 0; j < regexFeats.length; j++){ if(regexFeats[j]){ feats.add(new Feature("DepPath_" + conAnal.getRegexName(j))); //"NEG_DEP_REGEX_"+j)); } } } catch (Exception e) { e.printStackTrace(); throw new CleartkExtractorException(e); } return feats; }
@Override public List<Feature> extract(JCas jcas, IdentifiedAnnotation focusAnnotation) throws CleartkExtractorException { List<Feature> feats = new ArrayList<>(); Sentence sent = null; List<Sentence> sents = JCasUtil.selectCovering(jcas, Sentence.class, focusAnnotation.getBegin(), focusAnnotation.getEnd()); if(sents != null && sents.size() > 0){ sent = sents.get(0); }else{ return feats; } List<ConllDependencyNode> nodes = DependencyUtility.getDependencyNodes(jcas, sent); ConllDependencyNode headNode = DependencyUtility.getNominalHeadNode(jcas, focusAnnotation); try { boolean[] regexFeats = conAnal.findNegationContext(nodes, headNode); for(int j = 0; j < regexFeats.length; j++){ if(regexFeats[j]){ feats.add(new Feature("DepPath_" + conAnal.getRegexName(j))); //"NEG_DEP_REGEX_"+j)); } } } catch (Exception e) { e.printStackTrace(); throw new CleartkExtractorException(e); } return feats; }