LexiconTools.h header
#include <ew/app/LexiconTools.h>
Namespace ew::app
Enumerations
enum class LexiconSortKey { Word, Gloss, SemanticField, PartOfSpeech }
The field a lexicon can be ordered by.
Functions
std::vector< ew::core::LexiconEntry > ew::app::assignLexiconIds(std::vector< ew::core::LexiconEntry > entries)
Returns a copy of entries in which every entry lacking an id is assigned a fresh, unique one (of the form "lex-N"), leaving existing ids untouched. Deterministic. Needed before entries can be referenced by derivation/cognate links.
std::vector< ew::core::LexiconEntry > ew::app::dedupeLexicon(const std::vector< ew::core::LexiconEntry > &entries)
Removes duplicate entries (same headword), keeping the first occurrence, preserving order.
ew::core::LexiconEntry ew::app::deriveWord(const ew::core::LexiconEntry &root, const QString &word, const QString &gloss, const QString &partOfSpeech)
Builds a lexicon entry derived from root: the new word and gloss with the given partOfSpeech, linked back to the root by ew::core::LexiconEntry::rootId (from root's id) and a < root etymology, and inheriting the root's semantic field. This is the "make the
adjective from this noun" derivation step; the root should already carry an id (see assignLexiconIds).
std::vector< ew::core::LexiconEntry > ew::app::filterBySemanticField(const std::vector< ew::core::LexiconEntry > &entries, const QString &semanticField)
Returns the entries in the given semantic field (case-insensitive exact match), preserving order.
std::vector< ew::core::LexiconEntry > ew::app::generateSemanticField(const ew::core::Language &language, const std::vector< QString > &meanings, const QString &semanticField, quint64 seed)
Generates a fresh lexicon entry for each meaning in meanings, coining a word from language's phonology (the structured inventory + phonotactics, falling back to the legacy phoneme/pattern strings when a language has not been given a structured sound system yet), auto-glossing it with the meaning and tagging it with semanticField. Generation is deterministic per seed. Coined words are unique against language's existing lexicon and against each other; a meaning that cannot be realized (no sounds to draw from) is skipped. The returned entries carry no id – run assignLexiconIds to give them stable identifiers.
std::vector< ew::core::LexiconEntry > ew::app::searchLexicon(const std::vector< ew::core::LexiconEntry > &entries, const QString &query)
Returns the entries whose headword, gloss, semantic field, or part of speech contains query (case-insensitive), preserving order. An empty query returns every entry.
std::vector< ew::core::LexiconEntry > ew::app::sortLexicon(const std::vector< ew::core::LexiconEntry > &entries, LexiconSortKey key)
Returns the entries sorted (case-insensitively, stably) by key.
const std::vector< QString > & ew::app::swadeshList()
A standard core-vocabulary meaning list (a Swadesh-style list) a worldbuilder can seed a lexicon from – the words every language is expected to have. Returned as glosses to generate words for.