@param string $keyword

@return KeywordInterface
166487
public function getDocument($keyword)
    {
        $keyword = $this->suppressSpecialCharacterHelper->transform($keyword);
        $keywordClass = $this->keywordClass;
        $keywordEntity = $this->keywordRepository->findOneByLabel($keyword);

        if (is_null($keywordEntity)
            && !$this->authorizationChecker->isGranted(ContributionActionInterface::CREATE, KeywordInterface::ENTITY_TYPE)
        ) {
            throw new AccessDeniedHttpException();
        }
        if (is_null($keywordEntity)) {
            $keywordEntity = new $keywordClass();
            $keywordEntity->setLabel($keyword);
            $this->keywordRepository->getManager()->persist($keywordEntity);
            $this->keywordRepository->getManager()->flush($keywordEntity);
        }

        return $keywordEntity;
    }
1008043
protected function resolveSearchKeywords(string $keyword): array
    {
        $basic = [];
        $advanced = [];

        $tags = \array_map(function ($value) {
            [$tag, ] = \explode(':', $value, 2);

            return "{$tag}:";
        }, \array_keys($this->getSearchableRules()));

        if (\preg_match_all('/([\w]+:\"[\w\s]*\"|[\w]+:[\w\S]+|[\w\S]+)\s?/', $keyword, $keywords)) {
            foreach ($keywords[1] as $index => $keyword) {
                if (! Str::startsWith($keyword, $tags)) {
                    \array_push($basic, $keyword);
                } else {
                    \array_push($advanced, $keyword);
                }
            }
        }

        return [
            'basic' => \implode(' ', $basic),
            'advanced' => $advanced,
        ];
    }
1002690
public function transform($keyword, array $params = array())
    {
        if (!$keyword instanceof KeywordInterface) {
            throw new TransformerParameterTypeException();
        }

        $facade = $this->newFacade();

        $facade->id = $keyword->getId();
        $facade->label = $keyword->getLabel();
        $facade->label = $keyword->getLabel();
        $facade->numberUse = $keyword->countUse();

        $facade->addRight('can_edit', $this->authorizationChecker->isGranted(ContributionActionInterface::EDIT, $keyword));
        $facade->addRight('can_delete', $this->authorizationChecker->isGranted(ContributionActionInterface::DELETE, $keyword) &&
            $this->businessRulesManager->isGranted(BusinessActionInterface::DELETE, $keyword));

        return $facade;
    }
1180646
public function exists($keyword)
    {
        $object = null;
        $result = $this->_em->getConnection()->executeQuery(sprintf(
            'SELECT uid FROM keyword WHERE hex(lower(keyword)) = hex(lower("%s"))',
            preg_replace('#[/\"]#', '', trim($keyword))
        ))->fetchAll();

        if (0 < count($result)) {
            $uid = array_shift($result);
            $object = $this->find($uid['uid']);
        }

        return $object;
    }
354386
protected function globalSearch($keyword)
    {
        $keyword = $this->config->isCaseInsensitive() ? Str::lower($keyword) : $keyword;

        $this->collection = $this->collection->filter(function ($row) use ($keyword) {
            $this->isFilterApplied = true;

            $data = $this->serialize($row);
            foreach ($this->request->searchableColumnIndex() as $index) {
                $column = $this->getColumnName($index);
                $value = Arr::get($data, $column);
                if (! $value || is_array($value)) {
                    if (! is_numeric($value)) {
                        continue;
                    }

                    $value = (string) $value;
                }

                $value = $this->config->isCaseInsensitive() ? Str::lower($value) : $value;
                if (Str::contains($value, $keyword)) {
                    return true;
                }
            }

            return false;
        });
    }
820909
public function withKeywords(array $keywords)
    {
        Assertion::allString($keywords);
        Assertion::allNotBlank($keywords);

        $instance = clone $this;

        $instance->keywords = $keywords;

        return $instance;
    }
626839
public function setMetaKeywords($keywords)
    {
        if (is_array($keywords)) {
            $keywords = implode(', ', $keywords);
        }

        return $this->addMeta(['name' => 'keywords', 'content' => e($keywords)]);
    }
630626
protected function globalSearch($keyword)
    {
        $this->query->where(function ($query) use ($keyword) {
            collect($this->request->searchableColumnIndex())
                ->map(function ($index) {
                    return $this->getColumnName($index);
                })
                ->reject(function ($column) {
                    return $this->isBlacklisted($column) && ! $this->hasFilterColumn($column);
                })
                ->each(function ($column) use ($keyword, $query) {
                    if ($this->hasFilterColumn($column)) {
                        $this->applyFilterColumn($query, $column, $keyword, 'or');
                    } else {
                        $this->compileQuerySearch($query, $column, $keyword);
                    }

                    $this->isFilterApplied = true;
                });
        });
    }
982031
public function getKeyword($keyword, $lang = null)
    {
        $parts = $this->_callInternalLocale('getKeywords', null, $lang, false);
        return isset($parts[$keyword]) ? $parts[$keyword] : null;
    }
431082
public function getKeyword($text)
    {
        $found = null;
        $text = trim($text);
        $iText = strtoupper(TextNormalizer::stripDiacritics($text));
        foreach ($this->keywords as $keyword) {
            /** @var Keyword $keyword */
            $tmpText = trim($keyword->getText());
            if ($tmpText === $text
                || (
                    empty($keyword->isCaseSensitive()) &&
                    strtoupper(TextNormalizer::stripDiacritics($tmpText)) === $iText)
            ) {
                $found = $keyword;
                break;
            }
        }

        return $found;
    }
711405
public function parseKeywordToText($keywords, $alias = null)
    {
        foreach($keywords as $k => $v)
        {
            if(Text::isEmpty($v))
            {
                unset($keywords[$k]);
            }
        }
        $isLastStar = '*' === end($keywords);
        $result = BaseBuilder::DELIMITED_IDENTIFIERS . implode(BaseBuilder::DELIMITED_IDENTIFIERS . '.' . BaseBuilder::DELIMITED_IDENTIFIERS, $keywords) . BaseBuilder::DELIMITED_IDENTIFIERS;
        if($isLastStar)
        {
            $result = str_replace(BaseBuilder::DELIMITED_IDENTIFIERS . '*' . BaseBuilder::DELIMITED_IDENTIFIERS, '*', $result);
        }
        if(!Text::isEmpty($alias))
        {
            $result .= ' as ' . BaseBuilder::DELIMITED_IDENTIFIERS . $alias . BaseBuilder::DELIMITED_IDENTIFIERS;
        }
        return $result;
    }
929989
public static function wordFormat($keyword): string
    {
        // 将全角角逗号换为空格
        $keyword = str_replace(['，', ','], ' ', $keyword);

        return preg_replace([
            // 去掉两个空格以上的
            '/\s(?=\s)/',
            // 将非空格替换为一个空格
            '/[\n\r\t]/'
        ], ['', ' '], trim($keyword));
    }
1084721
public function deserialize($data, Keyword $keyword)
    {
        $this->sipe('name', 'setName', $data, $keyword);

        if (isset($data['clacoForm']['id'])) {
            $clacoForm = $this->clacoFormRepo->findOneBy(['uuid' => $data['clacoForm']['id']]);

            if (!empty($clacoForm)) {
                $keyword->setClacoForm($clacoForm);
            }
        }

        return $keyword;
    }
132336
public function setKeywords(array $keywords)
    {
        foreach ($keywords as $query) {
            $keyword    = $query[0];
            $properties = (isset($query[1]) ? (array)$query[1] : null);
            $this->addKeyword($keyword, $properties);
        }

        return $this;
    }
323941
public function search($keyword = "")
    {
        Yii::trace("Begin searching...", __METHOD__);
        $matches = $this->match($keyword);
        $results = [];
        foreach ($matches as $extension) {
            $results[$extension->extension->id()] = $extension->extension->search($keyword);
        }
        return $results;
    }
894424
public function add_keyword($key, $word) {
        if (!is_array($this->language_data['KEYWORDS'][$key])) {
            $this->language_data['KEYWORDS'][$key] = array();
        }
        if (!in_array($word, $this->language_data['KEYWORDS'][$key])) {
            $this->language_data['KEYWORDS'][$key][] = $word;

            //NEW in 1.0.8 don't recompile the whole optimized regexp, simply append it
            if ($this->parse_cache_built) {
                $subkey = count($this->language_data['CACHED_KEYWORD_LISTS'][$key]) - 1;
                $this->language_data['CACHED_KEYWORD_LISTS'][$key][$subkey] .= '|' . preg_quote($word, '/');
            }
        }
    }
231820
public function removeKeyword(Keyword $keyword)
    {
        if ($this->keywords->contains($keyword)) {
            $this->keywords->removeElement($keyword);
        }
    }