Add headword.
@param string|Headword $headword
`string`: Headword string.
`Headword`: Headword model.
@return false|Headword
168017
public function setHeadword($headword, $addSynonyms = false)
    {
        if (is_string($headword)) {
            return Headword::add($headword, $this, $addSynonyms);
        }
        if ($headword instanceof Headword) {
            return Headword::add($headword->word, $this, $addSynonyms);
        }
    }
739125
public function add_word($word)
    {
        $this->load_dict();

        foreach (explode(' ', $word) as $word) {
            // sanity check
            if (strlen($word) < 512) {
                $this->dict[] = $word;
                $valid = true;
            }
        }

        if ($valid) {
            $this->dict = array_unique($this->dict);
            $this->update_dict();
        }
    }
703077
public void addKeyword(String keyword) {
        if (taxonomy.concepts.containsKey(keyword)) {
            throw new IllegalArgumentException(String.format("Concept %s already exists.", keyword));
        }

        taxonomy.concepts.put(keyword, this);

        if (synset == null) {
            synset = new TreeSet<>();
        }

        synset.add(keyword);
    }
252293
public function add(string $word): self {
        // 构建临时树
        $tmp_tree = &$this->tmp_tree;
        foreach ($this->split($word) as $char) {
            // 加入索引
            $code = $this->index($char);

            // 插树
            $tmp_tree = &$this->putNode($code, $tmp_tree);

            // 抛弃无用词条
            if ($tmp_tree == $this->tmp_tree) {
                break;
            }
        }

        // 修剪trie树，抛弃无用词条
        $tmp_tree && $tmp_tree != $this->tmp_tree && $tmp_tree = [];

        return $this;
    }
91329
function add($header)
    {
        // convert to object form
        if (is_string($header))
            $header = HeaderField::fromString($header);

        $this->_headers[] = $header;
        return $this;
    }
483008
public function add($key, $value) {
        $key = $this->formatKey($key);
        $headers = $this->get($key);

        $headers[] = $value;

        array_set($this->headers, $key, $headers);
    }
1336004
public function setKeywords($keywords)
    {
        if (!empty($keywords)) {
            Yii::$app->view->registerMetaTag(['name' => 'keywords', 'content' => $keywords], 'keywords');
        }
        return $this;
    }
91193
public function removeHeadword($word)
    {
        if (is_string($word)) {
            $headword = $this->getHeadwords()->word($word)->one();
            return $headword && $headword->delete() == 1;
        }
        if ($word instanceof Headword && $word->extension == $this) {
            return $word->delete() == 1;
        }
    }
349259
def add(self, word):
        """"""
        if not word or word.strip() == '':
            return
        self.words[word]=word
393448
public function addStopWords($list) {
		$this->data = array_unique(array_merge($this->data, (array)$list));
		return $this;
    }
332890
public function addHeader($header)
    {
        if (is_string($header)) {
            $header = HeaderField::fromString($header);
        }
        $this->headers[] = $header;
        return $this;
    }
923105
public void addWords(Collection<String> words){
		if(false == (words instanceof Set)){
			words = new HashSet<>(words);
		}
		for (String word : words) {
			addWord(word);
		}
	}
202847
public function addDetectedLanguage($language)
    {
        if (!in_array($language, $this->detectedLanguages)) {
            $this->detectedLanguages[] = $language;
        }

        return $this;
    }
97077
private void addWord(final String word) {

		final int length = word.length();
		if (length >= wordMinLength && length <= wordMaxLength) {

			words.add(word);

			wordCount++;
		}
	}
203362
public function setKeyword($keyword, $locale = null)
    {
        $this->translate($locale, false)->setKeyword($keyword);
        $this->mergeNewTranslations();

        return $this;
    }
231820
public function removeKeyword(Keyword $keyword)
    {
        if ($this->keywords->contains($keyword)) {
            $this->keywords->removeElement($keyword);
        }
    }
1079548
public function indexing($keyword)
    {
        if ($this->indexing == null) {
            $tableCreated = false;
            if (!\file_exists($this->SqliteDir . '/indexing')) {
                $tableCreated = true;
            }

            $PDO = new PDO("sqlite:" . $this->SqliteDir . '/' . self::INDEXING_FILE);
            $PDO->setAttribute(PDO::ATTR_ERRMODE,
                PDO::ERRMODE_EXCEPTION);

            if ($tableCreated) {
                $this->initIndexing($PDO);
            }
            $this->indexing = $PDO;
            unset($PDO);

            $stm = $this->indexing->prepare("SELECT MAX(`db`) as `db` FROM `balancing`");
            $stm->execute();
            $row = $stm->fetch(PDO::FETCH_ASSOC);
            if (!isset($row['db'])) {
                $db = 1;
            } elseif ($row['db'] <= 1) {
                $db = 1;
            } else {
                $db = $row['db'];
            }

            // check file size

            $size = \file_exists($this->SqliteDir . '/db' . $db) ? filesize($this->SqliteDir . '/db' . $db) : 1;
            $size = round($size / 1024 / 1024, 1);


            if ($size > $this->maxSize) {
                $db++;
            }
            $this->currentDB = $db;

        }

        // look for keyword
        $stm = $this->indexing->prepare("SELECT * FROM `balancing` WHERE `keyword`=:keyword LIMIT 1");
        $stm->execute([
            ':keyword' => $keyword,
        ]);
        $row = $stm->fetch(PDO::FETCH_ASSOC);
        if (isset($row['db']) && $row['db'] != '') {
            $db = $row['db'];
        } else {
            /*
             * Insert new to Indexing
             */
            $db = $this->currentDB;
            $stm = $this->indexing->prepare("INSERT INTO `balancing` (`keyword`,`db`) VALUES(:keyword, :db)");
            $stm->execute([
                ':keyword' => $keyword,
                ':db' => $db,
            ]);
        }

        return $db;
    }