Java Code Examples for gnu.trove.TIntIntHashMap#containsKey()

The following examples show how to use gnu.trove.TIntIntHashMap#containsKey() . 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: DeleteToWordStartAction.java    From consulo with Apache License 2.0 5 votes vote down vote up
private static void countQuotes(@Nonnull TIntIntHashMap holder, @Nonnull CharSequence text, int start, int end) {
  for (int i = end - 1; i >= start; i--) {
    char c = text.charAt(i);
    if (holder.containsKey(c)) {
      holder.put(c, holder.get(c) + 1);
    }
  }
}
 
Example 2
Source File: DCSSingleLabelKnnFoldValidator.java    From jatecs with GNU General Public License v3.0 4 votes vote down vote up
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;

}
 
Example 3
Source File: CRWMVSingleLabelKnnFoldValidator.java    From jatecs with GNU General Public License v3.0 4 votes vote down vote up
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;

}
 
Example 4
Source File: SingleLabelKnnFoldValidator.java    From jatecs with GNU General Public License v3.0 4 votes vote down vote up
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;

}
 
Example 5
Source File: WMVSingleLabelKnnFoldValidator.java    From jatecs with GNU General Public License v3.0 4 votes vote down vote up
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;

}
 
Example 6
Source File: CRDCSSingleLabelKnnFoldValidator.java    From jatecs with GNU General Public License v3.0 4 votes vote down vote up
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;

}
 
Example 7
Source File: NameSuggester.java    From consulo with Apache License 2.0 4 votes vote down vote up
private static boolean containsAllBetween(TIntIntHashMap matches, int first, int last) {
  for (int i = first; i <= last; i++) {
    if (!matches.containsKey(i)) return false;
  }
  return true;
}