Beispiel #1
0
Lexicon*
PolyLexReader_Lexicon_IMP(PolyLexiconReader *self, String *field,
                          Obj *term) {
    PolyLexicon *lexicon = NULL;

    if (field != NULL) {
        Schema *schema = PolyLexReader_Get_Schema(self);
        FieldType *type = Schema_Fetch_Type(schema, field);
        if (type != NULL) {
            PolyLexiconReaderIVARS *const ivars = PolyLexReader_IVARS(self);
            lexicon = PolyLex_new(field, ivars->readers);
            if (!PolyLex_Get_Num_Seg_Lexicons(lexicon)) {
                DECREF(lexicon);
                return NULL;
            }
            if (term) { PolyLex_Seek(lexicon, term); }
        }
    }

    return (Lexicon*)lexicon;
}
Lexicon*
PolyLexReader_lexicon(PolyLexiconReader *self, const CharBuf *field,
                      Obj *term)
{
    PolyLexicon *lexicon = NULL;

    if (field != NULL) {
        Schema *schema = PolyLexReader_Get_Schema(self);
        FieldType *type = Schema_Fetch_Type(schema, field);
        if (type != NULL) {
            lexicon = PolyLex_new(field, self->readers);
            if (!VA_Get_Size(lexicon->seg_lexicons)) {
                DECREF(lexicon);
                return NULL;
            }
            if (term) { Lex_Seek(lexicon, term); }
        }
    }

    return (Lexicon*)lexicon;
}