本文整理汇总了Java中com.carrotsearch.hppc.ObjectIntOpenHashMap类的典型用法代码示例。如果您正苦于以下问题:Java ObjectIntOpenHashMap类的具体用法?Java ObjectIntOpenHashMap怎么用?Java ObjectIntOpenHashMap使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
ObjectIntOpenHashMap类属于com.carrotsearch.hppc包,在下文中一共展示了ObjectIntOpenHashMap类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:dice-group,项目名称:Lemming,代码行数:22,代码来源:VertexColourDistributionMetric.java
示例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);
}
开发者ID:dice-group,项目名称:Lemming,代码行数:22,代码来源:EdgeColourDistributionMetric.java
示例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];
}
开发者ID:dice-group,项目名称:Lemming,代码行数:23,代码来源:GenModelBasedAlgo.java
示例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);
}
开发者ID:dice-group,项目名称:Cetus,代码行数:23,代码来源:PatternCounter.java
示例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);
}
开发者ID:dice-group,项目名称:Tapioca,代码行数:19,代码来源:VoidParsingExtractorTest.java
示例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;
}
开发者ID:dice-group,项目名称:Tapioca,代码行数:17,代码来源:DumpFileAnalyzer.java
示例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;
}
开发者ID:dice-group,项目名称:Tapioca,代码行数:25,代码来源:MetaDataInformationCollector.java
示例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.");
}
开发者ID:dice-group,项目名称:gerbil,代码行数:24,代码来源:NIFDatasetLoadingTest.java
示例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;
}
开发者ID:cmoen,项目名称:mallet,代码行数:22,代码来源:Assignment.java
示例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();
}
}
开发者ID:cmoen,项目名称:mallet,代码行数:17,代码来源:Alphabet.java
示例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);
}
}
开发者ID:cmoen,项目名称:mallet,代码行数:18,代码来源:Alphabet.java
示例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;
}
开发者ID:clearnlp,项目名称:clearnlp,代码行数:22,代码来源:AbstractNLP.java
示例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;
}
开发者ID:clearnlp,项目名称:clearnlp,代码行数:22,代码来源:AbstractNLP.java
示例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);
}
}
开发者ID:clearnlp,项目名称:clearnlp,代码行数:25,代码来源:StringTrainSpace.java
示例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);
}
}
}
开发者ID:clearnlp,项目名称:clearnlp,代码行数:25,代码来源:StringTrainSpace.java
示例16: toSparseFeatureVector
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
/**
* Returns the sparse feature vector converted from the string feature vector.
* During the conversion, discards features not found in this model.
* @param vector the string feature vector.
* @return the sparse feature vector converted from the string feature vector.
*/
public SparseFeatureVector toSparseFeatureVector(StringFeatureVector vector)
{
SparseFeatureVector sparse = new SparseFeatureVector(vector.hasWeight());
int i, index, size = vector.size();
ObjectIntOpenHashMap<String> map;
String type, value;
for (i=0; i<size; i++)
{
type = vector.getType(i);
value = vector.getValue(i);
if ((map = m_features.get(type)) != null && (index = map.get(value)) > 0)
{
if (sparse.hasWeight())
sparse.addFeature(index, vector.getWeight(i));
else
sparse.addFeature(index);
}
}
sparse.trimToSize();
return sparse;
}
开发者ID:clearnlp,项目名称:clearnlp,代码行数:31,代码来源:StringModel.java
示例17: getProb1DAux
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
private Pair<Double,StringDoublePair[]> getProb1DAux(String key)
{
ObjectIntOpenHashMap<String> map = get(key);
if (map == null) return null;
StringDoublePair[] probs = new StringDoublePair[map.size()-1];
int i = 0, total = map.get(TOTAL);
String value;
for (ObjectCursor<String> cur : map.keys())
{
value = cur.value;
if (!value.equals(TOTAL))
probs[i++] = new StringDoublePair(value, (double)map.get(value)/total);
}
double prior = (double)total / i_total;
return new Pair<Double,StringDoublePair[]>(prior, probs);
}
开发者ID:clearnlp,项目名称:clearnlp,代码行数:21,代码来源:Prob2DMap.java
示例18: printMap
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
static public void printMap(PrintStream fout, ObjectIntOpenHashMap<String> map, String delim)
{
StringBuilder build;
fout.println(map.size());
for (ObjectCursor<String> cur : map.keys())
{
build = new StringBuilder();
build.append(cur.value);
build.append(delim);
build.append(map.get(cur.value));
fout.println(build.toString());
}
}
开发者ID:clearnlp,项目名称:clearnlp,代码行数:17,代码来源:UTOutput.java
示例19: getFieldMap
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
/** Called by {@link AbstractRun#getReader(Element)}. */
private ObjectIntOpenHashMap<String> getFieldMap(Element eReader)
{
NodeList list = eReader.getElementsByTagName(TAG_READER_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_READER_COLUMN_FIELD);
index = Integer.parseInt(element.getAttribute(TAG_READER_COLUMN_INDEX));
map.put(field, index);
}
return map;
}
开发者ID:clearnlp,项目名称:clearnlp,代码行数:22,代码来源:AbstractRun.java
示例20: getPOSReader
import com.carrotsearch.hppc.ObjectIntOpenHashMap; //导入依赖的package包/类
/** Called by {@link AbstractRun#getReader(Element)}. */
private POSReader getPOSReader(Element eReader)
{
ObjectIntOpenHashMap<String> map = getFieldMap(eReader);
int iForm = map.get(AbstractColumnReader.FIELD_FORM) - 1;
int iPos = map.get(AbstractColumnReader.FIELD_POS) - 1;
if (iForm < 0)
{
System.err.printf("The '%s' field must be specified in the configuration file.\n", AbstractColumnReader.FIELD_FORM);
System.exit(1);
}
return new POSReader(iForm, iPos);
}
开发者ID:clearnlp,项目名称:clearnlp,代码行数:17,代码来源:AbstractRun.java
注:本文中的com.carrotsearch.hppc.ObjectIntOpenHashMap类示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论