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


Java TIntArrayList.sort方法代码示例

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


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

示例1: selectNegatives

import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
public TIntArrayListIterator selectNegatives(String category) {

        short catID = _index.getCategoryDB().getCategory(category);

        TreeSet<Item> best = _best.get(catID);
        assert (best != null);

        TIntArrayList neg = new TIntArrayList();
        Iterator<Item> it = best.iterator();
        while (it.hasNext()) {
            Item docS = it.next();
            assert (!neg.contains(docS.docID));
            neg.add(docS.docID);
        }

        neg.sort();

        return new TIntArrayListIterator(neg);
    }
 
开发者ID:jatecs,项目名称:jatecs,代码行数:20,代码来源:BestKNNNegativesChooser.java

示例2: selectNegatives

import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
public TIntArrayListIterator selectNegatives(String category) {
    short catID = _index.getCategoryDB().getCategory(category);

    TreeSet<DocumentSimilar> best = _best.get(catID);

    TIntArrayList neg = new TIntArrayList();
    Iterator<DocumentSimilar> it = best.iterator();
    while (it.hasNext()) {
        DocumentSimilar docS = it.next();
        neg.add(docS.docID);
    }

    neg.sort();

    return new TIntArrayListIterator(neg);
}
 
开发者ID:jatecs,项目名称:jatecs,代码行数:17,代码来源:BestAutomaticNegativesChooser.java

示例3: removeCategoryFeatures

import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
public void removeCategoryFeatures(short category,
                                   IIntIterator removedFeatures) {
    TIntArrayList feats = _categoriesFeatures.get(category);
    while (removedFeatures.hasNext()) {
        int feature = removedFeatures.next();
        if (feats.binarySearch(feature) < 0)
            feats.add(feature);
    }
    feats.sort();
    _hasLocalRepresentation = _hasLocalRepresentation || feats.size() > 0;
}
 
开发者ID:jatecs,项目名称:jatecs,代码行数:12,代码来源:TroveDomainDB.java

示例4: computeTSR

import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
@Override
public void computeTSR(IIndex index) {
	TextualProgressBar bar = new TextualProgressBar(
			"Compute TSR with by using regex matcher");
	int total = index.getFeatureDB().getFeaturesCount();
	int step = 0;

	TIntArrayList toRemove = new TIntArrayList();

	IIntIterator it = index.getFeatureDB().getFeatures();
	while (it.hasNext()) {
		int featID = it.next();
		String featName = index.getFeatureDB().getFeatureName(featID);
		if (!featName.matches(regexPatternMatching)) {
			toRemove.add(featID);
		}

		step++;
		bar.signal((step * 100) / total);
	}

	bar.signal(100);

	toRemove.sort();

	// Remove the worst features.
	JatecsLogger.status().print("Removing worst features...");
	TIntArrayListIterator toRemoveIT = new TIntArrayListIterator(toRemove);
	index.removeFeatures(toRemoveIT);
	JatecsLogger.status().println(
			"done. Now the DB contains "
					+ index.getFeatureDB().getFeaturesCount()
					+ " feature(s).");
}
 
开发者ID:jatecs,项目名称:jatecs,代码行数:35,代码来源:StringPrefixTSR.java

示例5: computeTSR

import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
public void computeTSR(IIndex index) {
    TextualProgressBar bar = new TextualProgressBar(
            "Compute global threshold ("
                    + Os.generateDoubleString(_threshold, 3)
                    + ") TSR with " + _function.getClass().getName());
    int total = index.getFeatureDB().getFeaturesCount();
    int step = 0;

    TIntArrayList toRemove = new TIntArrayList();

    IIntIterator it = index.getFeatureDB().getFeatures();
    while (it.hasNext()) {
        int featID = it.next();

        double score = _function.compute((short) 0, featID, index);

        if (score < _threshold)
            toRemove.add(featID);

        step++;
        bar.signal((step * 100) / total);
    }

    bar.signal(100);

    toRemove.sort();

    // Remove the worst features.
    JatecsLogger.status().print(
            "Removing " + toRemove.size() + " features...");
    index.removeFeatures(new TIntArrayListIterator(toRemove));
    JatecsLogger.status().println(
            "done. Now the DB contains "
                    + index.getFeatureDB().getFeaturesCount()
                    + " feature(s).");
}
 
开发者ID:jatecs,项目名称:jatecs,代码行数:37,代码来源:GlobalThresholdTSR.java

示例6: computeTSR

import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
@Override
public void computeTSR(IIndex index) {
    TextualProgressBar bar = new TextualProgressBar(
            "Compute TSR with by using regex matcher");
    int total = index.getFeatureDB().getFeaturesCount();
    int step = 0;

    TIntArrayList toRemove = new TIntArrayList();

    IIntIterator it = index.getFeatureDB().getFeatures();
    while (it.hasNext()) {
        int featID = it.next();
        String featName = index.getFeatureDB().getFeatureName(featID);
        if (!featName.matches(regexPatternMatching)) {
            toRemove.add(featID);
        }

        step++;
        bar.signal((step * 100) / total);
    }

    bar.signal(100);

    toRemove.sort();

    // Remove the worst features.
    JatecsLogger.status().print("Removing worst features...");

    index.removeFeatures(new TIntArrayListIterator(toRemove));

    JatecsLogger.status().println(
            "done. Now the DB contains "
                    + index.getFeatureDB().getFeaturesCount()
                    + " feature(s).");

}
 
开发者ID:jatecs,项目名称:jatecs,代码行数:37,代码来源:RegexTSR.java

示例7: selectPositives

import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
protected IIndex selectPositives(short catID, IIndex training) {
    // First create a new index.
    IIndex idx = training.cloneIndex();

    IShortIterator childCats = getAllChildsCategoriesFor(idx, catID);
    short nextCatID = Short.MIN_VALUE;
    if (childCats.hasNext())
        nextCatID = childCats.next();

    // Remove unwanted categories.
    TShortArrayList toRemove = new TShortArrayList();
    for (short i = 0; i < training.getCategoryDB().getCategoriesCount(); i++) {
        if (i == nextCatID) {
            if (childCats.hasNext())
                nextCatID = childCats.next();
            continue;
        }

        toRemove.add(i);
    }
    toRemove.sort();
    idx.removeCategories(new TShortArrayListIterator(toRemove));

    // Remove unwanted documents.
    TIntArrayList docsToRemove = new TIntArrayList();
    IIntIterator docs = idx.getDocumentDB().getDocuments();
    while (docs.hasNext()) {
        int docID = docs.next();
        IShortIterator curCats = idx.getClassificationDB()
                .getDocumentCategories(docID);
        if (!curCats.hasNext())
            docsToRemove.add(docID);
    }

    docsToRemove.sort();
    idx.removeDocuments(new TIntArrayListIterator(docsToRemove), false);

    return idx;
}
 
开发者ID:jatecs,项目名称:jatecs,代码行数:40,代码来源:TreeBoostLearner.java

示例8: testBuilder

import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
public void testBuilder() {
  final Ref<Integer> trigramCountRef = new Ref<Integer>();
  final TIntArrayList list = new TIntArrayList();

  TrigramBuilder.processTrigrams("String$CharData", new TrigramBuilder.TrigramProcessor() {
    @Override
    public boolean execute(int value) {
      list.add(value);
      return true;
    }

    @Override
    public boolean consumeTrigramsCount(int count) {
      trigramCountRef.set(count);
      return true;
    }
  });

  list.sort();
  Integer trigramCount = trigramCountRef.get();
  assertNotNull(trigramCount);

  int expectedTrigramCount = 13;
  assertEquals(expectedTrigramCount, (int)trigramCount);
  assertEquals(expectedTrigramCount, list.size());

  int[] expected = {buildTrigram("$Ch"), buildTrigram("arD"), buildTrigram("ata"), 6514785, 6578548, 6759523, 6840690, 6909543, 7235364, 7496801, 7498094, 7566450, 7631465, };
  for(int i = 0; i < expectedTrigramCount; ++i) assertEquals(expected[i], list.getQuick(i));
}
 
开发者ID:jskierbi,项目名称:intellij-ce-playground,代码行数:30,代码来源:TrigramBuilderTest.java

示例9: computeTSR

import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
public void computeTSR(IIndex index) {
    TextualProgressBar bar = new TextualProgressBar(
            "Compute global TSR with " + _func.getClass().getName());
    int total = index.getFeatureDB().getFeaturesCount();
    int step = 0;

    TreeSet<FeatureEntry> best = new TreeSet<FeatureEntry>();
    TIntArrayList toRemove = new TIntArrayList();

    IIntIterator it = index.getFeatureDB().getFeatures();
    while (it.hasNext()) {
        int featID = it.next();

        double[] scores = new double[index.getCategoryDB()
                .getCategoriesCount()];

        for (short catID = 0; catID < scores.length; catID++) {
            if (!index.getDomainDB().hasCategoryFeature(catID, featID))
                scores[catID] = 0;
            else
                scores[catID] = _func.compute(catID, featID, index);
        }

        // Compute feature global value.
        double score = _global.compute(scores, index);

        FeatureEntry fe = new FeatureEntry();
        fe.featureID = featID;
        fe.score = score;
        best.add(fe);
        if (best.size() > _numBestFeature) {
            toRemove.add(best.first().featureID);
            best.remove(best.first());

        }

        step++;
        bar.signal((step * 100) / total);
    }

    bar.signal(100);

    toRemove.sort();

    // Remove the worst features.
    JatecsLogger.status().print("Removing worst features...");
    index.removeFeatures(new TIntArrayListIterator(toRemove));

    JatecsLogger.status().println(
            "done. Now the DB contains "
                    + index.getFeatureDB().getFeaturesCount()
                    + " feature(s).");
}
 
开发者ID:jatecs,项目名称:jatecs,代码行数:54,代码来源:GlobalTSR.java

示例10: buildBinaryLocalIndex

import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
private IIndex buildBinaryLocalIndex(IIndex trainingIndex,
                                     ArrayList<Short> catsGood) {
    if (!(catsGood.size() == 2))
        throw new RuntimeException("The set of valid categories must be 2");

    // First create a new index.
    IIndex idx = trainingIndex.cloneIndex();

    // Remove unwanted categories.
    TShortArrayList toRemove = new TShortArrayList();
    IShortIterator allCats = idx.getCategoryDB().getCategories();
    while (allCats.hasNext()) {
        short catID = allCats.next();
        if (catsGood.contains(catID))
            continue;

        toRemove.add(catID);
    }
    toRemove.sort();
    idx.removeCategories(new TShortArrayListIterator(toRemove));

    // Remove unwanted documents.
    TIntArrayList docsToRemove = new TIntArrayList();
    IIntIterator docs = idx.getDocumentDB().getDocuments();
    while (docs.hasNext()) {
        int docID = docs.next();
        IShortIterator curCats = idx.getClassificationDB()
                .getDocumentCategories(docID);
        if (!curCats.hasNext())
            docsToRemove.add(docID);
    }

    docsToRemove.sort();
    idx.removeDocuments(new TIntArrayListIterator(docsToRemove), true);

    // If the case, apply TSR.
    if (tsrType != null) {
        tsrType.computeTSR(idx);

        // Apply weighting.
        IWeighting weighting = null;
        if (weightingType == WeightingType.TF_IDF) {
            weighting = new TfNormalizedIdf(idx);
        } else if (weightingType == WeightingType.BM25) {
            weighting = new BM25(idx);
        }

        idx = weighting.computeWeights(idx);
    }

    // Remove 2nd category to make an index for a binary classifier.
    toRemove.clear();
    String catNameToRemove = trainingIndex.getCategoryDB()
            .getCategoryName(catsGood.get(1));
    toRemove.add(idx.getCategoryDB().getCategory(catNameToRemove));
    idx.removeCategories(new TShortArrayListIterator(toRemove));

    return idx;
}
 
开发者ID:jatecs,项目名称:jatecs,代码行数:60,代码来源:SvmDDagSingleLabelLearner.java

示例11: splitIndex

import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
public static Pair<IIndex, IIndex> splitIndex(int step, IIndex index,
                                              int numValidationSteps) {
    int numPositives = index.getDocumentDB().getDocumentsCount();

    int numSteps = Math.min(numPositives, numValidationSteps);
    if (step >= numSteps)
        return null;

    TIntArrayList tr = new TIntArrayList();
    TIntArrayList va = new TIntArrayList();

    int numPositivesInValidation = numPositives / numSteps;
    int numPositivesInTraining = numPositives - numPositivesInValidation;
    int startTrainingID = (numPositives / numSteps) * step;
    int endTrainingID = (startTrainingID + numPositivesInTraining - 1);
    TIntIntHashMap map = new TIntIntHashMap();
    for (int i = startTrainingID; i <= endTrainingID; i++) {
        int v = i % numPositives;
        map.put(v, v);
    }

    int curDoc = 0;
    IIntIterator docs = index.getDocumentDB().getDocuments();
    while (docs.hasNext()) {
        int docID = docs.next();
        if (map.containsKey(curDoc)) {
            tr.add(docID);
        } else {
            va.add(docID);
        }
        curDoc++;
    }

    tr.sort();
    va.sort();

    IIndex trIndex = index.cloneIndex();
    trIndex.removeDocuments(new TIntArrayListIterator(va), false);

    IIndex vaIndex = index.cloneIndex();
    vaIndex.removeDocuments(new TIntArrayListIterator(tr), false);

    JatecsLogger.status().println(
            "done. The training contains " + tr.size()
                    + " document(s) and the validation contains "
                    + va.size() + " document(s).");

    Pair<IIndex, IIndex> ret = new Pair<IIndex, IIndex>(trIndex, vaIndex);
    return ret;

}
 
开发者ID:jatecs,项目名称:jatecs,代码行数:52,代码来源:DCSSingleLabelKnnFoldValidator.java

示例12: splitIndex

import gnu.trove.TIntArrayList; //导入方法依赖的package包/类
public static Pair<IIndex, IIndex> splitIndex(int step, IIndex index, int numValidationSteps) {
    int numPositives = index.getDocumentDB().getDocumentsCount();

    int numSteps = Math.min(numPositives, numValidationSteps);
    if (step >= numSteps)
        return null;

    TIntArrayList tr = new TIntArrayList();
    TIntArrayList va = new TIntArrayList();

    int numPositivesInValidation = numPositives / numSteps;
    int numPositivesInTraining = numPositives - numPositivesInValidation;
    int startTrainingID = (numPositives / numSteps) * step;
    int endTrainingID = (startTrainingID + numPositivesInTraining - 1);
    TIntIntHashMap map = new TIntIntHashMap();
    for (int i = startTrainingID; i <= endTrainingID; i++) {
        int v = i % numPositives;
        map.put(v, v);
    }


    int curDoc = 0;
    IIntIterator docs = index.getDocumentDB().getDocuments();
    while (docs.hasNext()) {
        int docID = docs.next();
        if (map.containsKey(curDoc)) {
            tr.add(docID);
        } else {
            va.add(docID);
        }
        curDoc++;
    }


    tr.sort();
    va.sort();


    IIndex trIndex = index.cloneIndex();
    trIndex.removeDocuments(new TIntArrayListIterator(va), false);


    IIndex vaIndex = index.cloneIndex();
    vaIndex.removeDocuments(new TIntArrayListIterator(tr), false);


    JatecsLogger.status().println("done. The training contains " + tr.size() + " document(s) and the validation contains " + va.size() + " document(s).");

    Pair<IIndex, IIndex> ret = new Pair<IIndex, IIndex>(trIndex, vaIndex);
    return ret;

}
 
开发者ID:jatecs,项目名称:jatecs,代码行数:53,代码来源:WMVSingleLabelKnnFoldValidator.java


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