Adds a new terms within the given vocabulary.

@param int $vocabularyId Vocabulary's ID
@return void
182578
public function add($vocabularyId)
    {
        $this->loadModel('Taxonomy.Vocabularies');
        $vocabulary = $this->Vocabularies->get($vocabularyId);
        $term = $this->Vocabularies->Terms->newEntity(['vocabulary_id' => $vocabulary->id], ['validate' => false]);
        $this->Vocabularies->Terms->addBehavior('Tree', ['scope' => ['vocabulary_id' => $vocabulary->id]]);

        if ($this->request->data()) {
            $term = $this->Vocabularies->Terms->patchEntity($term, $this->request->data, [
                'fieldList' => [
                    'parent_id',
                    'name',
                ]
            ]);

            if ($this->Vocabularies->Terms->save($term)) {
                $this->Flash->success(__d('taxonomy', 'Term has been created.'));
                if (!empty($this->request->data['action_vocabulary'])) {
                    $this->redirect(['plugin' => 'Taxonomy', 'controller' => 'terms', 'action' => 'vocabulary', $vocabulary->id]);
                } elseif (!empty($this->request->data['action_add'])) {
                    $this->redirect(['plugin' => 'Taxonomy', 'controller' => 'terms', 'action' => 'add', $vocabulary->id]);
                }
            } else {
                $this->Flash->danger(__d('taxonomy', 'Term could not be created, please check your information.'));
            }
        }

        $parentsTree = $this->Vocabularies->Terms
            ->find('treeList', ['spacer' => '--'])
            ->map(function ($link) {
                if (strpos($link, '-') !== false) {
                    $link = str_replace_last('-', '- ', $link);
                }

                return $link;
            });

        $this->title(__d('taxonomy', 'Create New Term'));
        $this->set(compact('vocabulary', 'term', 'parentsTree'));
        $this->Breadcrumb
            ->push('/admin/system/structure')
            ->push(__d('taxonomy', 'Taxonomy'), '/admin/taxonomy/manage')
            ->push(__d('taxonomy', 'Vocabularies'), ['plugin' => 'Taxonomy', 'controller' => 'vocabularies', 'action' => 'index'])
            ->push("\"{$vocabulary->name}\"", ['plugin' => 'Taxonomy', 'controller' => 'vocabularies', 'action' => 'edit', $vocabulary->id])
            ->push(__d('taxonomy', 'Terms'), ['plugin' => 'Taxonomy', 'controller' => 'terms', 'action' => 'vocabulary', $vocabulary->id])
            ->push(__d('taxonomy', 'Add new term'), '#');
    }
1157873
public function pushLanguage(int $lanId): void
  {
    $this->language = Abc::$DL->abcBabelCoreLanguageGetDetails($lanId);
    array_push($this->stack, $this->language);
  }
203718
private function addTermData($termData)
    {
        $labelsByThesaurusId = [];

        foreach ($termData as $currentTerm) {
            $label = $currentTerm['expansions_terms'];

            if (isset($currentTerm['expanded_term']) && $currentTerm['expanded_term']) {
                $label = sprintf("%s => %s", $currentTerm['expanded_term'], $label);
            }

            $labelsByThesaurusId[$currentTerm['thesaurus_id']][] = $label;
        }

        foreach ($labelsByThesaurusId as $thesaurusId => $labels) {
            $this->_items[$thesaurusId]->setData('terms_summary', implode(" <br/> ", $labels));
        }

        return $this;
    }
776717
public function search($vocabularyId)
    {
        $this->loadModel('Taxonomy.Terms');
        $out = [];
        $text = $this->request->query['q'];
        $terms = $this->Terms
            ->find()
            ->select(['id', 'name'])
            ->where(['name LIKE' => "%%{$text}%%", 'vocabulary_id' => $vocabularyId])
            ->limit(10)
            ->all();

        foreach ($terms as $term) {
            $out[] = ['id' => $term->id, 'name' => $term->name];
        }

        die(json_encode($out));
    }
158422
public function getTermsForVocabulary($vocabulary_id)
    {
        return $this->cache->remember(
            'Rocket::Taxonomy::Terms::' . $vocabulary_id,
            60,
            function () use ($vocabulary_id) {
                $terms = TermContainer::where('vocabulary_id', $vocabulary_id)->get(['id']);

                $results = [];
                if (!empty($terms)) {
                    foreach ($terms as $term) {
                        $results[] = $term->id;
                    }
                }

                return $results;
            }
        );
    }
1339697
public function createTerm($vocabulary, $name)
    {
        // @todo make this easily extensible.
        $term = (object) array(
        'name' => $name,
        'vocabulary_machine_name' => $vocabulary,
        'description' => $this->getRandom()->name(255),
        );
        $saved = $this->termCreate($term);

        // Set internal page on the term.
        $this->getSession()->visit($this->locatePath('/taxonomy/term/' . $saved->tid));
    }
1040511
public function addWord($text, callable $callback, $textType = WordType::TEXT)
    {
        $inputWords = $this->getTranslateEntry()->getInputWords();

        $index = count($inputWords);
        $inputWords->addOne(new WordEntry($text, $textType));
        $this->addToTranslateMap($index, $callback);
    }
445738
private void addWord(String word, boolean containsNewLine) {
        currentSentence.add(word);
        if (containsNewLine) {
            sentences.add(getSentenceFromListCheckingNewLines(currentSentence));
            currentSentence.clear();
        }
    }
1331213
public function addWords(array $words)
    {
        $query = $this->dbHandler->createInsertQuery();
        $query->insertInto('ezsearch_word');

        $word = null;

        $query->set(
            'word',
            ':word'
        )->set(
            'object_count',
            '1'
        );
        $stmt = $query->prepare();
        foreach ($words as $word) {
            $stmt->execute(['word' => $word]);
        }
    }
697881
protected void addTerm(NormalFormGCI term) {
        if (term instanceof NF1a) {
            final NF1a nf1 = (NF1a) term;
            final int a = nf1.lhsA();
            addTerms(ontologyNF1, a, nf1.getQueueEntry());
        } else if (term instanceof NF1b) {
            final NF1b nf1 = (NF1b) term;
            final int a1 = nf1.lhsA1();
            final int a2 = nf1.lhsA2();
            addTerms(ontologyNF1, a1, nf1.getQueueEntry1());
            addTerms(ontologyNF1, a2, nf1.getQueueEntry2());
        } else if (term instanceof NF2) {
            final NF2 nf2 = (NF2) term;
            addTerms(ontologyNF2, nf2);
        } else if (term instanceof NF3) {
            final NF3 nf3 = (NF3) term;
            addTerms(ontologyNF3, nf3);
        } else if (term instanceof NF4) {
            ontologyNF4.add((NF4) term);
        } else if (term instanceof NF5) {
            ontologyNF5.add((NF5) term);
        } else if (term instanceof NF6) {
            reflexiveRoles.add(((NF6) term).getR());
        } else if (term instanceof NF7) {
            final NF7 nf7 = (NF7) term;
            addTerms(ontologyNF7, nf7);
        } else if (term instanceof NF8) {
            final NF8 nf8 = (NF8) term;
            addTerms(ontologyNF8, nf8);
        } else {
            throw new IllegalArgumentException("Type of " + term
                    + " must be one of NF1 through NF8");
        }
    }
564513
public function vocabulary($id)
    {
        $this->loadModel('Taxonomy.Vocabularies');
        $vocabulary = $this->Vocabularies->get($id);
        $terms = $this->Vocabularies->Terms
            ->find()
            ->where(['vocabulary_id' => $id])
            ->order(['lft' => 'ASC'])
            ->all()
            ->map(function ($term) {
                $term->set('expanded', true);

                return $term;
            })
            ->nest('id', 'parent_id');

        if (!empty($this->request->data['tree_order'])) {
            $items = json_decode($this->request->data['tree_order']);

            if ($items) {
                unset($items[0]);
                $entities = [];

                foreach ($items as $key => $item) {
                    $term = $this->Vocabularies->Terms->newEntity([
                        'id' => $item->item_id,
                        'parent_id' => intval($item->parent_id),
                        'lft' => ($item->left - 1),
                        'rght' => ($item->right - 1),
                    ], ['validate' => false]);
                    $term->isNew(false);
                    $term->dirty('id', false);
                    $entities[] = $term;
                }

                $this->Vocabularies->Terms->unbindSluggable();
                $this->Vocabularies->Terms->connection()->transactional(function () use ($entities) {
                    foreach ($entities as $entity) {
                        $this->Vocabularies->Terms->save($entity, ['atomic' => false]);
                    }
                });
                // don't trust "left" and "right" values coming from user's POST
                $this->Vocabularies->Terms->addBehavior('Tree', ['scope' => ['vocabulary_id' => $vocabulary->id]]);
                $this->Vocabularies->Terms->recover();
                $this->Flash->success(__d('taxonomy', 'Vocabulary terms tree has been reordered'));
            } else {
                $this->Flash->danger(__d('taxonomy', 'Invalid information, check you have JavaScript enabled'));
            }

            $this->redirect($this->referer());
        }

        $this->title(__d('taxonomy', 'Vocabulary’s Terms'));
        $this->set(compact('vocabulary', 'terms'));
        $this->Breadcrumb
            ->push('/admin/system/structure')
            ->push(__d('taxonomy', 'Taxonomy'), '/admin/taxonomy/manage')
            ->push(__d('taxonomy', 'Vocabularies'), ['plugin' => 'Taxonomy', 'controller' => 'vocabularies', 'action' => 'index'])
            ->push("\"{$vocabulary->name}\"", ['plugin' => 'Taxonomy', 'controller' => 'vocabularies', 'action' => 'edit', $vocabulary->id])
            ->push(__d('taxonomy', 'Terms'), '#');
    }
454049
public function add()
    {
        $this->loadModel('Taxonomy.Vocabularies');
        $vocabulary = $this->Vocabularies->newEntity();

        if ($this->request->data()) {
            $vocabulary = $this->Vocabularies->patchEntity($vocabulary, $this->request->data, [
                'fieldList' => [
                    'name',
                    'description',
                ],
            ]);

            if ($this->Vocabularies->save($vocabulary, ['atomic' => true])) {
                $this->Flash->success(__d('taxonomy', 'Vocabulary has been created, now you can start adding terms!'));
                $this->redirect(['plugin' => 'Taxonomy', 'controller' => 'terms', 'action' => 'add', $vocabulary->id]);
            } else {
                $this->Flash->danger(__d('taxonomy', 'Vocabulary could not be created, please check your information'));
            }
        }

        $this->title(__d('taxonomy', 'Create New Vocabulary'));
        $this->set('vocabulary', $vocabulary);
        $this->Breadcrumb
            ->push('/admin/system/structure')
            ->push(__d('taxonomy', 'Taxonomy'), '/admin/taxonomy/manage')
            ->push(__d('taxonomy', 'Vocabularies'), ['plugin' => 'Taxonomy', 'controller' => 'vocabularies', 'action' => 'index'])
            ->push(__d('taxonomy', 'Crating new vocabulary'), '#');
    }
1268457
public function add(string $menuId): void
    {
        $menu = TableRegistry::getTableLocator()->get('Menu.Menus')->get($menuId);
        $menuItem = $this->MenuItems->newEntity();
        if ($this->request->is('post')) {
            $data = $this->request->getData();
            $data['menu_id'] = $menu->id;
            $menuItem = $this->MenuItems->patchEntity($menuItem, $data);
            if ($this->MenuItems->save($menuItem)) {
                $this->Flash->success((string)__('The menu item has been saved.'));
                $this->redirect(['controller' => 'Menus', 'action' => 'view', $menu->id]);

                return;
            } else {
                $this->Flash->error((string)__('The menu item could not be saved. Please, try again.'));
            }
        }

        $parentMenuItems = $this->MenuItems
            ->find('treeList', ['spacer' => self::TREE_SPACER])
            ->where(['MenuItems.menu_id' => $menu->id]);

        $this->set(compact('menuItem', 'parentMenuItems'));
        $this->set('_serialize', ['menuItem']);
    }
198268
public function setLanguageId( $langid )
	{
		if ( $langid == $this->getLanguageId() ) { return; }

		$this->_checkLanguageId( $langid );
		$this->_values['langid'] = $langid;
		$this->setModified();
	}
1209471
def add_phrase(self,
                   phrase: List[int]) -> None:
        
        if len(phrase) == 1:
            self.final_ids.add(phrase[0])
        else:
            next_word = phrase[0]
            if next_word not in self.children:
                self.children[next_word] = AvoidTrie()
            self.step(next_word).add_phrase(phrase[1:])
1312225
private static void addSynonym(String term, String synonym, Map<String, String[]> synonyms)
   {
      term = term.toLowerCase();
      String[] syns = synonyms.get(term);
      if (syns == null)
      {
         syns = new String[]{synonym};
      }
      else
      {
         String[] tmp = new String[syns.length + 1];
         System.arraycopy(syns, 0, tmp, 0, syns.length);
         tmp[syns.length] = synonym;
         syns = tmp;
      }
      synonyms.put(term, syns);
   }
1021482
@Override
    public void incrementWordCount(String word, int increment) {
        T element = extendedVocabulary.get(word);
        if (element != null) {
            element.increaseElementFrequency(increment);
            totalWordCount.addAndGet(increment);
        }
    }