本文整理汇总了Java中com.carrotsearch.hppc.ObjectIntOpenHashMap类的典型用法代码示例。如果您正苦于以下问题:Java ObjectIntOpenHashMap类的具体用法?Java ObjectIntOpenHashMap怎么用?Java ObjectIntOpenHashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectIntOpenHashMap类属于com.carrotsearch.hppc包,在下文中一共展示了ObjectIntOpenHashMap类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Java代码示例。
示例1: apply
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
@Override
public ObjectDistribution<BitSet> apply(ColouredGraph graph) {
ObjectArrayList<BitSet> colours = graph.getVertexColours();
ObjectIntOpenHashMap<BitSet> counts = new ObjectIntOpenHashMap<BitSet>();
for (int i = 0; i < colours.elementsCount; ++i) {
counts.putOrAdd((BitSet) ((Object[]) colours.buffer)[i], 1, 1);
}
BitSet sampleSpace[] = new BitSet[counts.assigned];
double distribution[] = new double[counts.assigned];
int pos = 0;
for (int i = 0; i < counts.allocated.length; ++i) {
if (counts.allocated[i]) {
sampleSpace[pos] = (BitSet) ((Object[]) counts.keys)[i];
distribution[pos] = counts.values[i];
++pos;
}
}
return new ObjectDistribution<BitSet>(sampleSpace, distribution);
}
示例2: apply
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
@Override
public ObjectDistribution<BitSet> apply(ColouredGraph graph) {
ObjectArrayList<BitSet> colours = graph.getEdgeColours();
ObjectIntOpenHashMap<BitSet> counts = new ObjectIntOpenHashMap<BitSet>();
for (int i = 0; i < colours.elementsCount; ++i) {
counts.putOrAdd((BitSet) ((Object[]) colours.buffer)[i], 1, 1);
}
BitSet sampleSpace[] = new BitSet[counts.assigned];
double distribution[] = new double[counts.assigned];
int pos = 0;
for (int i = 0; i < counts.allocated.length; ++i) {
if (counts.allocated[i]) {
sampleSpace[pos] = (BitSet) ((Object[]) counts.keys)[i];
distribution[pos] = counts.values[i];
++pos;
}
}
return new ObjectDistribution<BitSet>(sampleSpace, distribution);
}
示例3: sampleEdgeEndColour
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
private BitSet sampleEdgeEndColour(Random random, ObjectIntOpenHashMap<BitSet> headDistribution,
int numberOfDistSamples) {
int colourId = random.nextInt(numberOfDistSamples);
// find the first colour
while (!headDistribution.allocated[colourId]) {
++colourId;
}
int temp = colourId;
while (temp > 0) {
temp -= headDistribution.values[colourId];
while ((colourId < headDistribution.allocated.length) && (!headDistribution.allocated[colourId])) {
++colourId;
}
if (colourId >= headDistribution.allocated.length) {
String msg = "Got a sample (" + colourId + ") that seems to be larger than the probability sum ("
+ numberOfDistSamples + "). Aborting.";
LOGGER.error(msg);
throw new IllegalStateException(msg);
}
}
return (BitSet) ((Object[]) headDistribution.keys)[colourId];
}
示例4: run
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
private void run(File inputFile, File outputFile) {
ObjectIntOpenHashMap<String> countedPatterns = readPatterns(inputFile);
if (countedPatterns == null) {
return;
}
// sort
LOGGER.info("Sorting " + countedPatterns.size() + " patterns...");
String patterns[] = new String[countedPatterns.size()];
int counts[] = new int[patterns.length];
int count = 0;
for (int i = 0; i < countedPatterns.allocated.length; i++) {
if (countedPatterns.allocated[i]) {
patterns[count] = (String) ((Object[]) countedPatterns.keys)[i];
counts[count] = countedPatterns.values[i];
++count;
}
}
AssociativeSort.quickSort(counts, patterns);
writeCounts(outputFile, counts, patterns);
}
示例5: test
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
@Test
public void test() {
VoidParsingExtractor extractor = new VoidParsingExtractor();
runTestOnTTL(rdfData, extractor);
ObjectObjectOpenHashMap<String, VoidInformation> voidInformation = extractor.getVoidInformation();
ObjectIntOpenHashMap<String> countedClasses = new ObjectIntOpenHashMap<String>();
ObjectIntOpenHashMap<String> countedProperties = new ObjectIntOpenHashMap<String>();
for (int i = 0; i < voidInformation.allocated.length; ++i) {
if (voidInformation.allocated[i]) {
((VoidInformation) ((Object[]) voidInformation.values)[i])
.addToCount(countedClasses, countedProperties);
}
}
checkExtractedData(countedClasses, extractedClasses, classesCounts);
checkExtractedData(countedProperties, extractedProperties, propertyCounts);
}
示例6: addCountedUris
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
protected long addCountedUris(ObjectIntOpenHashMap<String> countedUris, Model voidModel, Resource datasetResource,
Property partitionProperty, Property uriProperty, Property countProperty) {
long sum = 0;
Resource blank;
for (int i = 0; i < countedUris.allocated.length; ++i) {
if (countedUris.allocated[i]) {
blank = voidModel.createResource();
voidModel.add(datasetResource, partitionProperty, blank);
voidModel.add(blank, uriProperty, voidModel.createResource((String) ((Object[]) countedUris.keys)[i]));
voidModel.add(blank, uriProperty, voidModel.createResource((String) ((Object[]) countedUris.keys)[i]));
voidModel.addLiteral(blank, countProperty, countedUris.values[i]);
sum += countedUris.values[i];
}
}
return sum;
}
示例7: createDocIdCorpusIdMapping
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
@SuppressWarnings("unused")
@Deprecated
private ObjectIntOpenHashMap<String> createDocIdCorpusIdMapping(String corpusFileName) {
ObjectIntOpenHashMap<String> mapping = new ObjectIntOpenHashMap<String>();
Corpus corpus = readCorpus(corpusFileName);
DocumentName name;
String docId;
int pos, id = 0;
for (Document document : corpus) {
name = document.getProperty(DocumentName.class);
if (name != null) {
docId = name.get();
pos = docId.indexOf('.');
if (pos > 0) {
docId = new String(docId.substring(0, pos));
}
mapping.put(docId, id);
} else {
LOGGER.warn("Document #" + id + " has no DocumentName property.");
}
++id;
}
return mapping;
}
示例8: main
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
public static void main(String[] args) {
if (args.length != 1) {
LOGGER.error(
"Wrong usage. Need exactly one single argument. Correct usage: 'NIFDatasetLoadingTest <path-to-nif-file>'.");
return;
}
LOGGER.info("Starting loading of given test dataset \"" + args[0] + "\"...");
FileBasedNIFDataset dataset = new FileBasedNIFDataset(args[0], "Test dataset", Lang.TTL);
try {
dataset.init();
} catch (GerbilException e) {
LOGGER.error("Got an exception while trying to load the dataset.", e);
}
List<Document> documents = dataset.getInstances();
LOGGER.info("Dataset size: {} documents", documents.size());
ObjectIntOpenHashMap<String> annotationTypes;
for (Document document : documents) {
annotationTypes = listAnnotationTypes(document);
LOGGER.info("Document {} annotation types: {}", document.getDocumentURI(), annotationTypes.toString());
}
IOUtils.closeQuietly(dataset);
LOGGER.info("Finished loading of given test dataset.");
}
示例9: readObject
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException
{
// in.defaultReadObject ();
int version = in.readInt (); // version
int numVariables = in.readInt ();
var2idx = new ObjectIntOpenHashMap (numVariables);
for (int vi = 0; vi < numVariables; vi++) {
Variable var = (Variable) in.readObject ();
var2idx.put (var, vi);
}
int numRows = in.readInt ();
values = new ArrayList (numRows);
for (int ri = 0; ri < numRows; ri++) {
Object[] row = (Object[]) in.readObject ();
values.add (row);
}
scale = (version >= 2) ? in.readDouble () : 1.0;
}
示例10: readObject
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
private void readObject (ObjectInputStream in) throws IOException, ClassNotFoundException {
int version = in.readInt ();
int size = in.readInt();
entries = new ArrayList (size);
map = new ObjectIntOpenHashMap (size);
for (int i = 0; i < size; i++) {
Object o = in.readObject();
map.put (o, i);
entries. add (o);
}
growthStopped = in.readBoolean();
entryClass = (Class) in.readObject();
if (version >0 ){ // instanced id added in version 1S
instanceId = (VMID) in.readObject();
}
}
示例11: read
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
public void read(DataInputStream in) throws IOException {
int size = in.readInt();
entries = new ArrayList(size);
map = new ObjectIntOpenHashMap(size);
for (int i = 0; i < size; i++) {
String o = in.readUTF();
map.put(o, i);
entries.add(o);
}
growthStopped = in.readBoolean();
String classname = in.readUTF();
try {
entryClass = Class.forName(classname);
} catch (ClassNotFoundException e) {
throw new RuntimeException("Can't make class " + classname, e);
}
}
示例12: getJointReader
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
protected JointReader getJointReader(Element eReader)
{
ObjectIntOpenHashMap<String> map = getFieldMap(eReader);
int iId = map.get(AbstractColumnReader.FIELD_ID) - 1;
int iForm = map.get(AbstractColumnReader.FIELD_FORM) - 1;
int iLemma = map.get(AbstractColumnReader.FIELD_LEMMA) - 1;
int iPos = map.get(AbstractColumnReader.FIELD_POS) - 1;
int iFeats = map.get(AbstractColumnReader.FIELD_FEATS) - 1;
int iHeadId = map.get(AbstractColumnReader.FIELD_HEADID) - 1;
int iDeprel = map.get(AbstractColumnReader.FIELD_DEPREL) - 1;
int iXHeads = map.get(AbstractColumnReader.FIELD_XHEADS) - 1;
int iSHeads = map.get(AbstractColumnReader.FIELD_SHEADS) - 1;
int iNament = map.get(AbstractColumnReader.FIELD_NAMENT) - 1;
int iCoref = map.get(AbstractColumnReader.FIELD_COREF) - 1;
JointReader reader = new JointReader(iId, iForm, iLemma, iPos, iFeats, iHeadId, iDeprel, iXHeads, iSHeads, iNament, iCoref);
reader.initGoldPOSTag(map.get(AbstractColumnReader.FIELD_GPOS) - 1);
return reader;
}
示例13: getFieldMap
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
/** Called by {@link AbstractNLP#getCDEPReader(Element, String)}. */
private ObjectIntOpenHashMap<String> getFieldMap(Element eReader)
{
NodeList list = eReader.getElementsByTagName(TAG_COLUMN);
int i, index, size = list.getLength();
Element element;
String field;
ObjectIntOpenHashMap<String> map = new ObjectIntOpenHashMap<String>();
for (i=0; i<size; i++)
{
element = (Element)list.item(i);
field = UTXml.getTrimmedAttribute(element, TAG_FIELD);
index = Integer.parseInt(element.getAttribute(TAG_INDEX));
map.put(field, index);
}
return map;
}
示例14: appendSpaceFeatures
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
private void appendSpaceFeatures(StringTrainSpace space)
{
Map<String,ObjectIntOpenHashMap<String>> mFeatures = space.m_features;
ObjectIntOpenHashMap<String> tMap, sMap;
String value;
for (String type : mFeatures.keySet())
{
sMap = mFeatures.get(type);
if (m_features.containsKey(type))
{
tMap = m_features.get(type);
for (ObjectCursor<String> cur : sMap.keys())
{
value = cur.value;
tMap.put(value, tMap.get(value) + sMap.get(value));
}
}
else
m_features.put(type, sMap);
}
}
示例15: addLexicaFeatures
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
private void addLexicaFeatures(StringFeatureVector vector)
{
ObjectIntOpenHashMap<String> map;
int i, size = vector.size();
String type, value;
for (i=0; i<size; i++)
{
type = vector.getType(i);
value = vector.getValue(i);
if (m_features.containsKey(type))
{
map = m_features.get(type);
map.put(value, map.get(value)+1);
}
else
{
map = new ObjectIntOpenHashMap<String>();
map.put(value, 1);
m_features.put(type, map);
}
}
}