@Override protected Map<Document, TermsOccurences> computeResult( ResultComputingContext<? extends TermsIndexingEquipment> context) { Set<Document> allDocuments = context.equipment().allDocuments(); EachDocumentTermsExtraction termsExtractions = context.preliminaryResult(ExtractingEachDocumentTerms.getInstance()); Map<Document, TermsOccurences> res = new HashMap<>(allDocuments.size()); for (Document doc : allDocuments) { final TermsExtraction docTermsExtraction = termsExtractions.termsExtractedFromDocument(doc); // conting the total number of occurences int count = 0; for (String term : docTermsExtraction.allTerms()) { count += docTermsExtraction.tokensOfTerms(term).size(); } final int totalNumber = count; // creating a TermsOccurences for that document TermsOccurences docTermsOccurences = new TermsOccurences() { @Override public int numberOfOccurences(String term) { return docTermsExtraction.tokensOfTerms(term).size(); } @Override public int totalNumberOfOccurences() { return totalNumber; } }; res.put(doc, docTermsOccurences); } // making immutable res = Collections.unmodifiableMap(res); logger.log(Level.INFO, "Just extracted the term-occurences information for each document."); return res; }
@Override protected Double computeResult(ResultComputingContext<? extends AccountingEquipment> context) { IncomeStatement incomeStatement = context.equipment().incomeStatement(); double opRev = incomeStatement.operatingRevenues(); double opEx = incomeStatement.operatingExpenses(); double ebitda = opRev - opEx; logger.log(Level.INFO, "Just calculated the EBITDA"); return ebitda; }
@Override protected List<Integer> computeResult( ResultComputingContext<? extends IntegerEquipment> context) { // obtaining the integer we're working on int integer = context.equipment().n(); // the result, a list of digits with most significant at the beginning of the list List<Integer> digits = new ArrayList<Integer>(); // performing successive divisions to find the digits. int remainder = integer; while (remainder != 0) { int digit = remainder % radix; digits.add(digit); remainder /= radix; } Collections.reverse(digits); return Collections.unmodifiableList(digits); }