diff options
author | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-06 16:14:45 +0300 |
---|---|---|
committer | Sergey Poznyakoff <gray@gnu.org.ua> | 2011-06-06 16:18:34 +0300 |
commit | 8a7e9b26e073731c82c02594d081c57aa474eade (patch) | |
tree | 8aba21e17f5518dc52fb407ba4759ee499a33e34 /src/ellinika | |
parent | 00131c263a9cb0ff8501bc1c4dc1e38b84af1a88 (diff) | |
download | ellinika-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')
-rw-r--r-- | src/ellinika/elmorph.c | 51 |
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", | |||
596 | #define FUNC_NAME s_scm_elstr_char_prop_bitmask | 596 | #define FUNC_NAME s_scm_elstr_char_prop_bitmask |
597 | { | 597 | { |
598 | struct elstr *elstr; | 598 | struct elstr *elstr; |
599 | unsigned num; | 599 | int num; |
600 | 600 | ||
601 | SCM_ASSERT(scm_is_elstr(el), el, SCM_ARG1, FUNC_NAME); | 601 | SCM_ASSERT(scm_is_elstr(el), el, SCM_ARG1, FUNC_NAME); |
602 | SCM_ASSERT(scm_is_integer(n), n, SCM_ARG2, FUNC_NAME); | 602 | SCM_ASSERT(scm_is_integer(n), n, SCM_ARG2, FUNC_NAME); |
603 | elstr = (struct elstr*) SCM_CDR(el); | 603 | elstr = (struct elstr*) SCM_CDR(el); |
604 | num = scm_to_uint(n); | 604 | num = scm_to_int(n); |
605 | if (num < 0) | ||
606 | num += elstr->len; | ||
605 | if (num >= elstr->len) | 607 | if (num >= elstr->len) |
606 | scm_misc_error(FUNC_NAME, | 608 | scm_misc_error(FUNC_NAME, |
607 | "cannot get character #~S: not enough characters: ~S", | 609 | "cannot get character #~S: not enough characters: ~S", |
@@ -812,6 +814,51 @@ SCM_DEFINE_PUBLIC(scm_elstr_index, "elstr-index", | |||
812 | } | 814 | } |
813 | #undef FUNC_NAME | 815 | #undef FUNC_NAME |
814 | 816 | ||
817 | static int | ||
818 | _suffix_matches(struct elstr *elstr, SCM suffix, int arg, const char *func_name) | ||
819 | { | ||
820 | struct elstr *ep; | ||
821 | |||
822 | if (scm_is_elstr(suffix)) { | ||
823 | ep = (struct elstr*) SCM_CDR(suffix); | ||
824 | } else { | ||
825 | SCM scm; | ||
826 | char *str; | ||
827 | |||
828 | SCM_ASSERT(scm_is_string(suffix), suffix, arg, func_name); | ||
829 | str = scm_to_locale_string(suffix); | ||
830 | scm = _elstr_alloc(str, 0); | ||
831 | free(str); | ||
832 | ep = (struct elstr*) SCM_CDR(scm); | ||
833 | } | ||
834 | return (ep->len < elstr->len && | ||
835 | memcmp(elstr->str + elstr->len - ep->len, | ||
836 | ep->str, | ||
837 | ep->len * sizeof(elstr->str[0])) == 0); | ||
838 | } | ||
839 | |||
840 | SCM_DEFINE_PUBLIC(scm_elstr_suffix_p, "elstr-suffix?", | ||
841 | 2, 0, 1, | ||
842 | (SCM word, SCM suffix, SCM rest), | ||
843 | "Return #t if WORDS ends with SUFFIX") | ||
844 | #define FUNC_NAME s_scm_elstr_suffix_p | ||
845 | { | ||
846 | struct elstr *elstr; | ||
847 | |||
848 | SCM_ASSERT(scm_is_elstr(word), word, SCM_ARG1, FUNC_NAME); | ||
849 | elstr = (struct elstr*) SCM_CDR(word); | ||
850 | if (_suffix_matches(elstr, suffix, SCM_ARG2, FUNC_NAME)) | ||
851 | return suffix; | ||
852 | |||
853 | for (; !scm_is_null(rest); rest = SCM_CDR(rest)) { | ||
854 | SCM val = SCM_CAR(rest); | ||
855 | if (_suffix_matches(elstr, val, SCM_ARGn, FUNC_NAME)) | ||
856 | return val; | ||
857 | } | ||
858 | return SCM_BOOL_F; | ||
859 | } | ||
860 | #undef FUNC_NAME | ||
861 | |||
815 | SCM_DEFINE_PUBLIC(scm_elstr_append, "elstr-append", | 862 | SCM_DEFINE_PUBLIC(scm_elstr_append, "elstr-append", |
816 | 0, 0, 1, | 863 | 0, 0, 1, |
817 | (SCM rest), | 864 | (SCM rest), |