org.apache.commons.collections4.multimap.HashSetValuedHashMap Java Examples

The following examples show how to use org.apache.commons.collections4.multimap.HashSetValuedHashMap. You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: SleighAssemblerBuilder.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Invert a varnode list to a map suitable for use with {@link AssemblyStringMapTerminal}
 * 
 * @param vnlist the varnode list symbol
 * @return the inverted string map
 */
protected MultiValuedMap<String, Integer> invVarnodeList(VarnodeListSymbol vnlist) {
	MultiValuedMap<String, Integer> result = new HashSetValuedHashMap<>();
	int index = -1;
	for (VarnodeSymbol vnsym : vnlist.getVarnodeTable()) {
		index++;
		if (vnsym != null) {
			// nulls are _ in the spec, meaning the index is undefined.
			result.put(vnsym.getName(), index);
		}
	}
	return result;
}
 
Example #2
Source File: SleighAssemblerBuilder.java    From ghidra with Apache License 2.0 5 votes vote down vote up
/**
 * Invert a name table to a map suitable for use with {@link AssemblyStringMapTerminal}
 * 
 * @param ns the name symbol
 * @return the inverted string map
 */
protected MultiValuedMap<String, Integer> invNameSymbol(NameSymbol ns) {
	MultiValuedMap<String, Integer> result = new HashSetValuedHashMap<>();
	int index = -1;
	for (String name : ns.getNameTable()) {
		index++;
		if (name != null) {
			result.put(name, index);
		}
	}
	return result;
}
 
Example #3
Source File: PrimitiveUimaIndexingSupport.java    From inception with Apache License 2.0 5 votes vote down vote up
@Override
public MultiValuedMap<String, String> indexFeatureValue(String aFieldPrefix,
        AnnotationFS aAnnotation, String aFeaturePrefix, AnnotationFeature aFeature)
{
    FeatureSupport<?> featSup = featureSupportRegistry.getFeatureSupport(aFeature);
    String featureValue = featSup.renderFeatureValue(aFeature, aAnnotation);
    MultiValuedMap<String, String> values = new HashSetValuedHashMap<String, String>();
    if (isEmpty(featureValue)) {
        return values;
    }
    values.put(featureIndexName(aFieldPrefix, aFeaturePrefix, aFeature),
            featureValue);
    return values;
}
 
Example #4
Source File: RecommendationServiceImpl.java    From inception with Apache License 2.0 5 votes vote down vote up
public void removePredictions(Recommender aRecommender)
{
    // Remove incoming predictions
    if (incomingPredictions != null) {
        incomingPredictions.removePredictions(aRecommender.getId());
    }

    // Remove active predictions
    if (activePredictions != null) {
        activePredictions.removePredictions(aRecommender.getId());
    }

    // Remove trainedModel
    contexts.remove(aRecommender);

    // Remove from activeRecommenders map.
    // We have to do this, otherwise training and prediction continues for the
    // recommender when a new task is triggered.
    MultiValuedMap<AnnotationLayer, EvaluatedRecommender> newActiveRecommenders = 
            new HashSetValuedHashMap<>();
    MapIterator<AnnotationLayer, EvaluatedRecommender> it = activeRecommenders
            .mapIterator();

    while (it.hasNext()) {
        AnnotationLayer layer = it.next();
        EvaluatedRecommender rec = it.getValue();
        if (!rec.getRecommender().equals(aRecommender)) {
            newActiveRecommenders.put(layer, rec);
        }
    }
    
    setActiveRecommenders(newActiveRecommenders);
}
 
Example #5
Source File: MultiValuedMapUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenHashSetValuedHashMap_whenPuttingTwiceTheSame_thenReturningOneValue() {
    MultiValuedMap<String, String> map = new HashSetValuedHashMap<>();
    map.put("fruits", "apple");
    map.put("fruits", "apple");
  
    assertThat((Collection<String>) map.get("fruits")).containsExactly("apple");
}
 
Example #6
Source File: MapMultipleValuesUnitTest.java    From tutorials with MIT License 5 votes vote down vote up
@Test
public void givenHashSetValuedHashMap_whenPuttingTwiceTheSame_thenReturningOneValue() {
    MultiValuedMap<String, String> map = new HashSetValuedHashMap<>();
    map.put("key1", "value1");
    map.put("key1", "value1");
    assertThat((Collection<String>) map.get("key1"))
      .containsExactly("value1");
}
 
Example #7
Source File: ConceptFeatureIndexingSupport.java    From inception with Apache License 2.0 4 votes vote down vote up
@Override
public MultiValuedMap<String, String> indexFeatureValue(String aFieldPrefix,
        AnnotationFS aAnnotation, String aFeaturePrefix, AnnotationFeature aFeature)
{
    // Returns KB IRI label after checking if the
    // feature type is associated with KB and feature value is not null
    FeatureSupport<?> featSup = featureSupportRegistry.getFeatureSupport(aFeature);
    KBHandle featureObject = featSup.getFeatureValue(aFeature, aAnnotation);
    MultiValuedMap<String, String> values = new HashSetValuedHashMap<String, String>();
    
    // Feature value is not set
    if (featureObject == null) {
        return values;
    }

    // Get object from the KB
    Optional<KBObject> kbObject = kbService.readItem(aFeature.getProject(),
            WebAnnoCasUtil.getFeature(aAnnotation, aFeature.getName()));

    if (!kbObject.isPresent()) {
        return values;
    }

    String field = aFieldPrefix;
    
    // Indexing <layer>.<feature>-exact=<UI label>
    values.put(featureIndexName(field, aFeaturePrefix, aFeature),
            featureObject.getUiLabel());
    // Indexing <layer>.<feature>=<UI label>
    values.put(field + ATTRIBUTE_SEP + aFeature.getUiName(),
            featureObject.getUiLabel());
    // Indexing: <layer>.<feature>-exact=<URI>
    values.put(featureIndexName(field, aFeaturePrefix, aFeature),
            featureObject.getIdentifier());
    // Indexing: <layer>.<feature>=<URI>
    values.put(field + ATTRIBUTE_SEP + aFeature.getUiName(), featureObject.getIdentifier());

    // The following fields are used by the mentions panes on the KB page in order to find all
    // mentions of a given resource irrespective of which layer/feature they are linked to.
    // Indexing: KB.Entity=<UI label>
    values.put(KB_ENTITY, featureObject.getUiLabel());
    // Indexing: KB.Entity=<URI>
    values.put(KB_ENTITY, featureObject.getIdentifier());
    
    // Indexing super concepts with type super.concept 
    KBObject kbObj = kbObject.get();
    List<KBHandle> listParentConcepts = kbService.getParentConceptList(kbObj.getKB(),
            kbObj.getIdentifier(), false);
    for (KBHandle parentConcept : listParentConcepts) {
        if (hasImplicitNamespace(kbObj.getKB(), parentConcept.getIdentifier())) {
            continue;
        }
        values.put(field + aFeaturePrefix + ATTRIBUTE_SEP + aFeature.getUiName(),
                parentConcept.getUiLabel());
    }
    
    return values;
}
 
Example #8
Source File: TemplateImageBuilder.java    From onetwo with Apache License 2.0 4 votes vote down vote up
public HashSetValuedHashMap<String, DefinedData<?>> getDefineTables() {
	return defineTables;
}