1
0
Fork 0
mirror of https://github.com/ganelson/inform.git synced 2024-07-16 22:14:23 +03:00
inform7/services/inflections-module/Chapter 2/Past Participles.w

45 lines
1.4 KiB
OpenEdge ABL
Raw Normal View History

2019-02-05 02:44:07 +02:00
[PastParticiples::] Past Participles.
To inflect present into past participles.
@h Constructing past participles.
For example, "turning away" to "turned away".
=
wording PastParticiples::pasturise_wording(wording W) {
2020-06-28 01:18:54 +03:00
TEMPORARY_TEXT(pasturised)
TEMPORARY_TEXT(from)
2019-02-05 02:44:07 +02:00
feed_t id = Feeds::begin();
LOOP_THROUGH_WORDING(i, W) {
WRITE_TO(from, "%W", Wordings::one_word(i));
if (Str::get_first_char(from) == '\"') WRITE_TO(pasturised, "some-long-text");
else {
if (PastParticiples::pasturise_text(pasturised, from)) {
if (i > Wordings::first_wn(W)) Feeds::feed_wording(Wordings::up_to(W, i-1));
2020-05-12 12:00:53 +03:00
Feeds::feed_text(pasturised);
2019-02-05 02:44:07 +02:00
if (i < Wordings::last_wn(W)) Feeds::feed_wording(Wordings::from(W, i+1));
break;
}
}
}
wording PLW = Feeds::end(id);
LOGIF(CONSTRUCTED_PAST_PARTICIPLES, "[Past participle of %W is %W]\n", W, PLW);
2020-06-28 01:18:54 +03:00
DISCARD_TEXT(from)
DISCARD_TEXT(pasturised)
2019-02-05 02:44:07 +02:00
return PLW;
}
@h The pasturising trie.
This is the process of turning a present participle, like "turning", to
a past participle, like "turned". Note that it returns |NULL| if it fails
to recognise the word in question as a present participle; this is needed
above. It expects only a single word.
=
int PastParticiples::pasturise_text(OUTPUT_STREAM, text_stream *from) {
match_avinue *past_trie =
2020-05-24 00:57:42 +03:00
PreformUtilities::define_trie(<pasturise-participle>, TRIE_START,
2020-05-24 18:15:15 +03:00
DefaultLanguage::get(NULL));
return Inflect::suffix(OUT, past_trie, from);
2019-02-05 02:44:07 +02:00
}