本文整理汇总了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);
}
示例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;
}
示例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);
}
示例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;
}
示例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();
}
}
示例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();
}
}
示例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);
}
示例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);
}
示例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);
}
示例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);
}