gnu.trove.map.hash.TIntObjectHashMap Java Examples

The following examples show how to use gnu.trove.map.hash.TIntObjectHashMap. 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: ItemUpgradeData.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
void afterUnmarshal(Unmarshaller u, Object parent) {
	itemUpgradeSets = new TIntObjectHashMap<ItemUpgradeTemplate>();
	ResultItemMap = new FastMap<Integer, FastMap<Integer, UpgradeResultItem>>();

	for (ItemUpgradeTemplate set : ItemUpgradeTemplates) {
		itemUpgradeSets.put(set.getUpgrade_base_item_id(), set);

		ResultItemMap.put(set.getUpgrade_base_item_id(), new FastMap<Integer, UpgradeResultItem>());

		if (!set.getUpgrade_result_item().isEmpty()) {
			for (UpgradeResultItem resultItem : set.getUpgrade_result_item()) {
				ResultItemMap.get(set.getUpgrade_base_item_id()).put(resultItem.getItem_id(), resultItem);
			}
		}
	}
	ItemUpgradeTemplates = null;
}
 
Example #2
Source File: DataAccessForTesting.java    From ambiverse-nlu with Apache License 2.0 6 votes vote down vote up
@Override public TIntObjectHashMap<int[]> getInlinkNeighbors(Entities entities) throws EntityLinkingDataAccessException {
  TIntObjectHashMap<int[]> inlinks = new TIntObjectHashMap<int[]>();

  for (Entity e : entities) {
    inlinks.put(e.getId(), new int[0]);
  }

  for (String[] entityInlinks : allInlinks) {
    int eId = DataAccess.getInternalIdForKBEntity(getTestKBEntity(entityInlinks[0]));
    int[] inlinkIds = new int[entityInlinks.length - 1];
    for (int i = 1; i < entityInlinks.length; ++i) {
      inlinkIds[i - 1] = DataAccess.getInternalIdForKBEntity(getTestKBEntity(entityInlinks[i]));
    }
    Arrays.sort(inlinkIds);
    inlinks.put(eId, inlinkIds);
  }

  return inlinks;
}
 
Example #3
Source File: MilneWittenEntityEntitySimilarity.java    From ambiverse-nlu with Apache License 2.0 6 votes vote down vote up
private void setupEntities(Entities entities) throws Exception {
  logger.debug("Initializing MilneWittenEntityEntitySimilarity for " + entities.size() + " entities");

  collectionSize = DataAccess.getCollectionSize();

  TIntObjectHashMap<int[]> entityInlinks = DataAccess.getInlinkNeighbors(entities);

  // inlinks are assumed to be pre-sorted.
  entity2vector = new TIntObjectHashMap<>();

  for (TIntObjectIterator<int[]> itr = entityInlinks.iterator(); itr.hasNext(); ) {
    itr.advance();
    int entity = itr.key();
    int[] inLinks = itr.value();

    RoaringBitmap bs = new RoaringBitmap();
    for (int l : inLinks) {
      bs.add(l);
    }
    entity2vector.put(entity, bs);
  }

  logger.debug("Done initializing MilneWittenEntityEntitySimilarity for " + entities.size() + " entities");
}
 
Example #4
Source File: PartitionEquivalences.java    From metanome-algorithms with Apache License 2.0 6 votes vote down vote up
public void addPartition(EquivalenceManagedPartition partition) {
	if (!this.observedPartitions.contains(partition.getIndices()) && !this.containsSimilarPartition(partition)) {
		this.observedPartitions.add(partition.getIndices());
		long hashNumber = partition.getHashNumber();
		System.out.println(String.format("Partition[%s]\t%d\tSize: %d", partition.getIndices(), Long.valueOf(hashNumber), Integer.valueOf(partition.size())));
		partitionHashes.putIfAbsent(hashNumber, new TIntObjectHashMap<THashSet<EquivalenceManagedPartition>>());
		partitionHashes.get(hashNumber).putIfAbsent(partition.size(), new THashSet<EquivalenceManagedPartition>());
		THashSet<EquivalenceManagedPartition> partitionGroup = partitionHashes.get(hashNumber).get(partition.size());

		if (partitionGroup.isEmpty()) {
			partitionGroup.add(partition);
		} else {
			// then there is at least one element in the partitionGroup
			checkPossibleEquivalences(partitionGroup, partition);
		}
	}
}
 
Example #5
Source File: LunaData.java    From aion-germany with GNU General Public License v3.0 6 votes vote down vote up
void afterUnmarshal(Unmarshaller u, Object parent) {
	lunaData = new TIntObjectHashMap<LunaTemplate>();
	elyos = FastList.newInstance();
	asmos = FastList.newInstance();
	any = FastList.newInstance();
	for (LunaTemplate lt : list) {
		lunaData.put(lt.getId(), lt);
		switch (lt.getRace()) {
			case ASMODIANS:
				asmos.add(lt);
				break;
			case ELYOS:
				elyos.add(lt);
				break;
			case PC_ALL:
				any.add(lt);
				break;
			default:
				break;
		}
	}
	list = null;
}
 
Example #6
Source File: SuperdocEntityKeyphraseCountCollector.java    From ambiverse-nlu with Apache License 2.0 6 votes vote down vote up
public void run() throws Exception {
  logger.info("STARTING");
  logger.info("Reading Link Graph");
  Entities entities = DataAccess.getAllEntities();
  TIntObjectHashMap<int[]> linkFrom = DataAccess.getAllInlinks();
  TIntObjectHashMap<int[]> linkTo = transformInlinksToOutlinks(linkFrom);
  logger.info("Creating Count Dictionaries");
  TIntObjectHashMap<TIntIntHashMap> superdocKeyphraseCounts = createAllSuperdocKeyphraseDictionaries();
  logger.info("Counting Keyphrase Occurrences");
  fillSuperdocKeyphraseCounts(linkTo, superdocKeyphraseCounts);
  logger.info("Writing to file");
  writeToFile(superdocKeyphraseCounts);
  // Flush global writer.
  writer.flush();
  writer.close();
  logger.info("DONE");
}
 
Example #7
Source File: DataWatcherTransformer.java    From Carbon-2 with GNU Lesser General Public License v3.0 6 votes vote down vote up
public static byte[] transform(WatchedEntity entity, byte[] data) throws IOException {
    if (entity == null) {
        return data;
    }
    TIntObjectMap<DataWatcherObject> objects = DataWatcherSerializer.decodeData(data);
    TIntObjectMap<DataWatcherObject> newobjects = new TIntObjectHashMap<DataWatcherObject>();
    //copy entity
    moveDWData(objects, newobjects, 0, 0); //flags
    moveDWData(objects, newobjects, 1, 1); //air
    moveDWData(objects, newobjects, 2, 2); //nametag
    moveDWData(objects, newobjects, 3, 3); //nametagvisible
    //copy specific types
    for (RemappingEntry entry : entity.getType().getRemaps()) {
        moveDWData(objects, newobjects, entry.getFrom(), entry.getTo());
    }
    return DataWatcherSerializer.encodeData(newobjects);
}
 
Example #8
Source File: SuperdocEntityKeyphraseCountCollector.java    From ambiverse-nlu with Apache License 2.0 6 votes vote down vote up
private void writeToFile(TIntObjectHashMap<TIntIntHashMap> superdocKeyphraseCounts) throws IOException, SQLException {
  int eCount = 0;

  logger.info("Writing entity-keyphrase pairs for " + superdocKeyphraseCounts.size() + " entities");

  for (int eid : superdocKeyphraseCounts.keys()) {

    if ((++eCount % 100000) == 0) {
      double percent = (double) eCount / (double) superdocKeyphraseCounts.size();

      logger.info("Wrote " + eCount + " entities (" + new DecimalFormat("#.##").format(percent) + ")");
    }

    TIntIntHashMap keyphraseCounts = superdocKeyphraseCounts.get(eid);

    for (int kid : keyphraseCounts.keys()) {
      int count = keyphraseCounts.get(kid);

      writer.write(eid + "\t" + kid + "\t" + String.valueOf(count));
      writer.newLine();
    }
  }
}
 
Example #9
Source File: DataAccessForTesting.java    From ambiverse-nlu with Apache License 2.0 6 votes vote down vote up
public TIntObjectHashMap<TIntIntHashMap> getEntityKeyphraseIntersectionCount(Entities entities) throws EntityLinkingDataAccessException {
  TIntObjectHashMap<TIntIntHashMap> isec = new TIntObjectHashMap<TIntIntHashMap>();
  for (String[] eKps : allEntityKeyphrases) {
    int entity = DataAccess.getInternalIdForKBEntity(getTestKBEntity(eKps[0]));
    TIntIntHashMap counts = new TIntIntHashMap();
    isec.put(entity, counts);

    if (eKps.length > 1) {
      int currentKp = -1;
      for (int i = 1; i < eKps.length; ++i) {
        if (i % 2 == 1) {
          currentKp = DataAccess.getIdForWord(eKps[i]);
        } else {
          int count = Integer.parseInt(eKps[i]);
          counts.put(currentKp, count);
        }
      }
    }
  }
  return isec;
}
 
Example #10
Source File: DefaultMapping.java    From scheduler with GNU Lesser General Public License v3.0 6 votes vote down vote up
/**
 * Create a new mapping.
 */
@SuppressWarnings("unchecked")
public DefaultMapping() {

    nodeState = new Set[2];
    nodeState[ONLINE_STATE] = new THashSet<>();
    nodeState[OFFLINE_STATE] = new THashSet<>();

    vmReady = new THashSet<>();

    place = new TIntObjectHashMap<>();

    host = new TIntObjectHashMap[2];
    host[RUNNING_STATE] = new TIntObjectHashMap<>();
    host[SLEEPING_STATE] = new TIntObjectHashMap<>();

    st = new TIntIntHashMap(100, 0.5f, -1, -1);
}
 
Example #11
Source File: KeytermEntityEntityMeasureTracer.java    From ambiverse-nlu with Apache License 2.0 6 votes vote down vote up
public KeytermEntityEntityMeasureTracer(String name, double weight, Map<Integer, Double> keyphraseWeights, Map<Integer, TermTracer> matches,
    TIntObjectHashMap<int[]> keyphraseTokens) throws EntityLinkingDataAccessException {
  super(name, weight);

  this.terms = keyphraseWeights;
  this.matchedTerms = matches;
  this.keyphraseTokens = keyphraseTokens;

  synchronized (id2word) {
    if (id2word.size() == 0) {
      logger.debug("Reading all word ids for tracing.");
      id2word = getAllWordIds();
      logger.debug("Reading all word ids for tracing done.");
    }
  }
}
 
Example #12
Source File: CPowerView.java    From scheduler with GNU Lesser General Public License v3.0 6 votes vote down vote up
@Override
public boolean inject(Parameters ps, ReconfigurationProblem rp) throws SchedulerException {
    powerStarts = new TIntObjectHashMap<>(rp.getNodes().size());
    powerEnds = new TIntObjectHashMap<>(rp.getNodes().size());

    for (Node n : rp.getNodes()) {
        NodeTransition na = rp.getNodeAction(n);
        if (na instanceof ShutdownableNode) {
            powerStarts.put(rp.getNode(n), rp.getStart());
            IntVar powerEnd = rp.makeUnboundedDuration("NodeActionType(", n, ").Pe");
            TaskMonitor.build(na.getHostingEnd(), na.getDuration(), powerEnd);
            powerEnds.put(rp.getNode(n), powerEnd);
            rp.getModel().post(rp.getModel().arithm(powerEnd, "<=", rp.getEnd()));
        } else if (na instanceof BootableNode) {
            powerStarts.put(rp.getNode(n), na.getStart());
            powerEnds.put(rp.getNode(n), rp.getEnd());
        }
    }
    return true;
}
 
Example #13
Source File: InlinkOverlapEntityEntitySimilarity.java    From ambiverse-nlu with Apache License 2.0 6 votes vote down vote up
private void setupEntities(Entities entities) throws Exception {
  if (entities.size() == 0) {
    logger.debug("Skipping initialization of InlinkEntityEntitySimilarity for " + entities.size() + " entities");
    return;
  }

  logger.debug("Initializing InlinkEntityEntitySimilarity for " + entities.size() + " entities");

  entity2vector = new TIntObjectHashMap<>();

  TIntObjectHashMap<int[]> entityInlinks = DataAccess.getInlinkNeighbors(entities);

  for (TIntObjectIterator<int[]> itr = entityInlinks.iterator(); itr.hasNext(); ) {
    itr.advance();
    int entity = itr.key();
    int[] inLinks = itr.value();

    RoaringBitmap bs = new RoaringBitmap();
    for (int l : inLinks) {
      bs.add(l);
    }
    entity2vector.put(entity, bs);
  }

  logger.debug("Done initializing InlinkEntityEntitySimilarity");
}
 
Example #14
Source File: RequestService.java    From PeonyFramwork with Apache License 2.0 6 votes vote down vote up
public void init(){
    TIntObjectHashMap<Class<?>> requestHandlerClassMap = ServiceHelper.getRequestHandlerMap();
    requestHandlerClassMap.forEachEntry(new TIntObjectProcedure<Class<?>>(){
        @Override
        public boolean execute(int i, Class<?> aClass) {
            handlerMap.put(i, (RequestHandler)BeanHelper.getServiceBean(aClass));
            timeMap.put(i,new ConcurrentLinkedDeque<>());
            return true;
        }
    });
    // 命令
    List<Class<?>> cmdClasses = ClassHelper.getClassListEndWith("com.myFruit.cmd","Cmd");
    for (Class<?> cls:cmdClasses) {

        Field[] fields = cls.getFields();
        for(Field field : fields){
            try {
                opcodeNames.put(field.getInt(null),field.getName());
            } catch (IllegalAccessException e) {
                e.printStackTrace();
            }
        }
    }

}
 
Example #15
Source File: DataAccess.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
public static Map<KBIdentifiedEntity, EntityMetaData> getEntitiesMetaData(Set<KBIdentifiedEntity> entities)
    throws EntityLinkingDataAccessException {
  TObjectIntHashMap<KBIdentifiedEntity> ids = getInternalIdsForKBEntities(entities);
  TIntObjectHashMap<EntityMetaData> metadata = getEntitiesMetaData(ids.values());
  Map<KBIdentifiedEntity, EntityMetaData> result = new HashMap<KBIdentifiedEntity, EntityMetaData>();
  for (TObjectIntIterator<KBIdentifiedEntity> itr = ids.iterator(); itr.hasNext(); ) {
    itr.advance();
    int id = itr.value();
    result.put(itr.key(), metadata.get(id));
  }
  return result;
}
 
Example #16
Source File: DefaultMapping.java    From scheduler with GNU Lesser General Public License v3.0 5 votes vote down vote up
@Override
public void clearAllVMs() {
    place.clear();
    st.clear();
    vmReady.clear();
    for (TIntObjectHashMap<Set<VM>> h : host) {
        h.clear();
    }
}
 
Example #17
Source File: DataAccessSQLCache.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
private synchronized void addToEntityKeyphrasesCache(String querySignature, TIntObjectHashMap<List<EntityKeyphraseData>> entityKeyphrases) {
  CachingHashMap<Integer, List<EntityKeyphraseData>> queryCache = entityKeyphrasesCaches.get(querySignature);
  if (queryCache == null) {
    int maxEntities = EntityLinkingConfig.getAsInt(EntityLinkingConfig.ENTITIES_CACHE_SIZE);
    queryCache = new CachingHashMap<Integer, List<EntityKeyphraseData>>(maxEntities);
    entityKeyphrasesCaches.put(querySignature, queryCache);
  }

  for (TIntObjectIterator<List<EntityKeyphraseData>> itr = entityKeyphrases.iterator(); itr.hasNext(); ) {
    itr.advance();
    int entityId = itr.key();
    List<EntityKeyphraseData> keyphrases = itr.value();
    queryCache.put(entityId, keyphrases);
  }
}
 
Example #18
Source File: MapDictionaryGenerator.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
private static Collection<String> getLanguageSpecificMentionsForEntities(TIntObjectHashMap<EntityMetaData> entitiesMetaData) throws EntityLinkingDataAccessException {
    int[] collect = entitiesMetaData
            .valueCollection()
.stream()
.mapToInt(e -> e.getId())
.toArray();
    return DataAccess.getEntityMentionsforLanguageAndEntities(collect, Language.getLanguageForString(language)).keySet();
}
 
Example #19
Source File: GraphConfidenceEstimator.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
private Map<Integer, Map<Integer, Double>> computeConfidence(Graph g, TIntObjectHashMap<TIntIntHashMap> mentionEntityCounts) {
  Map<Integer, Map<Integer, Double>> confidences = new HashMap<Integer, Map<Integer, Double>>();
  // Fill with 0 confidences
  for (int mentionId : solution_.keySet()) {
    Map<Integer, Double> mentionConfidences = new HashMap<Integer, Double>();
    confidences.put(mentionId, mentionConfidences);
    int[] candidateEntities = g.getNode(mentionId).getSuccessors().keys();
    for (int entity : candidateEntities) {
      mentionConfidences.put(entity, 0.0);
    }
  }

  for (TIntObjectIterator<TIntIntHashMap> itr = mentionEntityCounts.iterator(); itr.hasNext(); ) {
    itr.advance();
    int mentionId = itr.key();
    // Get total count for mention.
    int totalCount = 0;
    for (TIntIntIterator innerItr = itr.value().iterator(); innerItr.hasNext(); ) {
      innerItr.advance();
      totalCount += innerItr.value();
    }
    // Compute confidences (by normalizing).
    Map<Integer, Double> entityConfidences = confidences.get(mentionId);
    if (entityConfidences.size() == 1) {
      entityConfidences.put(entityConfidences.keySet().iterator().next(), SINGLE_CANDIDATE_CONFIDENCE);
    } else {
      TIntIntHashMap entityCounts = itr.value();
      for (TIntIntIterator innerItr = entityCounts.iterator(); innerItr.hasNext(); ) {
        innerItr.advance();
        int entityId = innerItr.key();
        double entityConfidence = (double) innerItr.value() / (double) totalCount;
        assert entityConfidence <= 1.0001;
        assert entityConfidence >= -0.0001;
        entityConfidences.put(entityId, entityConfidence);
      }
    }
    confidences.put(mentionId, entityConfidences);
  }
  return confidences;
}
 
Example #20
Source File: DataAccessForTesting.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
@Override public TIntObjectHashMap<TIntIntHashMap> getEntityUnitIntersectionCount(Entities entities, UnitType unitType)
    throws EntityLinkingDataAccessException {
  switch (unitType) {
    case KEYWORD:
    case BIGRAM:
      return getEntityUnitIntersectionCountInternal(entities, unitType);
    default:
      return null;
  }
}
 
Example #21
Source File: DataAccessSQL.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
@Override public Entities getEntitiesForInternalIds(int[] ids) throws EntityLinkingDataAccessException {
  Entities entities = new Entities();
  TIntObjectHashMap<KBIdentifiedEntity> yagoEntityIds = getKnowlegebaseEntitiesForInternalIds(ids);
  if (yagoEntityIds.isEmpty()) {
    return entities;
  }
  for (int id : ids) {
    KBIdentifiedEntity kbi = yagoEntityIds.get(id);
    entities.add(new Entity(kbi, id));
  }
  return entities;
}
 
Example #22
Source File: DataAccessKeyValueStore.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
public TIntObjectHashMap<int[]> getTypesIdsForEntitiesIds(int[] entitiesIds) throws EntityLinkingDataAccessException {
  if (entitiesIds.length == 0) {
    return new TIntObjectHashMap<>();
  }

  TIntObjectHashMap<int[]> typesIds = new TIntObjectHashMap<>(getCapacity(entitiesIds.length), troveLoadFactor);
  try {
    DatabaseKeyValueStore db = DatabaseKeyValueStore.ENTITY_TYPES_ENTITY;
    if(db.getPartitions() != 1) {
      throw new IllegalArgumentException("Multiple partitions not supported for this key-value store");
    }
    Codec entityTypesCodec = DataAccessKeyValueStoreHandler.singleton().getCodec(db);
    KeyValueStore<byte[], byte[]> keyValueStore = DataAccessKeyValueStoreHandler.singleton().getKeyValueStore(db);

    List<byte[]> encodedKeys = new ArrayList<>();
    for (int id : entitiesIds) {
      encodedKeys.add(entityTypesCodec.encodeKey(id));
    }
    Map<byte[], byte[]> keyValueMap = keyValueStore.getAll(encodedKeys);

    if (keyValueMap.size() != entitiesIds.length) {
      for (int entitiesId : entitiesIds) {
        typesIds.put(entitiesId, new int[0]);
      }
    }

    for (Map.Entry<byte[], byte[]> entry : keyValueMap.entrySet()) {
      if (entry.getKey() == null || entry.getValue() == null) continue;
      int entity = (int) entityTypesCodec.decodeKey(entry.getKey());
      int[] curTypesIds = (int[]) entityTypesCodec.decodeValue(entry.getValue());
      typesIds.put(entity, curTypesIds);
    }
  } catch (Exception e) {
    throw new EntityLinkingDataAccessException(e);
  }
  return typesIds;
}
 
Example #23
Source File: Classification.java    From htm.java with GNU Affero General Public License v3.0 5 votes vote down vote up
/**
 * Utility method to copy the contents of a ClassifierResult.
 * 
 * @return  a copy of this {@code ClassifierResult} which will not be affected
 * by changes to the original.
 */
public Classification<T> copy() {
    Classification<T> retVal = new Classification<T>();
    retVal.actualValues = Arrays.copyOf(actualValues, actualValues.length);
    retVal.probabilities = new TIntObjectHashMap<double[]>(probabilities);
    
    return retVal;
}
 
Example #24
Source File: DataAccessEntitiesCacheTarget.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
@Override
protected void loadFromDisk() throws IOException {
  File cacheFile = getCacheFile();
  DataInputStream in = new DataInputStream(new BufferedInputStream(new GZIPInputStream(new FileInputStream(cacheFile))));
  int size = in.readInt();
  data_ = new TIntObjectHashMap<>((int) (size / Constants.DEFAULT_LOAD_FACTOR));
  for (int i = 0; i < size; ++i) {
    int entityId = in.readInt();
    int entityClass = in.readInt();
    data_.put(entityId, EntityType.getNameforDBId(entityClass));
  }
  in.close();
}
 
Example #25
Source File: DataAccessForTesting.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
@Override
public TIntObjectHashMap<EntityType> getEntityClasses(Entities entities) throws EntityLinkingDataAccessException {
  TIntObjectHashMap<EntityType> entityClasses = new TIntObjectHashMap<>();
  for (Entity e : entities) {
    entityClasses.put(e.getId(), EntityType.NAMED_ENTITY);
  }
  return entityClasses;
}
 
Example #26
Source File: YagoEntityKeyphraseCooccurrenceDataProviderIteratorTest.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
private TIntObjectHashMap<TIntIntHashMap> createHashMap() {
  TIntObjectHashMap<TIntIntHashMap> overallMap = new TIntObjectHashMap<TIntIntHashMap>();
  TIntIntHashMap map1 = new TIntIntHashMap();
  overallMap.put(1, map1);

  TIntIntHashMap map2 = new TIntIntHashMap();
  map2.put(21, 100);
  map2.put(22, 101);
  map2.put(23, 102);
  overallMap.put(2, map2);

  TIntIntHashMap map3 = new TIntIntHashMap();
  map3.put(31, 103);
  map3.put(32, 104);
  map3.put(33, 105);
  overallMap.put(3, map3);

  TIntIntHashMap map4 = new TIntIntHashMap();
  overallMap.put(4, map4);

  TIntIntHashMap map5 = new TIntIntHashMap();
  map5.put(51, 106);
  map5.put(52, 107);
  map5.put(53, 108);
  overallMap.put(5, map5);

  TIntIntHashMap map6 = new TIntIntHashMap();
  overallMap.put(6, map6);

  TIntIntHashMap map7 = new TIntIntHashMap();
  overallMap.put(7, map7);

  return overallMap;
}
 
Example #27
Source File: TitleData.java    From aion-germany with GNU General Public License v3.0 5 votes vote down vote up
void afterUnmarshal(Unmarshaller u, Object parent) {
	titles = new TIntObjectHashMap<TitleTemplate>();
	for (TitleTemplate tt : tts) {
		titles.put(tt.getTitleId(), tt);
	}
	tts = null;
}
 
Example #28
Source File: Cluster.java    From metanome-algorithms with Apache License 2.0 5 votes vote down vote up
public TIntObjectHashMap<Cluster> refineBy(int column, int[][] values) {
	TIntObjectHashMap<Cluster> map = new TIntObjectHashMap<>();
	for (TIntIterator iter = array.iterator(); iter.hasNext();) {
		int line = iter.next();
		int c = values[line][column];
		if (map.containsKey(c)) {
			map.get(c).add(line);
		} else {
			Cluster p = new Cluster(line);
			map.put(c, p);
		}
	}
	return map;
}
 
Example #29
Source File: UnitUtil.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
private static TIntObjectHashMap<String> getUsedWords(TIntSet usedTokens, TIntObjectHashMap<String> idsWords) {
  TIntObjectHashMap<String> usedWords = new TIntObjectHashMap<>();
  for (TIntIterator itr = usedTokens.iterator(); itr.hasNext(); ) {
    int usedToken = itr.next();
    usedWords.put(usedToken, idsWords.get(usedToken));
  }
  return usedWords;
}
 
Example #30
Source File: DataAccess.java    From ambiverse-nlu with Apache License 2.0 5 votes vote down vote up
public static Entities getAidaEntitiesForInternalIds(int[] internalIds) throws EntityLinkingDataAccessException {
  TIntObjectHashMap<KBIdentifiedEntity> kbEntities = DataAccess.getKnowlegebaseEntitiesForInternalIds(internalIds);
  Entities entities = new Entities();
  for (TIntObjectIterator<KBIdentifiedEntity> itr = kbEntities.iterator(); itr.hasNext(); ) {
    itr.advance();
    entities.add(new Entity(itr.value(), itr.key()));
  }
  return entities;
}