Example #1
0
void InflectLexicon::LoadSlow(const char *dir, const TagLexicon *tags) {
    lexiconDir = dir;
    Message(MSG_STATUS, "loading inflect lexicon slow...");
    std::ifstream in;
    if (!FixIfstream(in, dir, "inflection.rules", true))
        return;
    InflectRule::strings = new char[MAX_INFLECTION_RULES*40];
    for (nRules=0; nRules<MAX_INFLECTION_RULES; nRules++) {
        while (isspace(in.peek())) in.get();
        if (in.peek() == EOF)
            break;
        InflectRule &r = rules[nRules];
        if (in.peek() == '$') {
            in.get();
            Tag t;
            int j=0;
            while (in.peek() != '\n') {
                ensure(j < MAX_INFLECTION_FORMS);
                in >> t.string;
                if (strcmp(t.string, "-")) {
                    Tag *t2 = tags->Find(t);
                    if (!t2)
                        Message(MSG_WARNING, "unknown tag in inflection.rules:", t.String());//jonas 	    Message(MSG_ERROR, "unknown tag in inflection.rules:", t.String());
                    else {
                        r.tagIndex[j] = t2->Index();
                        if (j == 0)
                            t2->ruleBase = true;
                    }
                } else
                    r.tagIndex[j] = TAG_INDEX_NONE;
                j++;
                SkipSpaceButNotNewLine(in);
            }
            for (; j<MAX_INFLECTION_FORMS; j++)
                r.tagIndex[j] = TAG_INDEX_NONE;
        } else {
            if (nRules == 0)