ArrayList<ViterbiCandidate> candidates = new ArrayList<ViterbiCandidate>(candidateUnitSet.size()); for (int leftIndex : candidateUnitSet.toArray()) { DiphoneUnit diphoneUnit = new DiphoneUnit(unitReader.units[leftIndex], unitReader.units[leftIndex + 1]); logger.debug("Preselected " + candidateUnitSet.size() + " diphone candidates for target " + target); return candidates;
ArrayList<ViterbiCandidate> candidates = new ArrayList<ViterbiCandidate>(candidateUnitSet.size()); for (int leftIndex : candidateUnitSet.toArray()) { DiphoneUnit diphoneUnit = new DiphoneUnit(unitReader.units[leftIndex], unitReader.units[leftIndex + 1]); logger.debug("Preselected " + candidateUnitSet.size() + " diphone candidates for target " + target); return candidates;
/** * Returns the number of entries in the set. * @return the set's size. */ public int size() { return this._set.size(); }
/** * Returns a new array containing the values in the set. * * @return an <code>int[]</code> value */ public int[] toArray() { int[] result = new int[size()]; int[] set = _set; byte[] states = _states; for (int i = states.length, j = 0; i-- > 0;) { if (states[i] == FULL) { result[j++] = set[i]; } } return result; }
public ConfidenceBased(int trainSize, ClassificationScoreDB classification, TIntHashSet categoriesFilter, double[] probabilitySlopes, int topProbabilities) { super(trainSize, classification, categoriesFilter); //FIXME asser probabilitySlopes length this.slopes = probabilitySlopes; if (topProbabilities > this.categoriesFilter.size()) { topProbabilities = this.categoriesFilter.size(); } docCategoriesFilter = new TIntHashSet[testSize]; for (int docId = 0; docId < testSize; docId++) { docCategoriesFilter[docId] = filterByTopProbabilities(docId, topProbabilities); } }
/** * Compares this set with another set for equality of their stored * entries. * * @param other an <code>Object</code> value * @return a <code>boolean</code> value */ public boolean equals(Object other) { if (! (other instanceof TIntHashSet)) { return false; } final TIntHashSet that = (TIntHashSet)other; if (that.size() != this.size()) { return false; } return forEach(new TIntProcedure() { public final boolean execute(int value) { return that.contains(value); } }); }
@Override protected void firstPosting(Posting p) { super.firstPosting(p); if (positions.size() > 30) { positions.clear(); positions.compact(); } else { positions.clear(); } positions.addAll(((BlockPosting)p).getPositions()); }
@Override protected void firstPosting(Posting p) { super.firstPosting(p); if (positions.size() > 30) { positions.clear(); positions.compact(); } else { positions.clear(); } positions.addAll(((BlockPosting)p).getPositions()); }
@Override protected void firstPosting(Posting p) { super.firstPosting(p); if (positions.size() > 30) { positions.clear(); positions.compact(); } else { positions.clear(); } positions.addAll(((BlockPosting)p).getPositions()); }
@Override protected void firstPosting(Posting p) { super.firstPosting(p); if (positions.size() > 30) { positions.clear(); positions.compact(); } else { positions.clear(); } positions.addAll(((BlockPosting)p).getPositions()); }
/** * Get all relevant documents regardless of their relevance grades. * @return The identifiers of all relevant documents. */ public THashSet<String> getAllRelevantDocuments(){ THashSet<String> docnos = new THashSet<String>(); int[] grades = relGrade.toArray(); for (int i=0; i<relGrade.size(); i++){ THashSet<String> docnosTmp = (THashSet<String>)relGradeDocnosMap.get(grades[i]); String[] docnosArray = (String[])docnosTmp.toArray(new String[docnosTmp.size()]); for (int j=0; j<docnosArray.length; j++) docnos.add(docnosArray[j]); } return docnos; }
/** * Get all relevant documents regardless of their relevance grades. * @return The identifiers of all relevant documents. */ public THashSet<String> getAllRelevantDocuments(){ THashSet<String> docnos = new THashSet<String>(); int[] grades = relGrade.toArray(); for (int i=0; i<relGrade.size(); i++){ THashSet<String> docnosTmp = (THashSet<String>)relGradeDocnosMap.get(grades[i]); String[] docnosArray = (String[])docnosTmp.toArray(new String[docnosTmp.size()]); for (int j=0; j<docnosArray.length; j++) docnos.add(docnosArray[j]); } return docnos; }
public void processTerm(String term) { /* null means the term has been filtered out (eg stopwords) */ if (term != null) { /* add term to Document tree */ for (String fieldName: termFields) { int tmp = fieldNames.get(fieldName); if (tmp > 0) { fields.add(tmp -1); } } if (ELSE_ENABLED && fields.size() == 0) { fields.add(ELSE_FIELD_ID); } ((FieldDocumentPostingList)termsInDocument).insert(term,fields.toArray()); numOfTokensInDocument++; fields.clear(); } }
public void processTerm(String term) { if (term != null) { TIntHashSet freqs = new TIntHashSet(0); for (String docField : docFields) freqs.add(fieldIDs.get(docField)); if (fieldIDs.containsKey("ELSE") && freqs.size() == 0) freqs.add(fieldIDs.get("ELSE")); ((FieldDocumentPostingList) fdpl).insert(term, freqs.toArray()); } }
public void processTerm(String t) { // null means the term has been filtered out (eg stopwords) if (t != null) { //add term to document posting list for (String fieldName: termFields) { int tmp = fieldNames.get(fieldName); if (tmp > 0) { fields.add(tmp -1); } } if (ELSE_ENABLED && fields.size() == 0) { fields.add(ELSE_FIELD_ID); } ((BlockFieldDocumentPostingList)termsInDocument).insert(t,fields.toArray(), blockId); numOfTokensInDocument++; if (++numOfTokensInBlock >= BLOCK_SIZE && blockId < MAX_BLOCKS) { numOfTokensInBlock = 0; blockId++; } fields.clear(); } }
public void processTerm(String t) { // null means the term has been filtered out (eg stopwords) if (t != null) { //add term to document posting list for (String fieldName: termFields) { int tmp = fieldNames.get(fieldName); if (tmp > 0) { fields.add(tmp -1); } } if (ELSE_ENABLED && fields.size() == 0) { fields.add(ELSE_FIELD_ID); } ((BlockFieldDocumentPostingList)termsInDocument).insert(t,fields.toArray(), blockId); numOfTokensInDocument++; if (++numOfTokensInBlock >= BLOCK_SIZE && blockId < MAX_BLOCKS) { numOfTokensInBlock = 0; blockId++; } fields.clear(); } }
/** * Get all relevant documents regardless of their relevance grades. * @return The identifiers of all relevant documents. */ public String[] getAllRelevantDocumentsToArray(){ THashSet<String> docnos = new THashSet<String>(); int[] grades = relGrade.toArray(); for (int i=0; i<relGrade.size(); i++){ THashSet<String> docnosTmp = (THashSet<String>)relGradeDocnosMap.get(grades[i]); String[] docnosArray = (String[])docnosTmp.toArray(new String[docnosTmp.size()]); for (int j=0; j<docnosArray.length; j++) docnos.add(docnosArray[j]); } return (String[])docnos.toArray(new String[docnos.size()]); } /**
/** * Get all relevant documents regardless of their relevance grades. * @return The identifiers of all relevant documents. */ public String[] getAllRelevantDocumentsToArray(){ THashSet<String> docnos = new THashSet<String>(); int[] grades = relGrade.toArray(); for (int i=0; i<relGrade.size(); i++){ THashSet<String> docnosTmp = (THashSet<String>)relGradeDocnosMap.get(grades[i]); String[] docnosArray = (String[])docnosTmp.toArray(new String[docnosTmp.size()]); for (int j=0; j<docnosArray.length; j++) docnos.add(docnosArray[j]); } return (String[])docnos.toArray(new String[docnos.size()]); } /**
public void processTerm(String term) { /* null means the term has been filtered out (eg stopwords) */ if (term != null) { /* add term to Document tree */ for (String fieldName: termFields) { int tmp = fieldNames.get(fieldName); if (tmp > 0) { fields.add(tmp -1); } } if (ELSE_ENABLED && fields.size() == 0) { fields.add(ELSE_FIELD_ID); } ((FieldDocumentPostingList)termsInDocument).insert(term,fields.toArray()); numOfTokensInDocument++; fields.clear(); } } @Override
public void computeTSR(IIndex index, IIndex testindex){ selectBestFeatures(index); // Select the features to remove from DB. JatecsLogger .status() .print("Selecting worst features to remove from DB and removing it..."); TIntArrayList toRemove = new TIntArrayList(); IIntIterator it = index.getFeatureDB().getFeatures(); while(it.hasNext()){ int featID = it.next(); if (!_bestFeatsSet.contains(featID)){ toRemove.add(featID); } } TIntArrayListIterator toRemoveIt=new TIntArrayListIterator(toRemove); // Remove the features from DB. index.removeFeatures(toRemoveIt); if(testindex!=null){ toRemoveIt.begin(); testindex.removeFeatures(toRemoveIt); } JatecsLogger.status().println("done."); JatecsLogger.status().println("Round-robin TSR: "+_bestFeatsSet.size()+" features globally selected, "+_rounds+" features for each category"); } }