Lines Matching full:group

20  * A collection manages a group of related indexes that together provide a specific search use case.
140 * @param int $group Index group (0 for non-split, token length for split)
144 public function getTokenIndex(int $group = 0): AbstractIndex argument
149 return new MemoryIndex($this->idxToken, $this->groupToSuffix($group), $this->isWritable);
153 * @param int $group Index group (0 for non-split, token length for split)
157 public function getFrequencyIndex(int $group = 0): AbstractIndex argument
159 … return new MemoryIndex($this->idxFrequency, $this->groupToSuffix($group), $this->isWritable);
182 * Convert a logical group number to the index file suffix
184 * Group 0 represents non-split indexes (suffix '') while positive integers
187 * @param int $group
188 * @return string The file suffix ('' for group 0, the group number as string otherwise)
189 * @throws IndexUsageException when group does not match the collection's split mode
191 protected function groupToSuffix(int $group): string argument
193 if ($group === 0 && $this->splitByLength) {
194 throw new IndexUsageException('Group 0 is not valid for split-by-length collections');
196 if ($group !== 0 && !$this->splitByLength) {
197 throw new IndexUsageException("Group $group is not valid for non-split collections");
199 return $group === 0 ? '' : (string)$group;
205 * Given a set of token IDs from a specific index group, returns the entities
210 * @param int $group Index group (0 for non-split, token length for split)
214 public function resolveTokenFrequencies(int $group, array $tokenIds): array argument
216 $freqIndex = $this->getFrequencyIndex($group);
235 foreach ($groups as $group) {
236 $freqIndex = $this->getFrequencyIndex($group);
267 * - token == frequency (per group, both keyed by token RID)
278 foreach ($groups as $group) {
279 $tokenIndex = $this->getTokenIndex($group);
280 $freqIndex = $this->getFrequencyIndex($group);
286 "Group $group: missing " .
295 "Group $group: token count ($tc) != frequency count ($fc)"
353 * Resolve raw tokens into the two-level structure [group => [tokenId => frequency]]
360 * @return array [group => [tokenId => frequency, ...], ...]
367 // group tokens by their index suffix
370 $group = $this->splitByLength ? Tokenizer::tokenLength($token) : 0;
371 $groups[$group][$token] = $freq;
376 foreach ($groups as $group => $tokenFreqs) {
377 $tokenIndex = $this->getTokenIndex($group);
378 $result[$group] = [];
381 $result[$group][$tokenId] = $freq;
458 …* For split collections the format is "group*tokenId:group*tokenId:..." where group is the token l…
459 * For non-split collections the group prefix is omitted: "tokenId:tokenId:..."
463 * @return array [group => [tokenId => 0, ...], ...]
471 $group = (int)(array_pop($parts) ?? 0);
472 $result[$group][$tokenId] = 0;
480 * @param array $data [group => [tokenId => freq, ...], ...]
486 foreach ($data as $group => $tokens) {
487 $prefix = $group === 0 ? '' : "$group*";
498 * Iterates over the two-level structure [group => [tokenId => freq]] and updates the
499 * corresponding frequency index for each group. A frequency of 0 removes the entity
502 * @param array $data [group => [tokenId => frequency, ...], ...]
508 foreach ($data as $group => $tokens) {
509 $freqIndex = $this->getFrequencyIndex($group);