summaryrefslogtreecommitdiffabout
path: root/src/ellinika
authorSergey Poznyakoff <gray@gnu.org.ua>2011-06-06 13:14:45 (GMT)
committer Sergey Poznyakoff <gray@gnu.org.ua>2011-06-06 13:18:34 (GMT)
commit8a7e9b26e073731c82c02594d081c57aa474eade (patch) (side-by-side diff)
tree8aba21e17f5518dc52fb407ba4759ee499a33e34 /src/ellinika
parent00131c263a9cb0ff8501bc1c4dc1e38b84af1a88 (diff)
downloadellinika-8a7e9b26e073731c82c02594d081c57aa474eade.tar.gz
ellinika-8a7e9b26e073731c82c02594d081c57aa474eade.tar.bz2
Improve conjugator
* data/db.struct: Update. * data/dbverb.struct: New file. * scm/conjugator.scm: Conjugate passive voice. * src/ellinika/elmorph.c (elstr-char-prop-bitmask): Accept negative positions. * xml/pl/rhmata.xml: Make verb suffixes prominent. * xml/ru/rhmata.xml: Likewise.
Diffstat (limited to 'src/ellinika') (more/less context) (ignore whitespace changes)
-rw-r--r--src/ellinika/elmorph.c51
1 files changed, 49 insertions, 2 deletions
diff --git a/src/ellinika/elmorph.c b/src/ellinika/elmorph.c
index faeeb49..5785f8d 100644
--- a/src/ellinika/elmorph.c
+++ b/src/ellinika/elmorph.c
@@ -596,12 +596,14 @@ SCM_DEFINE_PUBLIC(scm_elstr_char_prop_bitmask, "elstr-char-prop-bitmask",
#define FUNC_NAME s_scm_elstr_char_prop_bitmask
{
struct elstr *elstr;
- unsigned num;
+ int num;
SCM_ASSERT(scm_is_elstr(el), el, SCM_ARG1, FUNC_NAME);
SCM_ASSERT(scm_is_integer(n), n, SCM_ARG2, FUNC_NAME);
elstr = (struct elstr*) SCM_CDR(el);
- num = scm_to_uint(n);
+ num = scm_to_int(n);
+ if (num < 0)
+ num += elstr->len;
if (num >= elstr->len)
scm_misc_error(FUNC_NAME,
"cannot get character #~S: not enough characters: ~S",
@@ -812,6 +814,51 @@ SCM_DEFINE_PUBLIC(scm_elstr_index, "elstr-index",
}
#undef FUNC_NAME
+static int
+_suffix_matches(struct elstr *elstr, SCM suffix, int arg, const char *func_name)
+{
+ struct elstr *ep;
+
+ if (scm_is_elstr(suffix)) {
+ ep = (struct elstr*) SCM_CDR(suffix);
+ } else {
+ SCM scm;
+ char *str;
+
+ SCM_ASSERT(scm_is_string(suffix), suffix, arg, func_name);
+ str = scm_to_locale_string(suffix);
+ scm = _elstr_alloc(str, 0);
+ free(str);
+ ep = (struct elstr*) SCM_CDR(scm);
+ }
+ return (ep->len < elstr->len &&
+ memcmp(elstr->str + elstr->len - ep->len,
+ ep->str,
+ ep->len * sizeof(elstr->str[0])) == 0);
+}
+
+SCM_DEFINE_PUBLIC(scm_elstr_suffix_p, "elstr-suffix?",
+ 2, 0, 1,
+ (SCM word, SCM suffix, SCM rest),
+"Return #t if WORDS ends with SUFFIX")
+#define FUNC_NAME s_scm_elstr_suffix_p
+{
+ struct elstr *elstr;
+
+ SCM_ASSERT(scm_is_elstr(word), word, SCM_ARG1, FUNC_NAME);
+ elstr = (struct elstr*) SCM_CDR(word);
+ if (_suffix_matches(elstr, suffix, SCM_ARG2, FUNC_NAME))
+ return suffix;
+
+ for (; !scm_is_null(rest); rest = SCM_CDR(rest)) {
+ SCM val = SCM_CAR(rest);
+ if (_suffix_matches(elstr, val, SCM_ARGn, FUNC_NAME))
+ return val;
+ }
+ return SCM_BOOL_F;
+}
+#undef FUNC_NAME
+
SCM_DEFINE_PUBLIC(scm_elstr_append, "elstr-append",
0, 0, 1,
(SCM rest),

Return to:

Send suggestions and report system problems to the System administrator.