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

@param termedDocument
document to count the terms of
@param entityStatistics
record where statistics are counted
483068
protected void countTerms(TermedDocument termedDocument,
			EntityStatistics entityStatistics) {
		entityStatistics.countLabels += termedDocument.getLabels().size();
		// for (MonolingualTextValue mtv : termedDocument.getLabels().values())
		// {
		// countKey(usageStatistics.labelCounts, mtv.getLanguageCode(), 1);
		// }

		entityStatistics.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();
			entityStatistics.countAliases += count;
			// countKey(usageStatistics.aliasCounts, languageKey, count);
		}
	}
135034
protected function doCounts($source, $countSpec, &$dest)
    {
        // process count aggregate function
        foreach ($countSpec as $c)
        {
            $fieldName = $c['fieldName'];
            if(isset($c['temporary']) && $c['temporary'] === true)
            {
                if(!in_array($fieldName, $this->temporaryFields))
                {
                    $this->temporaryFields[] = $fieldName;
                }
            }
            $applyRegex = (isset($c['regex'])) ? isset($c['regex']) : null;
            $count = 0;
            // just count predicates at current location
            if (isset($source[$c['property']]))
            {
                if (isset($source[$c['property']][VALUE_URI]) || isset($source[$c['property']][VALUE_LITERAL]))
                {
                    if ($applyRegex != null)
                    {
                        $count = $this->applyRegexToValue($c['regex'],$source[$c['property']]);
                    } else {
                        $count = 1;
                    }
                }
                else
                {
                    if ($applyRegex != null)
                    {
                        foreach ($source[$c['property']] as $value)
                        {
                            if ($this->applyRegexToValue($c['regex'],$value)) {
                                $count++;
                            }
                        }
                    }
                    else
                    {
                        $count = count($source[$c['property']]);
                    }
                }
            }
            if (!isset($dest[$fieldName])) $dest[$fieldName] = 0;
            $dest[$fieldName] += $count;
        }
    }
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);
    }
1111554
public void count(final Stat name, final int count) {
        Integer value = counters.get(name);
        value = value == null ? count : value + count;
        counters.put(name, value);
    }
464706
private void countPropertyQualifier(PropertyIdValue property, int count) {
		PropertyRecord propertyRecord = getPropertyRecord(property);
		propertyRecord.qualifierCount = propertyRecord.qualifierCount + count;
	}
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();
		}
	}
351132
public void _include(IncludeBuilderBase includes) {
        if (includes == null) {
            return;
        }

        if (includes.documentsToInclude != null) {
            for (String doc : includes.documentsToInclude) {
                documentIncludes.add(doc);
            }
        }

        _includeCounters(includes.alias, includes.countersToIncludeBySourcePath);
    }
430164
def count_annotation_entries(self) -> int:
        """"""
        return self.session.query(NamespaceEntry).filter(NamespaceEntry.is_annotation).count()
1357811
private void writeEntitySets(XMLStreamWriter writer) throws XMLStreamException, ODataRenderException {
        List<EntitySet> entitySets = getEntityContainer().getEntitySets();
        LOG.debug("Number of entity sets to be written in service document are {}", entitySets.size());
        for (EntitySet entitySet : entitySets) {
            if (entitySet.isIncludedInServiceDocument()) {
                writeElement(writer, null, SERVICE_COLLECTION, null, entitySet.getName(), entitySet.getName());
            }
        }
    }
740628
protected void addEntityFieldsToDocument(EntityMetadata metadata, Object entity, Document document,
        MetamodelImpl metaModel) {
        String indexName = metadata.getIndexName();
        Map<String, PropertyIndex> indexProperties = metadata.getIndexProperties();
        for (String columnName : indexProperties.keySet()) {
            PropertyIndex index = indexProperties.get(columnName);
            java.lang.reflect.Field property = index.getProperty();
            String propertyName = index.getName();
            addFieldToDocument(entity, document, property, propertyName, indexName);
        }

        if (metaModel.isEmbeddable(metadata.getIdAttribute().getBindableJavaType())) {
            Object id = PropertyAccessorHelper.getId(entity, metadata);
            EmbeddableType embeddableId = metaModel.embeddable(metadata.getIdAttribute().getBindableJavaType());
            Set<Attribute> embeddedAttributes = embeddableId.getAttributes();
            indexCompositeKey(embeddedAttributes, metadata, id, document, metaModel);
        }
    }
772350
public void processDocument(BufferedReader document) throws IOException {
        int docIndex = documentCounter.getAndIncrement();

        Iterator<String> documentTokens = 
            IteratorFactory.tokenizeOrdered(document);

        // As we read in the document, generate a compressed version of it,
        // which we will use during the process space method to recompute all of
        // the word vectors' semantics
        ByteArrayOutputStream compressedDocument = 
            new ByteArrayOutputStream(4096);
        DataOutputStream dos = new DataOutputStream(compressedDocument);
        int tokens = 0; // count how many are in this document
        int unfilteredTokens = 0; // how many tokens remained after filtering

        IntegerVector docVector = createVector();
        docToVector.put(docIndex, docVector);

        while (documentTokens.hasNext()) {
            tokens++;
            String focusWord = documentTokens.next();

            // If we are filtering the semantic vectors, check whether this word
            // should have its semantics calculated.  In addition, if there is a
            // filter and it would have excluded the word, do not keep its
            // semantics around
            boolean calculateSemantics =
                semanticFilter.isEmpty() || semanticFilter.contains(focusWord)
                && !focusWord.equals(IteratorFactory.EMPTY_TOKEN);

	    // If the filter does not accept this word, skip the semantic
	    // processing, continue with the next word
            if (!calculateSemantics) {
                // Do not write out any removed tokens to save space
		continue;
	    }

            // Update the occurrences of this token
            unfilteredTokens++;
            add(docVector, getTermIndexVector(focusWord));

            // Update the compress version of the document with the token.
            //
            // NOTE: this call to termToIndex *must* come after the
            // getTermIndexVector() call, which is responsible for adding this
            // mapping if it doesn't already exist.
	    int focusIndex = termToIndex.get(focusWord);

            // write the term index into the compressed for the document for
            // later corpus reprocessing
            dos.writeInt(focusIndex);
        }

        document.close();
        
        dos.close();
        byte[] docAsBytes = compressedDocument.toByteArray();

        // Once the document is finished, write the compressed contents to the
        // corpus stream
        synchronized(compressedDocumentsWriter) {
            // Write how many terms were in this document after filtering
            compressedDocumentsWriter.writeInt(unfilteredTokens);
            compressedDocumentsWriter.write(docAsBytes, 0, docAsBytes.length);
        }
    }
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();
		}
	}
607209
public long count(BoundingBox boundingBox) {
		long count = 0;
		switch (getIndexedType()) {
		case GEOPACKAGE:
			count = featureTableIndex.count(boundingBox);
			break;
		case RTREE:
			count = rTreeIndexTableDao.count(boundingBox);
			break;
		default:
			count = manualFeatureQuery.count(boundingBox);
		}
		return count;
	}
27186
public void doSendDocument(Peer peer, String fileName, String mimeType, int fileSize,
                               FastThumb fastThumb, String descriptor) {
        long rid = RandomUtils.nextRid();
        long date = createPendingDate();
        long sortDate = date + 365 * 24 * 60 * 60 * 1000L;
        DocumentContent documentContent = DocumentContent.createLocal(fileName, fileSize,
                descriptor, mimeType, fastThumb);

        Message message = new Message(rid, sortDate, date, myUid(), MessageState.PENDING, documentContent);
        context().getMessagesModule().getRouter().onOutgoingMessage(peer, message);

        pendingMessages.getPendingMessages().add(new PendingMessage(peer, rid, documentContent));
        savePending();

        performUploadFile(rid, descriptor, fileName);
    }
616879
public static void printResults(Counter<String> entityTP, Counter<String> entityFP,
                           Counter<String> entityFN) {
    Set<String> entities = new TreeSet<String>();
    entities.addAll(entityTP.keySet());
    entities.addAll(entityFP.keySet());
    entities.addAll(entityFN.keySet());
    boolean printedHeader = false;
    for (String entity : entities) {
      double tp = entityTP.getCount(entity);
      double fp = entityFP.getCount(entity);
      double fn = entityFN.getCount(entity);
      printedHeader = printPRLine(entity, tp, fp, fn, printedHeader);
    }
    double tp = entityTP.totalCount();
    double fp = entityFP.totalCount();
    double fn = entityFN.totalCount();
    printedHeader = printPRLine("Totals", tp, fp, fn, printedHeader);
  }
410881
protected void addAssociatedEntitiesToDocument(EntityMetadata metadata, Object entity, Document document,
        MetamodelImpl metaModel) {
        try {
            IndexCollection indexes = metadata.getEntityClazz().getAnnotation(IndexCollection.class);
            if (indexes != null) {
                List<String> columnsNameToBeIndexed = new ArrayList<String>();
                for (com.impetus.kundera.index.Index indexedColumn : indexes.columns()) {
                    Attribute attrib = metaModel.getEntityAttribute(entity.getClass(), indexedColumn.name());
                    columnsNameToBeIndexed.add(((AbstractAttribute) attrib).getJPAColumnName());
                }

                String indexName = metadata.getIndexName();
                List<Relation> relations = metadata.getRelations();
                for (Relation relation : relations) {
                    if (relation.getType().equals(ForeignKey.MANY_TO_ONE)
                        || relation.getType().equals(ForeignKey.ONE_TO_ONE)) {
                        String propertyName = relation.getJoinColumnName(null);
                        if (propertyName != null && columnsNameToBeIndexed.contains(propertyName)) {
                            java.lang.reflect.Field property = relation.getProperty();
                            Object obj = PropertyAccessorHelper.getObject(entity, property);
                            if (obj != null) {
                                EntityMetadata relMetaData = metaModel.getEntityMetadata(obj.getClass());
                                Object id = PropertyAccessorHelper.getId(obj, relMetaData);
                                if (id != null) {
                                    Field luceneField =
                                        new Field(getCannonicalPropertyName(indexName, propertyName), id.toString(),
                                            Field.Store.YES, Field.Index.ANALYZED_NO_NORMS);

                                    document.add(luceneField);
                                } else {
                                    LOG.warn("value is null for field" + property.getName());
                                }
                            }
                        }
                    }
                }
            }
        } catch (PropertyAccessException e) {
            LOG.error("Error in accessing field, Caused by:" + e.getMessage());
            throw new LuceneIndexingException("Error in creating indexes on associated columns", e);
        }
    }
803566
public long count(String serviceName, String dataStructureName, String methodName) {
        return ((LatencyProbeImpl) newProbe(serviceName, dataStructureName, methodName)).stats.count;
    }