Count the terms (labels, descriptions, aliases) of an item or property
document.

@param usageStatistics
statistics object to store counters in
@param termedDocument
document to count the terms of
519737
protected void countTerms(UsageStatistics usageStatistics,
			TermedDocument termedDocument) {
		usageStatistics.countLabels += termedDocument.getLabels().size();
		for (MonolingualTextValue mtv : termedDocument.getLabels().values()) {
			countKey(usageStatistics.labelCounts, mtv.getLanguageCode(), 1);
		}

		usageStatistics.countDescriptions += termedDocument.getDescriptions()
				.size();
		for (MonolingualTextValue mtv : termedDocument.getDescriptions()
				.values()) {
			countKey(usageStatistics.descriptionCounts, mtv.getLanguageCode(),
					1);
		}

		for (String languageKey : termedDocument.getAliases().keySet()) {
			int count = termedDocument.getAliases().get(languageKey).size();
			usageStatistics.countAliases += count;
			countKey(usageStatistics.aliasCounts, languageKey, count);
		}
	}
798565
public void statisticCreated(SPIStatistic s) {
        final String methodName = "statisticCreated()";
        // if (tc.isEntryEnabled()) {
        // Tr.entry(tc, methodName + " cacheName=" + _sCacheName + " statistic=" + s, this);
        // }
        switch (s.getId()) {
        case WSDynamicCacheStats.MaxInMemoryCacheEntryCount:
            _maxInMemoryCacheEntryCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.InMemoryCacheEntryCount:
            _inMemoryCacheEntryCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.HitsInMemoryCount:
            _hitsInMemoryCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.HitsOnDiskCount:
            _hitsOnDiskCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.ExplicitInvalidationCount:
            _explicitInvalidationCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.LruInvalidationCount:
            _lruInvalidationCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.TimeoutInvalidationCount:
            _timeoutInvalidationCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.InMemoryAndDiskCacheEntryCount:
            _inMemoryAndDiskCacheEntryCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.RemoteHitCount:
            _remoteHitCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.MissCount:
            _missCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.ClientRequestCount:
            _clientRequestCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.DistributedRequestCount:
            _distributedRequestCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.ExplicitMemoryInvalidationCount:
            _explicitMemoryInvalidationCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.ExplicitDiskInvalidationCount:
            _explicitDiskInvalidationCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.LocalExplicitInvalidationCount:
            _localExplicitInvalidationCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.RemoteExplicitInvalidationCount:
            _remoteExplicitInvalidationCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.RemoteCreationCount:
            _remoteCreationCount = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.ObjectsOnDisk:
            _objectsOnDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.HitsOnDisk:
            _hitsOnDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.ExplicitInvalidationsFromDisk:
            _explicitInvalidationsFromDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.TimeoutInvalidationsFromDisk:
            _timeoutInvalidationsFromDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.PendingRemovalFromDisk:
            _pendingRemovalFromDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.DependencyIdsOnDisk:
            _dependencyIdsOnDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.DependencyIdsBufferedForDisk:
            _dependencyIdsBufferedForDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.DependencyIdsOffloadedToDisk:
            _dependencyIdsOffloadedToDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.DependencyIdBasedInvalidationsFromDisk:
            _dependencyIdBasedInvalidationsFromDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.TemplatesOnDisk:
            _templatesOnDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.TemplatesBufferedForDisk:
            _templatesBufferedForDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.TemplatesOffloadedToDisk:
            _templatesOffloadedToDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.TemplateBasedInvalidationsFromDisk:
            _templateBasedInvalidationsFromDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.GarbageCollectorInvalidationsFromDisk:
            _garbageCollectorInvalidationsFromDisk = (SPICountStatistic) s;
            break;
        case WSDynamicCacheStats.OverflowInvalidationsFromDisk:
            _overflowInvalidationsFromDisk = (SPICountStatistic) s;
            break;
        default:
            Tr.debug(tc, methodName,
                    "Error - Unknown stats Id for " + WSDynamicCacheStats.NAME + " cacheName=" + _sCacheName + " dataID=" + s.getId());

            assert false;
            break;
        }
    }
772033
function( term ) {
    
    var document_count
    var appearances = 1
    
    for( key in this.documents ) {
      this.documents[ key ][ term ]
        ? appearances++ : 0
    }
    
    document_count = Object.keys( this.documents )
    document_count = document_count.length + 1
    
    return Math.log( document_count / appearances )
    
  }
756939
public void setPropertyNameSuggestions(java.util.Collection<PropertyNameSuggestion> propertyNameSuggestions) {
        if (propertyNameSuggestions == null) {
            this.propertyNameSuggestions = null;
            return;
        }

        this.propertyNameSuggestions = new java.util.ArrayList<PropertyNameSuggestion>(propertyNameSuggestions);
    }
178491
def log_term_frequency(document, term)
      count = document.term_count(term)
      if count > 0
        1 + log(count)
      else
        0
      end
    end
122989
private void writeTermStatisticsToFile(UsageStatistics usageStatistics,
			String fileName) {

		// Make sure all keys are present in label count map:
		for (String key : usageStatistics.aliasCounts.keySet()) {
			countKey(usageStatistics.labelCounts, key, 0);
		}
		for (String key : usageStatistics.descriptionCounts.keySet()) {
			countKey(usageStatistics.labelCounts, key, 0);
		}

		try (PrintStream out = new PrintStream(
				ExampleHelpers.openExampleFileOuputStream(fileName))) {

			out.println("Language,Labels,Descriptions,Aliases");
			for (Entry<String, Integer> entry : usageStatistics.labelCounts
					.entrySet()) {
				countKey(usageStatistics.aliasCounts, entry.getKey(), 0);
				int aCount = usageStatistics.aliasCounts.get(entry.getKey());
				countKey(usageStatistics.descriptionCounts, entry.getKey(), 0);
				int dCount = usageStatistics.descriptionCounts.get(entry
						.getKey());
				out.println(entry.getKey() + "," + entry.getValue() + ","
						+ dCount + "," + aCount);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
443477
void collectStats(final StatsCollector collector) {
    collector.record("compaction.count", compaction_count);
    collector.record("compaction.duplicates", duplicates_same, "type=identical");
    collector.record("compaction.duplicates", duplicates_different, "type=variant");
    if (!tsdb.config.enable_compactions()) {
      return;
    }
    // The remaining stats only make sense with compactions enabled.
    collector.record("compaction.queue.size", size);
    collector.record("compaction.errors", handle_read_error.errors, "rpc=read");
    collector.record("compaction.errors", handle_write_error.errors, "rpc=put");
    collector.record("compaction.errors", handle_delete_error.errors,
                     "rpc=delete");
    collector.record("compaction.writes", written_cells);
    collector.record("compaction.deletes", deleted_cells);
  }
40045
def term_counts(self):

        

        counts = OrderedDict()
        for term in self.terms:
            counts[term] = len(self.terms[term])

        return utils.sort_dict(counts)
96093
public void setCounters(java.util.Collection<SummarizedCounter> counters) {
        if (counters == null) {
            this.counters = null;
            return;
        }

        this.counters = new java.util.ArrayList<SummarizedCounter>(counters);
    }
1218398
private void countCoordinateStatement(Statement statement,
			ItemDocument itemDocument) {
		Value value = statement.getValue();
		if (!(value instanceof GlobeCoordinatesValue)) {
			return;
		}

		GlobeCoordinatesValue coordsValue = (GlobeCoordinatesValue) value;
		if (!this.globe.equals((coordsValue.getGlobe()))) {
			return;
		}

		int xCoord = (int) (((coordsValue.getLongitude() + 180.0) / 360.0) * this.width)
				% this.width;
		int yCoord = (int) (((coordsValue.getLatitude() + 90.0) / 180.0) * this.height)
				% this.height;

		if (xCoord < 0 || yCoord < 0 || xCoord >= this.width
				|| yCoord >= this.height) {
			System.out.println("Dropping out-of-range coordinate: "
					+ coordsValue);
			return;
		}

		countCoordinates(xCoord, yCoord, itemDocument);
		this.count += 1;

		if (this.count % 100000 == 0) {
			reportProgress();
			writeImages();
		}
	}
464706
private void countPropertyQualifier(PropertyIdValue property, int count) {
		PropertyRecord propertyRecord = getPropertyRecord(property);
		propertyRecord.qualifierCount = propertyRecord.qualifierCount + count;
	}
930065
public Long getCount(String type, Map<String, ?> terms) {
		if (terms == null) {
			return 0L;
		}
		MultivaluedMap<String, String> params = new MultivaluedHashMap<>();
		LinkedList<String> list = new LinkedList<>();
		for (Map.Entry<String, ? extends Object> term : terms.entrySet()) {
			String key = term.getKey();
			Object value = term.getValue();
			if (value != null) {
				list.add(key.concat(Config.SEPARATOR).concat(value.toString()));
			}
		}
		if (!terms.isEmpty()) {
			params.put("terms", list);
		}
		params.putSingle(Config._TYPE, type);
		params.putSingle("count", "true");
		Pager pager = new Pager();
		getItems(find("terms", params), pager);
		return pager.getCount();
	}
653389
private void writePropertyStatisticsToFile(UsageStatistics usageStatistics,
			String fileName) {
		try (PrintStream out = new PrintStream(
				ExampleHelpers.openExampleFileOuputStream(fileName))) {

			out.println("Property id,in statements,in qualifiers,in references,total");

			for (Entry<PropertyIdValue, Integer> entry : usageStatistics.propertyCountsMain
					.entrySet()) {
				int qCount = usageStatistics.propertyCountsQualifier.get(entry
						.getKey());
				int rCount = usageStatistics.propertyCountsReferences.get(entry
						.getKey());
				int total = entry.getValue() + qCount + rCount;
				out.println(entry.getKey().getId() + "," + entry.getValue()
						+ "," + qCount + "," + rCount + "," + total);
			}
		} catch (IOException e) {
			e.printStackTrace();
		}
	}
173710
protected void tally(WARCRecordType warcRecordType, long contentBytes, long totalBytes, long sizeOnDisk) {
        if (tmpStats == null) {
            tmpStats = new HashMap<String, Map<String,Long>>();
        }

        // add to stats for this record type
        Map<String, Long> substats = tmpStats.get(warcRecordType.toString());
        if (substats == null) {
            substats = new HashMap<String, Long>();
            tmpStats.put(warcRecordType.toString(), substats);
        }
        subtally(substats, contentBytes, totalBytes, sizeOnDisk);
        
        // add to totals
        substats = tmpStats.get(TOTALS);
        if (substats == null) {
            substats = new HashMap<String, Long>();
            tmpStats.put(TOTALS, substats);
        }
        subtally(substats, contentBytes, totalBytes, sizeOnDisk);
    }
701304
def remove_terms_used_in_less_than_num_docs(self, threshold):
        '''
        
        '''
        term_counts = self._X.astype(bool).astype(int).sum(axis=0).A[0]
        terms_to_remove = np.where(term_counts < threshold)[0]
        return self.remove_terms_by_indices(terms_to_remove)
1360416
private void handleDocument(EntityDocument document) {
		if (document instanceof ItemDocument) {
			this.entityDocumentProcessor
					.processItemDocument((ItemDocument) document);
		} else if (document instanceof PropertyDocument) {
			this.entityDocumentProcessor
					.processPropertyDocument((PropertyDocument) document);
		} else if(document instanceof LexemeDocument) {
			this.entityDocumentProcessor
					.processLexemeDocument((LexemeDocument) document);
		}
	}
999608
public void fitLabelledDocuments(JavaRDD<LabelledDocument> documentsRdd) {

        validateConfiguration();

        broadcastEnvironment(new JavaSparkContext(documentsRdd.context()));

        JavaRDD<Sequence<VocabWord>> sequenceRDD =
                        documentsRdd.map(new DocumentSequenceConvertFunction(configurationBroadcast));

        super.fitSequences(sequenceRDD);
    }