ConlangWord.h header

#include <ew/app/ConlangWord.h>

Namespace ew::app

SplitWord struct

struct ew::app::SplitWord

A word token split into the punctuation before it, the word itself, and the punctuation after it, so a caller can act on the word and put back what surrounded it.

Members

QString ew::app::conlang::SplitWord::leading

The punctuation before the word (an opening bracket, a quotation mark); empty if none.

QString ew::app::conlang::SplitWord::core

The word itself, as isConlangWordChar defines it; empty for a token that is punctuation only.

QString ew::app::conlang::SplitWord::trailing

The punctuation after the word (a comma, a full stop); empty if none.

Functions

QString ew::app::conlang::conlangWordLetters(const QString &token)

The word in token under the stricter reading that only letters belong to a word, so an apostrophe or hyphen at either edge is stripped along with the other punctuation. Use this as a fallback after splitConlangWord, for a writer who quotes a word ('miu') rather than spelling it with an edge mark.

bool ew::app::conlang::isConlangWordChar(QChar ch)

Whether ch belongs to a constructed-language word: a letter, or the apostrophe and hyphen that carry sound and structure in constructed languages – an apostrophe spells a glottal stop (ka', t'lan) and a hyphen marks a bound affix (-ith), at the edges of a word as much as inside it. Everything else is punctuation around the word.

QString ew::app::conlang::matchCapitalization(const QString &model, QString text)

text capitalised to match model: when model begins with an upper-case letter the first letter of the result is upper-cased, otherwise text is returned unchanged. Use this wherever one form of a word replaces another – a translation, a romanization – so a word that opened a sentence still does.

SplitWord ew::app::conlang::splitConlangWord(const QString &token)

Splits token – a run of non-whitespace characters – into the punctuation before the word, the word, and the punctuation after it. A token with no word character yields an empty SplitWord::core and keeps the whole token in SplitWord::leading.