From 55f418118d70b4eae0ad031647754500b695a701 Mon Sep 17 00:00:00 2001 From: Alexis Nasr <alexis.nasr@lif.univ-mrs.fr> Date: Thu, 25 May 2017 10:05:36 +0200 Subject: [PATCH] added a function that checks if a l_rule can apply --- maca_common/src/l_rule.c | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/maca_common/src/l_rule.c b/maca_common/src/l_rule.c index e851f78..ee49439 100644 --- a/maca_common/src/l_rule.c +++ b/maca_common/src/l_rule.c @@ -5,6 +5,28 @@ #include "util.h" +int l_rule_is_applicable(char *form, char *l_rule) +{ + int i,j; + int sep_index; + int lemma_suffix_length; + int form_suffix_length; + int form_length = strlen(form); + int l_rule_length = strlen(l_rule); + + for(sep_index=1; sep_index < l_rule_length; sep_index++) + if(l_rule[sep_index] == '@') + break; + + lemma_suffix_length = l_rule_length - 1 - sep_index; + form_suffix_length = sep_index - 1; + + for(j=0, i=form_length - form_suffix_length; j < sep_index; i++, j++) + if((l_rule[j] != '*') && (l_rule[j] != form[i])) + return 0; + return 1; +} + char *apply_l_rule(char *form, char *l_rule) { int i,j; -- GitLab