Convert number of substitution into search queries boost.

@param array $queryRewrites Array of query rewrites.
@param int   $divider       Score divider.
@param int   $baseWeight    Original score.

@return array
420766
private function getWeightedRewrites($queryRewrites, $divider, $baseWeight = 1)
    {
        $mapper = function ($substitutions) use ($baseWeight, $divider) {
            return $baseWeight / ($substitutions * $divider);
        };

        return array_map($mapper, $queryRewrites);
    }
397200
private double[] getVotesForInstance(Instance instance) {
		ErrorWeightedVote errorWeightedVote=newErrorWeightedVote(); 
		int numberOfRulesCovering = 0;
		
		for (ActiveRule rule: ruleSet) {
			if (rule.isCovering(instance) == true){
				numberOfRulesCovering++;
				double [] vote=rule.getPrediction(instance);
				double error= rule.getCurrentError();
				errorWeightedVote.addVote(vote,error);
				if (!this.unorderedRules) { // Ordered Rules Option.
					break; // Only one rule cover the instance.
				}
			}
		}

		if (numberOfRulesCovering == 0) {
			double [] vote=defaultRule.getPrediction(instance);
			double error= defaultRule.getCurrentError();
			errorWeightedVote.addVote(vote,error);	
		} 	
		double[] weightedVote=errorWeightedVote.computeWeightedVote();
		
		return weightedVote;
	}
73996
protected function baseQuery()
    {
        if (empty($this->baseQuery) && $this->parent->getData()) {
            $pk    = $this->parent->getPk();
            $table = $this->pivot->getTable();

            $this->query
                ->join($table . ' pivot', 'pivot.' . $this->foreignKey . '=' . $this->query->getTable() . '.' . $this->query->getPk())
                ->where('pivot.' . $this->localKey, $this->parent->$pk);
            $this->baseQuery = true;
        }
    }
819787
@Override
    public List<DistinctQueryResult> divide() {
        return Lists.newArrayList(Iterators.transform(getResultData(), new Function<QueryRow, DistinctQueryResult>() {
    
            @Override
            public DistinctQueryResult apply(final QueryRow input) {
                Set<QueryRow> resultData = new LinkedHashSet<>();
                resultData.add(input);
                return new AggregationDistinctQueryResult(getColumnLabelAndIndexMap(), resultData.iterator(), metaData);
            }
        }));
    }
750533
public function split(float $ratio = 0.5) : array
    {
        if ($ratio <= 0 or $ratio >= 1) {
            throw new InvalidArgumentException('Split ratio must be strictly'
            . " between 0 and 1, $ratio given.");
        }

        $n = (int) ($ratio * $this->numRows());

        $leftSamples = array_slice($this->samples, 0, $n);
        $leftLabels = array_slice($this->labels, 0, $n);

        $rightSamples = array_slice($this->samples, $n);
        $rightLabels = array_slice($this->labels, $n);

        return [
            self::quick($leftSamples, $leftLabels),
            self::quick($rightSamples, $rightLabels),
        ];
    }
925964
public function setDivider($divider = '/'): Breadcrumbs
    {
        if (!is_string($divider) && !is_null($divider)) {
            throw new InvalidArgumentException('Breadcrumbs::setDivider() only accepts strings or NULL');
        }
        $this->setOption('divider', $divider);

        return $this;
    }
11027
public static SearchExecutor newLdaptiveSearchExecutor(final String baseDn, final String filterQuery,
                                                           final List<String> params,
                                                           final List<String> returnAttributes) {
        return newLdaptiveSearchExecutor(baseDn, filterQuery, params, returnAttributes.toArray(ArrayUtils.EMPTY_STRING_ARRAY));
    }
171207
protected function enrichFrequentSearchesInfo(array $frequentSearchTerms, $minimumSize, $maximumSize)
    {
        $frequentSearches = [];
        if (count($frequentSearchTerms)) {
            $maximumHits = max(array_values($frequentSearchTerms));
            $minimumHits = min(array_values($frequentSearchTerms));
            $spread = $maximumHits - $minimumHits;
            $step = ($spread == 0) ? 1 : ($maximumSize - $minimumSize) / $spread;

            foreach ($frequentSearchTerms as $term => $hits) {
                $size = round($minimumSize + (($hits - $minimumHits) * $step));
                $frequentSearches[] = ['q' => htmlspecialchars_decode($term), 'hits' => $hits, 'style' => 'font-size: ' . $size . 'px', 'class' => 'tx-solr-frequent-term-' . $size, 'size' => $size];
            }
        }

        return $frequentSearches;
    }
628640
public function searchType(QueryBuilderInterface $query , $class_uri , $recursive = false) {

        $Class    = new \core_kernel_classes_Class($class_uri);
        $rdftypes = [];

        if ($recursive === true) {
            foreach($Class->getSubClasses(true) as $subClass) {
                $rdftypes[] = $subClass->getUri();
            }
        }

        $rdftypes[] = $class_uri;
        
        $criteria = $query->newQuery()
                ->add('http://www.w3.org/1999/02/22-rdf-syntax-ns#type')
                ->in($rdftypes);
        
        return $criteria;
    }
62234
public function useSiteHashFromAllowedSites($allowedSites): QueryBuilder
    {
        $isAnySiteAllowed = trim($allowedSites) === '*';
        if ($isAnySiteAllowed) {
            // no filter required
            return $this;
        }

        $allowedSites = GeneralUtility::trimExplode(',', $allowedSites);
        $filters = [];
        foreach ($allowedSites as $site) {
            $siteHash = $this->siteHashService->getSiteHashForDomain($site);
            $filters[] = 'siteHash:"' . $siteHash . '"';
        }

        $siteHashFilterString = implode(' OR ', $filters);
        return $this->useFilter($siteHashFilterString, 'siteHash');
    }
56779
@Override
    public double[] getVotesForInstance(Instance inst) {

        if (m_weights == null) {
            return new double[inst.numAttributes() + 1];
        }

        double[] result = new double[2];

        double wx = dotProd(inst, m_weights, inst.classIndex());// * m_wScale;
        double z = (wx + m_weights[m_weights.length - 1]);
        //System.out.print("" + z + ": ");
        // System.out.println(1.0 / (1.0 + Math.exp(-z)));
        if (z <= 0) {
            //  z = 0;
            if (m_loss == LOGLOSS) {
                result[0] = 1.0 / (1.0 + Math.exp(z));
                result[1] = 1.0 - result[0];
            } else {
                result[0] = 1;
            }
        } else {
            if (m_loss == LOGLOSS) {
                result[1] = 1.0 / (1.0 + Math.exp(-z));
                result[0] = 1.0 - result[1];
            } else {
                result[1] = 1;
            }
        }
        return result;
    }
560640
private function applyMultiSort(array $data, array $sortArguments)
    {
        $args = [];
        foreach ($sortArguments as $values) {
            $remain = count($values) % 3;
            if ($remain != 0) {
                throw new \InvalidArgumentException(
                    'The parameter count for each sortArgument has to be three. Given count of: ' . count($values)
                );
            }
            $args[] = $values[0]; // column value
            $args[] = $values[1]; // sort direction
            $args[] = $values[2]; // sort type
        }

        $args[] = $data;

        //possible 5.3.3 fix?
        $sortArgs = [];
        foreach ($args as $key => &$value) {
            $sortArgs[$key] = &$value;
        }

        call_user_func_array('array_multisort', $sortArgs);

        return end($args);
    }
999601
public static function fromBaseIter( $baseIter, $allowSameElementRepeat = false )
	{
		$result = new DocumentOrderNodeIterator();
		$result->allowSameElementRepeat = $allowSameElementRepeat;
		$result->fromDocumentOrderNodeIteratorParts( $baseIter );
		return $result;
	}
1228997
public function addVote($intItemId, $fltValue, $blnLock = false)
    {
        if ($this->getSessionBag()->get($this->getLockId($intItemId))) {
            return;
        }

        $arrData = $this->getDataFor([$intItemId]);

        if (!$arrData || !$arrData[$intItemId]['votecount']) {
            $voteCount   = 0;
            $prevPercent = 0;
        } else {
            $voteCount   = $arrData[$intItemId]['votecount'];
            $prevPercent = (float) $arrData[$intItemId]['meanvalue'];
        }

        $grandTotal = ($voteCount * $this->get('rating_max') * $prevPercent);
        $hundred    = ($this->get('rating_max') * (++$voteCount));

        // Calculate the percentage.
        $value = (1 / $hundred * ($grandTotal + $fltValue));

        $arrSet = [
            'mid' => $this->getMetaModel()->get('id'),
            'aid' => $this->get('id'),
            'iid' => $intItemId,
            'votecount' => $voteCount,
            'meanvalue' => $value,
        ];

        $queryBuilder = $this->connection->createQueryBuilder();

        if (!$arrData || !$arrData[$intItemId]['votecount']) {
            $queryBuilder
                ->insert('tl_metamodel_rating')
                ->values($arrSet);
        } else {
            foreach ($arrSet as $key => $value) {
                $queryBuilder
                    ->set($key, ':' . $key)
                    ->setParameter($key, $value);
            }

            $queryBuilder
                ->update('tl_metamodel_rating')
                ->andWhere('mid=:mid AND aid=:aid AND iid=:iid')
                ->setParameter('mid', $this->getMetaModel()->get('id'))
                ->setParameter('aid', $this->get('id'))
                ->setParameter('iid', $intItemId);
        }

        $queryBuilder->execute();

        if ($blnLock) {
            $this->getSessionBag()->set($this->getLockId($intItemId), true);
        }
    }
203828
public function countActiveUsers(array $finderParams = [], $defaultPeriod = false)
    {
        if ($defaultPeriod) {
            $finderParams = $this->formatQueryParams($finderParams);
        }
        $queryParams = FinderProvider::parseQueryParams($finderParams);
        $resultData = $this->logRepository->countActiveUsers($queryParams['allFilters']);

        return floatval($resultData);
    }
800616
private static function mergeQueryString(?string $queryString, array $queryArray, bool $replace): ?string
    {
        if (!$queryArray) {
            return $queryString;
        }

        $query = [];

        if (null !== $queryString) {
            foreach (explode('&', $queryString) as $v) {
                if ('' !== $v) {
                    $k = urldecode(explode('=', $v, 2)[0]);
                    $query[$k] = (isset($query[$k]) ? $query[$k].'&' : '').$v;
                }
            }
        }

        foreach ($queryArray as $k => $v) {
            if (is_scalar($v)) {
                $queryArray[$k] = rawurlencode($k).'='.rawurlencode($v);
            } elseif (null === $v) {
                unset($queryArray[$k]);

                if ($replace) {
                    unset($query[$k]);
                }
            } else {
                throw new InvalidArgumentException(sprintf('Unsupported value for query parameter "%s": scalar or null expected, %s given.', $k, \gettype($v)));
            }
        }

        return implode('&', $replace ? array_replace($query, $queryArray) : ($query + $queryArray));
    }
671909
public function queryAndCount($resultName, $countName, QueryObjectInterface $queryObject, DisplayCriteriaInterface $displayCriteria = null)
    {
        list($result, $count) = $this->doQueryAndCount($queryObject, $displayCriteria);

        $this->data[$resultName] = $result;
        $this->data[$countName] = $count;

        return [$result, $count];
    }