Defaults keywords dumper.

@param array   $keywords Keywords list
@param Boolean $isShort  Is short version

@return string
760910
public function dumpKeywords(array $keywords, $isShort)
    {
        if ($isShort) {
            return 1 < count($keywords) ? '(' . implode('|', $keywords) . ')' : $keywords[0];
        }

        return $keywords[0];
    }
202279
public static function getKeywords()
    {
        static $keywords = null;

        if ($keywords === null) {
            $keywords = [];

            $keywordsStrings = [
                'T_ABSTRACT', 'T_ARRAY', 'T_AS', 'T_BREAK', 'T_CALLABLE', 'T_CASE',
                'T_CATCH', 'T_CLASS', 'T_CLONE', 'T_CONST', 'T_CONTINUE', 'T_DECLARE', 'T_DEFAULT', 'T_DO',
                'T_ECHO', 'T_ELSE', 'T_ELSEIF', 'T_EMPTY', 'T_ENDDECLARE', 'T_ENDFOR', 'T_ENDFOREACH',
                'T_ENDIF', 'T_ENDSWITCH', 'T_ENDWHILE', 'T_EVAL', 'T_EXIT', 'T_EXTENDS', 'T_FINAL',
                'T_FINALLY', 'T_FOR', 'T_FOREACH', 'T_FUNCTION', 'T_GLOBAL', 'T_GOTO', 'T_HALT_COMPILER',
                'T_IF', 'T_IMPLEMENTS', 'T_INCLUDE', 'T_INCLUDE_ONCE', 'T_INSTANCEOF', 'T_INSTEADOF',
                'T_INTERFACE', 'T_ISSET', 'T_LIST', 'T_LOGICAL_AND', 'T_LOGICAL_OR', 'T_LOGICAL_XOR',
                'T_NAMESPACE', 'T_NEW', 'T_PRINT', 'T_PRIVATE', 'T_PROTECTED', 'T_PUBLIC', 'T_REQUIRE',
                'T_REQUIRE_ONCE', 'T_RETURN', 'T_STATIC', 'T_SWITCH', 'T_THROW', 'T_TRAIT', 'T_TRY',
                'T_UNSET', 'T_USE', 'T_VAR', 'T_WHILE', 'T_YIELD',
            ];

            foreach ($keywordsStrings as $keywordName) {
                if (defined($keywordName)) {
                    $keyword = constant($keywordName);
                    $keywords[$keyword] = $keyword;
                }
            }
        }

        return $keywords;
    }
358952
public function addKeyword($keyword)
    {
        if (is_array($keyword)):
            $this->keywords = array_merge($keyword, $this->keywords);
        else:
            $this->keywords[] = strip_tags($keyword);
        endif;

        return $this;
    }
426856
public function searchKeywords($keywords, $queryBuilder)
    {
        if ($this->attributeKey) {
            $result = $queryBuilder->expr()->like('ak_' . $this->attributeKey->getAttributeKeyHandle(), ':keywords');
        } else {
            $result = null;
        }

        return $result;
    }
68939
public function cleanKeywordLinks(AbstractClassContent $content, $keywords)
    {
        if (!is_array($keywords)) {
            $keywords = [$keywords];
        }

        $keywordUids = [];
        foreach ($keywords as $keyword) {
            if (
                $keyword instanceof Keyword
                && !empty($keyword->value)
                && (null !== $realKeyword = $this->_em->find('BackBee\NestedNode\KeyWord', $keyword->value))
            ) {
                $keywordUids[] = $realKeyword->getUid();
            }
        }

        $query = $this->_em
            ->getConnection()
            ->createQueryBuilder()
            ->select('c.keyword_uid')
            ->from('keywords_contents', 'c')
        ;
        $query->where($query->expr()->eq('c.content_uid', $query->expr()->literal($content->getUid())));
        $savedKeywords = $query->execute()->fetchAll(\PDO::FETCH_COLUMN);

        $linksToBeRemoved = array_diff($savedKeywords, $keywordUids);
        if (count($linksToBeRemoved)) {
            $query = $this->_em
                ->getConnection()
                ->createQueryBuilder()
                ->delete('keywords_contents')
            ;

            array_walk(
                $linksToBeRemoved,
                function(&$value, $key, $query) {
                    $value = $query->expr()->literal($value);
                },
                $query
            );

            $query
                ->where($query->expr()->eq('content_uid', $query->expr()->literal($content->getUid())))
                ->andWhere($query->expr()->in('keyword_uid', $linksToBeRemoved))
                ->execute()
            ;
        }
    }
699574
public function dump($language, $short = true, $excludeAsterisk = false)
    {
        $this->keywords->setLanguage($language);
        $languageComment = '';
        if ('en' !== $language) {
            $languageComment = "# language: $language\n";
        }

        $keywords = explode('|', $this->keywords->getFeatureKeywords());

        if ($short) {
            $keywords = call_user_func($this->keywordsDumper, $keywords, $short);

            return trim($languageComment . $this->dumpFeature($keywords, $short, $excludeAsterisk));
        }

        $features = array();
        foreach ($keywords as $keyword) {
            $keyword = call_user_func($this->keywordsDumper, array($keyword), $short);
            $features[] = trim($languageComment . $this->dumpFeature($keyword, $short, $excludeAsterisk));
        }

        return $features;
    }
1328955
public static function isKeyword($str, $isReserved = false)
    {
        $str = strtoupper($str);

        if (isset(static::$KEYWORDS[$str])) {
            if ($isReserved && ! (static::$KEYWORDS[$str] & Token::FLAG_KEYWORD_RESERVED)) {
                return null;
            }

            return static::$KEYWORDS[$str];
        }

        return null;
    }
405252
protected function saveKeywordsToFile($keywords, $cacheFilePath, $lastUpdate = null)
    {
        if ($lastUpdate === null) {
            $lastUpdate = time();
        }

        // add timestamp to first line
        array_unshift($keywords, $lastUpdate);

        // save without logging - this could end up in spamming the logs
        @file_put_contents($cacheFilePath, implode("\n", $keywords));
    }
995943
function defineKeywords(ajv, keyword) {
  if (Array.isArray(keyword)) {
    for (var i=0; i<keyword.length; i++)
      get(keyword[i])(ajv);
    return ajv;
  }
  if (keyword) {
    get(keyword)(ajv);
    return ajv;
  }
  for (keyword in KEYWORDS) get(keyword)(ajv);
  return ajv;
}
1319025
public function doShortcode(string $content, $tags = [], bool $deep = false): string
    {
        $tags = $this->preProcessTags($tags);
        $handler = function (string $tag, ?string $content = null, array $atts = []) {
            $shortcode = $this[$tag];

            if ($shortcode instanceof AttributeInterface) {
                $atts = array_merge($shortcode->getAttributes(), $atts);

                return $shortcode->handle($content, $atts);
            }

            return $shortcode->handle($content);
        };

        $result = (string) $this->parser->parseShortcode($content, $tags, $handler);

        if ($deep && $this->hasShortcode($result, $tags)) {
            return $this->doShortcode($result, $tags, $deep);
        }

        return $result;
    }
212706
public function fuzzySearch($keyword)
    {
        $prefix         = substr($keyword, 0, $this->fuzzy_prefix_length);
        $searchWordlist = "SELECT * FROM wordlist WHERE term like :keyword ORDER BY num_hits DESC LIMIT {$this->fuzzy_max_expansions}";
        $stmtWord       = $this->index->prepare($searchWordlist);
        $stmtWord->bindValue(':keyword', mb_strtolower($prefix)."%");
        $stmtWord->execute();
        $matches = $stmtWord->fetchAll(PDO::FETCH_ASSOC);

        $resultSet = [];
        foreach ($matches as $match) {
            $distance = levenshtein($match['term'], $keyword);
            if ($distance <= $this->fuzzy_distance) {
                $match['distance'] = $distance;
                $resultSet[]       = $match;
            }
        }

        // Sort the data by distance, and than by num_hits
        $distance = [];
        $hits     = [];
        foreach ($resultSet as $key => $row) {
            $distance[$key] = $row['distance'];
            $hits[$key]     = $row['num_hits'];
        }
        array_multisort($distance, SORT_ASC, $hits, SORT_DESC, $resultSet);

        return $resultSet;
    }
1213042
protected function prepareKeyword($keyword)
    {
        if ($this->config->isCaseInsensitive()) {
            $keyword = Str::lower($keyword);
        }

        if ($this->config->isWildcard()) {
            $keyword = Helper::wildcardLikeString($keyword);
        }

        if ($this->config->isSmartSearch()) {
            $keyword = "%$keyword%";
        }

        return $keyword;
    }
236625
public function getSearchFrequentSearchesUseLowercaseKeywords($defaultIfEmpty = false)
    {
        $result = $this->getValueByPathOrDefaultValue('plugin.tx_solr.search.frequentSearches.useLowercaseKeywords', $defaultIfEmpty);
        return $this->getBool($result);
    }
591201
public function validateCollection(array $keywords, array $options = [])
    {
        $errors = [];

        $maxScore = -1;
        $keywordsData = []; // We will store text and caseSensitive to check there is no duplicate

        foreach ($keywords as $index => $keyword) {
            // Validate keyword
            $errors = array_merge($errors, $this->validateAfterSchema($keyword, $options));

            if (empty($errors)) {
                if ($keyword['score'] > $maxScore) {
                    $maxScore = $keyword['score'];
                }

                // Checks for duplicates
                if (isset($keywordsData[$keyword['text']]) && in_array($keyword['caseSensitive'], $keywordsData[$keyword['text']], true)) {
                    // Keywords already exists
                    $caseSensitive = $keyword['caseSensitive'] ? 'true' : 'false'; // Converts to string to display in logs
                    $errors[] = [
                        'path' => "/{$index}",
                        'message' => "there is already a keyword with text: '{$keyword['text']}' and caseSensitive: '{$caseSensitive}'",
                    ];
                } else {
                    $keywordsData[$keyword['text']] = [];
                    $keywordsData[$keyword['text']][] = $keyword['caseSensitive'];
                }
            }
        }

        // check there is a keyword with a positive score
        if (in_array(Validation::VALIDATE_SCORE, $options) && $maxScore <= 0) {
            $errors[] = [
                'path' => '',
                'message' => 'there is no keyword with a positive score',
            ];
        }

        return $errors;
    }
987880
def query_keywords_empty(kind='1'):
        '''
        
        '''
        return TabPost.select().where((TabPost.kind == kind) & (TabPost.keywords == ''))
1784
public function keywords($default = null)
  {
    if (!$k = $this->getKeywords()) {
      $d = $default ?: $this->getDefaultKeywords();
      $k = is_null($d) ? $this->getTitle() : $d;
    }

    return new Tag('meta', null, array('name' => 'keywords', 'content' => $k), true);
  }
686468
protected function dumpBackground($keyword, $short = true, $excludeAsterisk = false)
    {
        $dump = <<<GHERKIN
  {$keyword}:

GHERKIN;

        // Given
        $dump .= $this->dumpStep(
            $this->keywords->getGivenKeywords(),
            'there is agent A',
            $short,
            $excludeAsterisk
        );

        // And
        $dump .= $this->dumpStep(
            $this->keywords->getAndKeywords(),
            'there is agent B',
            $short,
            $excludeAsterisk
        );

        return $dump . "\n";
    }