Get the term frequency
@param DocumentAbstract $document - the document to evaluate
@param string $token The token to look for
@param int $mode The type of term frequency to use
@return float
359566
public function getTfIdf(DocumentAbstract $document, $token, $mode = 1)
    {
        return $this->getTermFrequency($document, $token, $mode) * $this->getIdf($token);
    }
760458
public function getDocumentActualData($document)
    {
        $class      = $this->dm->getClassMetadata(get_class($document));
        $actualData = [];

        foreach ($class->propertyMetadata as $name => $mapping) {
            // skip not saved attributes
            if ($mapping->notSaved) {
                continue;
            }

            $value = $mapping->getValue($document);

            if ($mapping->isMany() && $value !== null && !($value instanceof PersistentCollectionInterface)) {
                // If $actualData[$name] is not a Collection then use an ArrayCollection.
                if (!$value instanceof Collection) {
                    $value = new ArrayCollection($value);
                }

                // Inject PersistentCollection
                $coll = $this->dm->getConfiguration()->getPersistentCollectionFactory()->create($this->dm, $mapping, $value);
                $coll->setOwner($document, $mapping);
                $coll->setDirty(!$value->isEmpty());
                $mapping->setValue($document, $coll);
                $actualData[$name] = $coll;
            } else {
                $actualData[$name] = $value;
            }
        }

        return $actualData;
    }
166049
protected function getHashId(Document $document, $sm) 
	{
		$main = $sm->get('neobazaar.service.main');
		$documentRepository = $main->getDocumentEntityRepository();
		return $documentRepository->getEncryptedId($document->getDocumentId());
	}
952183
def term_frequency(document, term)
      tf = document.term_count(term)
      (tf * 2.2) / (tf + 0.3 + 0.9 * documents.size / @model.average_document_size)
    end
428800
public function getDOM($doc = null, $majorVersion = 1, $minorVersion = null)
    {
        $element = parent::getDOM($doc, $majorVersion, $minorVersion);
        foreach ($this->_entry as $entry) {
            $element->appendChild($entry->getDOM($element->ownerDocument));
        }
        return $element;
    }
422676
public function get_doc_url(\core_search\document $doc) {
        // Get correct URL to section that contains label, from course format.
        $cminfo = $this->get_cm($this->get_module_name(), strval($doc->get('itemid')), $doc->get('courseid'));
        $format = course_get_format($cminfo->get_course());
        $url = $format->get_view_url($cminfo->sectionnum);

        // Add the ID of the label to the section URL.
        $url->set_anchor('module-' . $cminfo->id);
        return $url;
    }
1090814
public function _conjunctionScore($docId, Zend_Search_Lucene_Interface $reader)
    {
        if ($this->_coord === null) {
            $this->_coord = $reader->getSimilarity()->coord(
                count($this->_terms),
                count($this->_terms) 
            );
        }

        $score = 0.0;

        foreach ($this->_terms as $termId => $term) {
            /**
             * We don't need to check that term freq is not 0
             * Score calculation is performed only for matched docs
             */
            $score += $reader->getSimilarity()->tf($this->_termsFreqs[$termId][$docId]) *
                      $this->_weights[$termId]->getValue() *
                      $reader->norm($docId, $term->field);
        }

        return $score * $this->_coord * $this->getBoost();
    }
991076
public function getLocaleForDocument($document)
    {
        $oid = $this->getObjectIdentifier($document);
        $this->assertDocumentExists($document);

        return $this->documentLocaleMap[$oid];
    }
265225
public function getToken(string $token)
    {
        /* @var \ZfrOAuth2\Server\Model\AbstractToken $tokenFromDb */
        $tokenFromDb = $this->tokenRepository->findByToken($token);

        // Because the collation is most often case insensitive, we need to add a check here to ensure
        // that the token matches case
        if (! $tokenFromDb || ! hash_equals($tokenFromDb->getToken(), $token)) {
            return null;
        }

        return $tokenFromDb;
    }
256371
private function get(string $tag, string $memberof = '', bool $grouped = true){
    if ( empty($this->parsed) ){
      $this->parse();
    }
    if ( !empty($this->parsed) ){
      $res = [];
      foreach ( $this->parsed as $p ){
        if (
          !empty($p['tags']) &&
          (($i = \bbn\x::find($p['tags'], ['tag' => $tag])) !== false) &&
          (
            (
              empty($memberof) &&
              (\bbn\x::find($p['tags'], ['tag' => 'memberof']) === false)
            ) ||
            (
              !empty($memberof) &&
              (($k = \bbn\x::find($p['tags'], ['tag' => 'memberof'])) !== false) &&
              ($p['tags'][$k]['name'] === $memberof)
            )
          )
        ){
          if ( $grouped ){
            $tmp = $p['tags'][$i];
            if ( $p['tags'][$i]['tag'] !== 'file' ){
              $tmp['description'] = $p['description'];
            }
            unset($p['tags'][$i], $tmp['tag']);
            $res[] = array_merge($tmp, $this->group_tags($p['tags']));
          }
          else {
            $res = array_map(function($t){
              unset($t['tag']);
              return $t;
            }, $p['tags']);
          }
        }
      }
      return $res;
    }
    return false;
  }
797268
public function docFreq(Zend_Search_Lucene_Index_Term $term)
    {
        $docFreq = 0;

        foreach ($this->_indices as $index) {
            $docFreq += $index->docFreq($term);
        }

        return $docFreq;
    }
1202050
def document(self):
        
        doc = {'mode': self.__mongos_mode}
        if self.__tag_sets not in (None, [{}]):
            doc['tags'] = self.__tag_sets
        if self.__max_staleness != -1:
            doc['maxStalenessSeconds'] = self.__max_staleness
        return doc
1063556
public function getAvailableLocalization(StructureBehavior $document, $locale)
    {
        $availableLocales = $this->inspector->getLocales($document);

        if (in_array($locale, $availableLocales)) {
            return $locale;
        }

        $fallbackLocale = null;

        if ($document instanceof WebspaceBehavior) {
            $fallbackLocale = $this->localizationFinder->findAvailableLocale(
                $this->inspector->getWebspace($document),
                $availableLocales,
                $locale
            );
        }

        if (!$fallbackLocale) {
            $fallbackLocale = reset($availableLocales);
        }

        if (!$fallbackLocale) {
            $fallbackLocale = $this->documentRegistry->getDefaultLocale();
        }

        return $fallbackLocale;
    }
830975
private function UDB3Location($document)
    {
        $location = null;

        if ($document) {
            $item = $document->getBody();
            $location = isset($item->location) ? $item->location : null;
        }

        return $location;
    }
535995
protected function getLinksFromDocument( $document, $onlyWithLabel = FALSE )
	{
		$baseUrl	= $this->getBaseUrl( $document );
		$links		= array();
		$nodes		= $document->getElementsByTagName( "a" );
		foreach( $nodes as $node )
		{
			$ref	= $node->getAttribute( 'href' );
			$ref	= trim( preg_replace( "@^\./@", "", $ref ) );
			if( strlen( $ref ) ){
				$base	= $document->getElementsByTagName( "base" );
	//			remark( $ref );
				if( preg_match( "@^(#|mailto:|javascript:)@", $ref ) )
					continue;
				if( $base->length && preg_match( "@^\.\./@", $ref ) )
					continue;
				if( preg_match( "@^\.?/@", $ref ) )
					$ref	= $baseUrl.$ref;
				else if( preg_match( "@^\./@", $ref ) )
					$ref	= preg_replace( "@^\./@", "", $ref );
				if( !preg_match( "@^https?://@", $ref ) )
					$ref	= $baseUrl.$ref;
				$label	= trim( strip_tags( $node->nodeValue ) );
				if( $node->hasAttribute( 'title' ) )
					$label	= trim( strip_tags( $node->getAttribute( 'title' ) ) );
				if( $onlyWithLabel && !strlen( $label ) )
					continue;
				$links[$ref]	= $label;
			}
		}
		return $links;
	}
1368782
public WireFeedParser getParserFor(final Document document) {
        final List<WireFeedParser> parsers = getPlugins();
        for (final WireFeedParser parser : parsers) {
            if (parser.isMyType(document)) {
                return parser;
            }
        }
        return null;
    }
457203
private function propertyToEmbedOne($document, AbstractField $annotation)
    {
        $className = $annotation->target;

        try {
            $reflectClass = new \ReflectionClass($className);
        } catch (\Exception $exception) {
            return $document;
        }

        $embed = new $className;

        foreach ($reflectClass->getProperties() as $property) {
            if ($property->isStatic()) {
                continue;
            }
            /** @var AbstractField $annotation */
            $annotation = $this->annotationParser->getPropertyAnnotation($property);

            $propertyName = $annotation->name ?? $property->getName();
            $propertyValue = $document->{$propertyName} ?? null;
            $propertyValue = $this->propertyToField($propertyValue, $annotation);

            $property->setAccessible(true);
            $property->setValue($embed, $propertyValue);
        }

        return $embed;
    }