protected void addGuess(L guess, L label, boolean addUnknownLabels) { if (label == null) { noLabel++; return; } if (addUnknownLabels) { if (labelIndex == null) { labelIndex = new HashIndex<L>(); } labelIndex.add(guess); labelIndex.add(label); } if (guess.equals(label)) { correctGuesses.incrementCount(label); tokensCorrect++; } if (!guess.equals(negLabel)) { foundGuessed.incrementCount(guess); } if (!label.equals(negLabel)) { foundCorrect.incrementCount(label); } tokensCount++; }
public void clearCounts() { if (foundCorrect != null) { foundCorrect.clear(); } else { foundCorrect = new IntCounter<L>(); } if (foundGuessed != null) { foundGuessed.clear(); } else { foundGuessed = new IntCounter<L>(); } if (correctGuesses != null) { correctGuesses.clear(); } else { correctGuesses = new IntCounter<L>(); } if (tpCount != null) { Arrays.fill(tpCount, 0); } if (fnCount != null) { Arrays.fill(fnCount, 0); } if (fpCount != null) { Arrays.fill(fpCount, 0); } tokensCount = 0; tokensCorrect = 0; }
/** * In a three time repetition: it ask use to input a int and try to find it in a random generated * int array. */ public static void main(String[] args) { Scanner input = new Scanner(System.in); for (int i = 1; i <= 3; i++) { System.out.println("\nWhich number do you wish to find?"); int target = input.nextInt(); int[] numberArray = makeArray(); IntCounter intCounter = new IntCounter(numberArray); intCounter.showTarget(target); } System.out.println("\nFinished"); }
protected void finalizeCounts() { negIndex = labelIndex.indexOf(negLabel); int numClasses = labelIndex.size(); if (tpCount == null || tpCount.length != numClasses) { tpCount = new int[numClasses]; } if (fpCount == null || fpCount.length != numClasses) { fpCount = new int[numClasses]; } if (fnCount == null || fnCount.length != numClasses) { fnCount = new int[numClasses]; } for (int i = 0; i < numClasses; i++) { L label = labelIndex.get(i); tpCount[i] = correctGuesses.getIntCount(label); fnCount[i] = foundCorrect.getIntCount(label) - tpCount[i]; fpCount[i] = foundGuessed.getIntCount(label) - tpCount[i]; } }
public int getRelevant() { return foundCorrect.totalIntCount(); }
public int getRelevant(L label) { return foundCorrect.getIntCount(label); }
public int getRetrieved() { return foundGuessed.totalIntCount(); }
public int getRetrieved(L label) { return foundGuessed.getIntCount(label); }
public int getCorrect(L label) { return correctGuesses.getIntCount(label); }
/** Return overall number of correct answers */ public int getCorrect() { return correctGuesses.totalIntCount(); }