1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-08 01:54:21 +03:00
inform7/services/inflections-module/Chapter 2/Article Inflection.w

23 lines
736 B
OpenEdge ABL

[ArticleInflection::] Article Inflection.
To inflect "a" into "an", and so forth.
@ Here we take text such as "UNESCO document" and put an article in front, to
get "a UNESCO document" (and not "an UNESCO document": these things are much
trickier than they look).
=
match_avinue *indef_trie = NULL;
void ArticleInflection::preface_by_article(OUTPUT_STREAM,
text_stream *initial_text, NATURAL_LANGUAGE_WORDS_TYPE *nl) {
if (indef_trie == NULL)
indef_trie =
PreformUtilities::define_trie(
<singular-noun-to-its-indefinite-article>, TRIE_START,
DefaultLanguage::get(NULL));
inchar32_t *result = Tries::search_avinue(indef_trie, initial_text);
if (result == NULL) result = U"a";
WRITE("%w %S", result, initial_text);
}