TIntHashSet candidateUnitSet = new TIntHashSet(); candidateUnitSet.add(unit.index); candidateUnitSet.add(leftNeighbour.index); ArrayList<ViterbiCandidate> candidates = new ArrayList<ViterbiCandidate>(candidateUnitSet.size()); for (int leftIndex : candidateUnitSet.toArray()) { DiphoneUnit diphoneUnit = new DiphoneUnit(unitReader.units[leftIndex], unitReader.units[leftIndex + 1]); ViterbiCandidate candidate = new ViterbiCandidate(diphoneTarget, diphoneUnit, targetCostFunction); logger.debug("Preselected " + candidateUnitSet.size() + " diphone candidates for target " + target); return candidates;
public final boolean execute(int value) { return that.contains(value); } });
/** * Empties the set. */ public void clear() { this._set.clear(); }
/** * union 2 int[] * @param arr1 * @param arr2 * @return int[] */ public static int[] union(int[] arr1, int[] arr2) { TIntHashSet set = new TIntHashSet(); set.addAll(arr1); set.addAll(arr2); int[] arr = set.toArray(); Arrays.sort(arr); return arr; }
TIntHashSet hIndices = new TIntHashSet(instances.getDataAlphabet().size()); hIndices.addAll(indices); hIndices.add(i); } else return mean(instances, hIndices.toArray());
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(); } }
TIntHashSet wordIndices = new TIntHashSet(); int type = alphabet.lookupIndex(topicTopWords[topic][i]); topicWordIndicesInOrder[topic][i] = type; wordIndices.add(type); docTopicWordIndices[topic] = new TIntHashSet(); if (topicTopWordIndices[topic].contains(type)) { docTopicWordIndices[topic].add(type); if (supportedWords.contains(indices[i])) { for (int j = i; j < numTopWords; j++) { if (i == j) { else if (supportedWords.contains(indices[j])) { topicCodocumentMatrices[topic][i][j]++; topicCodocumentMatrices[topic][j][i]++; docTopicWordIndices[topic].clear(); topicCounts[topic] = 0;
public Incremental(int trainSize, ClassificationScoreDB classification, TIntHashSet categoriesFilter, EstimationType estimation, ContingencyTableSet evaluation, IGain gain, IGain firstRankGain, double[] probabilitySlope, double[] prevalencies) { super(trainSize, classification, categoriesFilter, estimation, evaluation, firstRankGain, probabilitySlope, prevalencies); macroRankTable = new TIntDoubleHashMap((int) (testSize + testSize * 0.25), (float) 0.75); microRankTable = new TIntDoubleHashMap((int) (testSize + testSize * 0.25), (float) 0.75); macroAlreadySeen = new TIntHashSet((int) (testSize + testSize * 0.25), (float) 0.75); microAlreadySeen = new TIntHashSet((int) (testSize + testSize * 0.25), (float) 0.75); probabilities = new double[testSize][numOfCategories]; for (int docId = 0; docId < testSize; docId++) { Set<Entry<Short, ClassifierRangeWithScore>> entries = classification.getDocumentScoresAsSet(docId); Iterator<Entry<Short, ClassifierRangeWithScore>> iterator = entries.iterator(); while (iterator.hasNext()) { Entry<Short, ClassifierRangeWithScore> next = iterator.next(); ClassifierRangeWithScore value = next.getValue(); if (categoriesFilter.contains(next.getKey())) { probabilities[docId][catMap.get(next.getKey())] = probability(Math.abs(value.score - value.border), next.getKey()); } } } }
/** Insert a term into this document, occurs at given block id */ public void insert(String t, int blockId) { insert(t); TIntHashSet blockids = null; if ((blockids = term_blocks.get(t)) == null) { term_blocks.put(t, blockids = new TIntHashSet(/*TODO */)); } blockids.add(blockId); blockCount++; }
/** * Output the evaluation result of each query to the specific file. * @param resultEvalFilename String the name of the file in which to * save the evaluation results. */ public void writeEvaluationResultOfEachQuery(String resultEvalFilename) { int[] queryids = queryNumbers.toArray(); Arrays.sort(queryids); try { final PrintWriter out = new PrintWriter(Files.writeFileWriter(resultEvalFilename)); final StringBuilder sb = new StringBuilder(); for (int i = 0; i < this.queryNumbers.size(); i++) { sb.append( queryids[i] + " " + Rounding.toString( recipRank.get(queryids[i]), 4) + ApplicationSetup.EOL); } out.print(sb.toString()); out.close(); } catch (IOException fnfe) { logger.error("Couldn't write evaluation file "+resultEvalFilename, fnfe); } } /**
final TIntHashSet l = new TIntHashSet(tk.countTokens()); while (tk.hasMoreTokens()) { final String tok = tk.nextToken(); l.add(i - 1); l.add(i - 1); return l.toArray();
@Override public int[] getPositions() { int[] rtr = positions.toArray(); Arrays.sort(rtr); return rtr; }
TIntHashSet distinctKeys = new TIntHashSet(); distinctKeys.addAll(countsX.keys()); distinctKeys.addAll(countsY.keys()); TIntIterator iterator = distinctKeys.iterator(); while (iterator.hasNext()) { key = iterator.next();
/** * return intersection between two int[] * @param arr1 * @param arr2 * @return intersection */ public static int[] intersection(int[] arr1, int[] arr2) { TIntHashSet set = new TIntHashSet(); set.addAll(arr1); Arrays.sort(arr2); TIntArrayList list = new TIntArrayList(); for (int i : arr2) { if (set.contains(i)) { list.add(i); } } return list.toNativeArray(); }
public int[] recover() throws SimpleXAResourceException { int[] nodePhases = persistentNodePool.recover(); int[] stringPhases = persistentStringPool.recover(); // If both are empty then return empty. if (nodePhases.length == 0 && stringPhases.length == 0) { return nodePhases; } // Else if the intersection is empty *error*, TIntHashSet phaseSet = new TIntHashSet(nodePhases); phaseSet.retainAll(stringPhases); if (phaseSet.isEmpty()) { throw new SimpleXAResourceException("No matching phases between Node and String Pools."); } //else return the intersection. return phaseSet.toArray(); }
private void initCommon(int capacity) { m_paramIndices = new TIntHashSet(); m_onceThrough = false; }
public StaticRank(int trainSize, ClassificationScoreDB classification, TIntHashSet categoriesFilter) { this.trainSize = trainSize; this.classification = classification; this.testSize = classification.getDocumentCount(); if (categoriesFilter == null || categoriesFilter.isEmpty()) { this.categoriesFilter = new TIntHashSet((int) (testSize + testSize * 0.25), (float) 0.75); for (short i = 0; i < classification.getDocumentScoresAsSet(0).size(); i++) { this.categoriesFilter.add(i); } } else { this.categoriesFilter = categoriesFilter; } }
/** * Add an identifier of a relevant document with its relevance grade. * @param docno The identifier of the given relevant document. * @param grade The relevance grade of the given relevant document. */ public void insertRelDocno(String docno, int grade){ if (!relGrade.contains(grade)){ relGrade.add(grade); THashSet<String> gradeDocnos = new THashSet<String>(); gradeDocnos.add(docno); relGradeDocnosMap.put(grade, gradeDocnos); }else{ ((THashSet<String>)relGradeDocnosMap.get(grade)).add(docno); } }