当前位置: 首页>>代码示例>>Java>>正文


Java ObjectOpenHashSet.add方法代码示例

本文整理汇总了Java中it.unimi.dsi.fastutil.objects.ObjectOpenHashSet.add方法的典型用法代码示例。如果您正苦于以下问题:Java ObjectOpenHashSet.add方法的具体用法?Java ObjectOpenHashSet.add怎么用?Java ObjectOpenHashSet.add使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在it.unimi.dsi.fastutil.objects.ObjectOpenHashSet的用法示例。


在下文中一共展示了ObjectOpenHashSet.add方法的10个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。

示例1: getSortedWordsFromListOfEdges

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; //导入方法依赖的package包/类
/**
 * Given a list of edges, get all the indexed words from them (their nodes) and return them sorted by index
 * @param edges: list of edges
 * @return list of indexed words sorted by index
 */
public static ObjectArrayList<IndexedWord> getSortedWordsFromListOfEdges(Set<SemanticGraphEdge> edges){
    ObjectOpenHashSet<IndexedWord> wordsSet = new ObjectOpenHashSet<>();
    for (SemanticGraphEdge e: edges){
        wordsSet.add(e.getGovernor());
        wordsSet.add(e.getDependent());
    }
    
    return getSortedWordsFromSetOfWords(wordsSet);
}
 
开发者ID:gkiril,项目名称:minie,代码行数:15,代码来源:CoreNLPUtils.java

示例2: getWordSetFromCoreMapList

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; //导入方法依赖的package包/类
public static ObjectOpenHashSet<IndexedWord> getWordSetFromCoreMapList(List<CoreMap> coreMapList){
    ObjectOpenHashSet<IndexedWord> coreLabelSet = new ObjectOpenHashSet<>();
    for (CoreMap cm: coreMapList){
        coreLabelSet.add(new IndexedWord(new CoreLabel(cm)));
    }
    return coreLabelSet;
}
 
开发者ID:gkiril,项目名称:minie,代码行数:8,代码来源:CoreNLPUtils.java

示例3: initializeGrids

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; //导入方法依赖的package包/类
public void initializeGrids(
		Set<UUID> allActiveNodes, 
		Set<UUID> activeNeedsInputNodes, 
		Set<UUID> passiveNodes,
		Object2IntOpenHashMap<UUID> uuidToIntMap,
		Object2ObjectOpenHashMap<UUID, Commodity[]> uuidOutputMap,
		Object2ObjectOpenHashMap<UUID, Commodity[]> uuidInputMap) {
	
	Object2IntOpenHashMap<UUID> uuidToIntMapWithMeter = new Object2IntOpenHashMap<UUID>(uuidToIntMap);
	uuidToIntMapWithMeter.put(meterUUID, uuidToIntMap.size());
	
	Object2ObjectOpenHashMap<UUID, Commodity[]> uuidOutputMapWithMeter = new Object2ObjectOpenHashMap<UUID, Commodity[]>(uuidOutputMap);
	uuidOutputMapWithMeter.put(meterUUID, Commodity.values());
	
	Object2ObjectOpenHashMap<UUID, Commodity[]> uuidInputMapWithMeter = new Object2ObjectOpenHashMap<UUID, Commodity[]>(uuidInputMap);
	uuidInputMapWithMeter.put(meterUUID, Commodity.values());
	
	
	for (Entry<EnergySimulationTypes,EnergyGrid> grid : grids.entrySet()) {
		grid.getValue().initializeGrid(allActiveNodes, activeNeedsInputNodes, passiveNodes, uuidToIntMapWithMeter, uuidOutputMapWithMeter);
	}
	
	ObjectOpenHashSet<UUID> passiveWithMeter = new ObjectOpenHashSet<UUID>(passiveNodes);
	passiveWithMeter.add(meterUUID);
	
	a2pInputStateMap = new UUIDCommodityMap(passiveWithMeter, uuidToIntMapWithMeter, uuidInputMapWithMeter, true);
	
	p2aInputStateMap = new UUIDCommodityMap(activeNeedsInputNodes, uuidToIntMap, uuidInputMap, true);
}
 
开发者ID:organicsmarthome,项目名称:OSHv4,代码行数:30,代码来源:OCEnergySimulationCore.java

示例4: getNeighbors

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; //导入方法依赖的package包/类
@Override
public Collection<Integer> getNeighbors( final Integer x ) {
	final int v = x.intValue();
	final int outdegree = graph.outdegree( v );
	final int indegree = transpose.outdegree( v );
	final LazyIntIterator succ = graph.successors( v );
	final LazyIntIterator pred = transpose.successors( v );
	
	final ObjectOpenHashSet<Integer> res = new ObjectOpenHashSet<Integer>( outdegree + indegree );
	for( int s; ( s = succ.nextInt() ) != -1; ) res.add( Integer.valueOf( s ) );
	for( int p; ( p = pred.nextInt() ) != -1; ) res.add( Integer.valueOf( p ) );
	return res;
}
 
开发者ID:lhelwerd,项目名称:WebGraph,代码行数:14,代码来源:JungAdapter.java

示例5: detectQuantities

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; //导入方法依赖的package包/类
/**
 * Detect the quantities in a phrase (given the sentence semantic graph).
 * @param sentSemGraph: the sentence semantic graph
 */
public void detectQuantities(SemanticGraph sentSemGraph, int i){
    // Quantity words and edges
    ObjectArrayList<IndexedWord> qWords = new ObjectArrayList<IndexedWord>();
    ObjectArrayList<SemanticGraphEdge> qEdges = new ObjectArrayList<SemanticGraphEdge>();
    
    // Tokens regex patterns
    String tokenRegexPattern;
    if (i == 1)
        tokenRegexPattern = REGEX.QUANTITY_SEQUENCE;
    else
        tokenRegexPattern = REGEX.QUANTITY_SEQUENCE_WITH_NO;
    
    TokenSequencePattern tPattern = TokenSequencePattern.compile(tokenRegexPattern);
    TokenSequenceMatcher tMatcher = tPattern.getMatcher(this.getWordCoreLabelList());
    
    // Some reusable variables
    List<CoreMap> matchCoreMaps;
    ObjectOpenHashSet<IndexedWord> wordsSet = new ObjectOpenHashSet<>();
    IndexedWord head;
    Set<SemanticGraphEdge> subtreeedges = new HashSet<>();
    int matchCounter = -1;
    
    // Annotate the matches and their subtrees
    while (tMatcher.find()){      
        matchCounter++;
        matchCoreMaps = tMatcher.groupNodes();
        
        // Get the head word of the phrase and see whether or not to add it to the quantities
        head = CoreNLPUtils.getRootFromCoreMapWordList(sentSemGraph, matchCoreMaps);
        if (head.ner().equals(NE_TYPE.DATE) || head.ner().equals(NE_TYPE.LOCATION) ||
                head.ner().equals(NE_TYPE.MISC) || head.ner().equals(NE_TYPE.ORGANIZATION) || 
                head.ner().equals(NE_TYPE.PERSON) || head.ner().equals(NE_TYPE.TIME))
            continue;
        
        // Add the sutree elements of the head word if the right relations are in force
        for (IndexedWord w: sentSemGraph.getChildren(head)){
            if ((sentSemGraph.reln(head, w) == EnglishGrammaticalRelations.QUANTIFIER_MODIFIER) ||
                (sentSemGraph.reln(head, w) == EnglishGrammaticalRelations.ADVERBIAL_MODIFIER)){
                wordsSet.add(w);
                subtreeedges = CoreNLPUtils.getSubTreeEdges(w, sentSemGraph, null);
            }
        }
        
        // Add the quantity words found and annotate them within the phrase
        wordsSet.addAll(CoreNLPUtils.getWordSetFromCoreMapList(matchCoreMaps));
        wordsSet.addAll(CoreNLPUtils.getSortedWordsFromListOfEdges(subtreeedges));
        wordsSet.retainAll(this.getWordList());
        qWords = CoreNLPUtils.getSortedWordsFromSetOfWords(wordsSet);
        if (qWords.isEmpty())
            continue;
        this.setQuantitiesFromWordList(qWords.clone(), qEdges, sentSemGraph, i, matchCounter);
        
        // Reset
        qWords.clear();
        wordsSet.clear();
    }
}
 
开发者ID:gkiril,项目名称:minie,代码行数:62,代码来源:AnnotatedPhrase.java

示例6: mergeAdjacentQuantities

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; //导入方法依赖的package包/类
/**
 * When there are already annotated quantities, merge the ones which are right next to each other in a sequence.
 */
public void mergeAdjacentQuantities(){
    // Reusable variables
    ObjectArrayList<IndexedWord> mergedQuantityWords = new ObjectArrayList<>();
    ObjectArrayList<SemanticGraphEdge> mergedEdges = new ObjectArrayList<>();
    ObjectArrayList<String> qIds = new ObjectArrayList<>();
    ObjectOpenHashSet<IndexedWord> remWords = new ObjectOpenHashSet<>();
    ObjectArrayList<IndexedWord> matches = new ObjectArrayList<>();
    
    // Token regex pattern and matcher
    TokenSequencePattern tPattern = TokenSequencePattern.compile(REGEX.ADJACENT_QUANTITIES);
    TokenSequenceMatcher tMatcher = tPattern.getMatcher(this.getWordCoreLabelList());
    
    // Merge the quantities when matched
    while (tMatcher.find()){
        // Get the merged words and edges from the quantities that should be merged.
        matches = CoreNLPUtils.getWordListFromCoreMapList(tMatcher.groupNodes());
        
        for (int i = 0; i < matches.size(); i++){
            // If it has preposition bridging two quantities, add it to the mergedQuantityWords list
            if (matches.get(i).tag().equals(POS_TAG.IN)) {
                mergedQuantityWords.add(matches.get(1));
                remWords.add(matches.get(1));
            }
            
            // Merge the adjacent quantities
            for (Quantity q: this.getQuantities()){
                if ((Quantity.ST_QUANT + CHARACTER.UNDERSCORE + q.getId()).equals(matches.get(i).word())){
                    qIds.add(q.getId());
                    mergedQuantityWords.addAll(q.getQuantityWords());
                    mergedEdges.addAll(q.getQuantityEdges());
                }
            }
        }
        
        // Add all the words and edges from the merged quantities to the first one and remove the rest
        for (int i = 0; i < this.getWordList().size(); i++){
            if (this.getWordList().get(i).word().equals(Quantity.ST_QUANT + CHARACTER.UNDERSCORE + qIds.get(0))){
                if (this.getQuantityByID(qIds.get(0)) != null){
                    this.getQuantityByID(qIds.get(0)).setWords(mergedQuantityWords);
                    this.getQuantityByID(qIds.get(0)).setEdges(mergedEdges);
                    for (int j = 1; j < qIds.size(); j++){
                        this.removeQuantityByID(qIds.get(j));
                        for (int k = i; k < this.getWordList().size(); k++){
                            if (this.getWordList().get(k).word().equals(Quantity.ST_QUANT + CHARACTER.UNDERSCORE + 
                                                                        qIds.get(j))){
                                remWords.add(this.getWordList().get(k));
                                continue;
                            }
                        }
                    }
                    break;
                }
            }
        }
        
        // Remove and clear 
        this.removeWordsFromList(remWords);
        remWords.clear();
        qIds.clear();
    }
}
 
开发者ID:gkiril,项目名称:minie,代码行数:65,代码来源:AnnotatedPhrase.java

示例7: add

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; //导入方法依赖的package包/类
public void add(K k, V v) {
    ObjectOpenHashSet<V> list = getSet(k);
    list.add(v);
}
 
开发者ID:htools,项目名称:htools,代码行数:5,代码来源:FHashMapSet.java

示例8: addIfNotExists

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; //导入方法依赖的package包/类
public void addIfNotExists(K k, V v) {
    ObjectOpenHashSet<V> list = getSet(k);
    if (!list.contains(v))
       list.add(v);
}
 
开发者ID:htools,项目名称:htools,代码行数:6,代码来源:FHashMapSet.java

示例9: add

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; //导入方法依赖的package包/类
public void add(int k, V v) {
    ObjectOpenHashSet<V> list = getSet(k);
    list.add(v);
}
 
开发者ID:htools,项目名称:htools,代码行数:5,代码来源:FHashMapIntSet.java

示例10: addIfNotExists

import it.unimi.dsi.fastutil.objects.ObjectOpenHashSet; //导入方法依赖的package包/类
public void addIfNotExists(int k, V v) {
    ObjectOpenHashSet<V> list = getSet(k);
    if (!list.contains(v))
       list.add(v);
}
 
开发者ID:htools,项目名称:htools,代码行数:6,代码来源:FHashMapIntSet.java


注:本文中的it.unimi.dsi.fastutil.objects.ObjectOpenHashSet.add方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。