Example usage for com.fasterxml.jackson.core JsonParser nextIntValue

List of usage examples for com.fasterxml.jackson.core JsonParser nextIntValue

Introduction

In this page you can find the example usage for com.fasterxml.jackson.core JsonParser nextIntValue.

Prototype

public int nextIntValue(int defaultValue) throws IOException, JsonParseException 

Source Link

Document

Method that fetches next token (as if calling #nextToken ) and if it is JsonToken#VALUE_NUMBER_INT returns 32-bit int value; otherwise returns specified default value It is functionally equivalent to:
 return (nextToken() == JsonToken.VALUE_NUMBER_INT) ? 

Usage

From source file:eu.project.ttc.readers.TermSuiteJsonCasDeserializer.java

private static void FillFixedExpressions(JsonParser parser, JsonToken token, FixedExpression fe, CAS cas)
        throws IOException {
    if (token.equals(JsonToken.FIELD_NAME)) {
        switch (parser.getCurrentName()) {
        case F_BEGIN:
            fe.setBegin(parser.nextIntValue(0));
            break;
        case F_END:
            fe.setEnd(parser.nextIntValue(0));
            break;
        }/*from   w w w.  jav  a2 s.  c  om*/
    }
}

From source file:eu.project.ttc.readers.TermSuiteJsonCasDeserializer.java

private static void fillSdi(JsonParser parser, JsonToken token, SourceDocumentInformation sdi)
        throws IOException {
    if (token.equals(JsonToken.FIELD_NAME)) {
        switch (parser.getCurrentName()) {
        case F_URI:
            sdi.setUri(parser.nextTextValue());
            break;
        case F_OFFSET_IN_SOURCE:
            sdi.setOffsetInSource(parser.nextIntValue(0));
            break;
        case F_DOCUMENT_INDEX:
            sdi.setDocumentIndex(parser.nextIntValue(0));
            break;
        case F_NB_DOCUMENTS:
            sdi.setNbDocuments(parser.nextIntValue(0));
            break;
        case F_DOCUMENT_SIZE:
            sdi.setDocumentSize(parser.nextIntValue(0));
            break;
        case F_CUMULATED_DOCUMENT_SIZE:
            sdi.setCumulatedDocumentSize(parser.nextLongValue(0));
            break;
        case F_CORPUS_SIZE:
            sdi.setCorpusSize(parser.nextLongValue(0));
            break;
        case F_LAST_SEGMENT:
            sdi.setLastSegment(parser.nextBooleanValue());
            break;
        case F_BEGIN:
            sdi.setBegin(parser.nextIntValue(0));
            break;
        case F_END:
            sdi.setEnd(parser.nextIntValue(0));
            break;
        }/*from  w  w w.jav  a 2 s  . co m*/
    }
}

From source file:com.google.openrtb.json.Test3Reader.java

@Override
protected void read(BidResponse.Builder msg, JsonParser par) throws IOException {
    if ("test3".equals(getCurrentName(par))) {
        msg.setExtension(TestExt.testResponse3, par.nextIntValue(0));
    }/*from  www  . j  a v a  2s .  c o m*/
}

From source file:YDExtStandardAssetReader.java

@Override
protected void read(OpenRtb.NativeRequest.Asset.Builder ext, JsonParser par) throws IOException {
    switch (getCurrentName(par)) {
    case "id":
        ext.setId(par.nextIntValue(-1));
        break;/*from   w w w.  j a va2 s. c  o  m*/
    case "required":
        ext.setRequired(par.nextIntValue(0) != 0);
        break;
    case "title":
        ext.setTitle(openRtbNativeJsonReader.readReqTitle(par));
        break;
    case "img":
        ext.setImg(openRtbNativeJsonReader.readReqImage(par));
        break;
    case "data":
        ext.setData(openRtbNativeJsonReader.readReqData(par));
        break;
    }
}

From source file:YDExtStandardSchemaIdReader.java

@Override
protected void read(OpenRtb.BidRequest.Imp.Builder message, JsonParser par) throws IOException {
    if (Constants.EXTEND_STANDARD_SCHEMA_ID_FIELD_NAME.equals(getCurrentName(par))) {
        message.setExtension(OpenRtbYDExtForDsp.ssid, par.nextIntValue(-1));
    }//from   www.  j  a  va  2 s  .co  m
}

From source file:YDExtDataAssetTypeReader.java

@Override
protected void read(OpenRtb.NativeRequest.Asset.Data.Builder message, JsonParser par) throws IOException {
    if (Constants.EXTEND_DATA_ASSET_TYPE_FIELD_NAME.equals(getCurrentName(par))) {
        message.setExtension(OpenRtbYDExtForDsp.dataAssetType, par.nextIntValue(-1));
    }//from  w w w. j  a  va  2 s .c o m
}

From source file:eu.project.ttc.readers.TermSuiteJsonCasDeserializer.java

private static void FillTermOccAnnotations(JsonParser parser, JsonToken token, TermOccAnnotation toa, CAS cas)
        throws IOException, CASException {
    if (token.equals(JsonToken.FIELD_NAME)) {
        switch (parser.getCurrentName()) {
        case F_PATTERN:
            String[] patternTable = parser.nextTextValue().split(" ");
            StringArray stringArray = new StringArray(cas.getJCas(), patternTable.length);

            for (int i = 0; i < patternTable.length; i++) {
                stringArray.set(i, patternTable[i]);
            }/*from  www . j ava2 s  .c o m*/
            toa.setPattern(stringArray);
            break;

        case F_SPOTTING_RULE_NAME:
            toa.setSpottingRuleName(parser.nextTextValue());
            break;
        case F_TERM_KEY:
            toa.setTermKey(parser.nextTextValue());
            break;
        case F_WORDS:
            fillWords(toa, cas);
            break;
        case F_BEGIN:
            toa.setBegin(parser.nextIntValue(0));
            break;
        case F_END:
            toa.setEnd(parser.nextIntValue(0));
            break;
        }
    }
}

From source file:com.joliciel.jochre.search.highlight.Snippet.java

private void read(JsonParser jsonParser) {
    try {//from w  ww .  j a  va  2s  .  c  o m
        if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT)
            throw new RuntimeException("Expected START_OBJECT, but was " + jsonParser.getCurrentToken() + " at "
                    + jsonParser.getCurrentLocation());
        while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
            String fieldName = jsonParser.getCurrentName();

            if (fieldName.equals("docId")) {
                this.docId = jsonParser.nextIntValue(0);
            } else if (fieldName.equals("field")) {
                this.field = jsonParser.nextTextValue();
            } else if (fieldName.equals("start")) {
                this.startOffset = jsonParser.nextIntValue(0);
            } else if (fieldName.equals("end")) {
                this.endOffset = jsonParser.nextIntValue(0);
            } else if (fieldName.equals("score")) {
                jsonParser.nextValue();
                this.score = jsonParser.getDoubleValue();
                this.scoreCalculated = true;
            } else if (fieldName.equals("terms")) {
                if (jsonParser.nextToken() != JsonToken.START_ARRAY)
                    throw new RuntimeException("Expected START_ARRAY, but was " + jsonParser.getCurrentToken()
                            + " at " + jsonParser.getCurrentLocation());
                while (jsonParser.nextToken() != JsonToken.END_ARRAY) {
                    if (jsonParser.getCurrentToken() != JsonToken.START_OBJECT)
                        throw new RuntimeException("Expected START_OBJECT, but was "
                                + jsonParser.getCurrentToken() + " at " + jsonParser.getCurrentLocation());
                    int termDocId = docId;
                    String termField = field;
                    int termStart = 0;
                    int termEnd = 0;
                    int pageIndex = 0;
                    int imageIndex = 0;
                    double weight = 0.0;
                    while (jsonParser.nextToken() != JsonToken.END_OBJECT) {
                        String termFieldName = jsonParser.getCurrentName();
                        if (termFieldName.equals("docId")) {
                            termDocId = jsonParser.nextIntValue(0);
                        } else if (termFieldName.equals("field")) {
                            termField = jsonParser.nextTextValue();
                        } else if (termFieldName.equals("start")) {
                            termStart = jsonParser.nextIntValue(0);
                        } else if (termFieldName.equals("end")) {
                            termEnd = jsonParser.nextIntValue(0);
                        } else if (termFieldName.equals("pageIndex")) {
                            pageIndex = jsonParser.nextIntValue(0);
                        } else if (termFieldName.equals("imageIndex")) {
                            imageIndex = jsonParser.nextIntValue(0);
                        } else if (termFieldName.equals("weight")) {
                            jsonParser.nextValue();
                            weight = jsonParser.getDoubleValue();
                        } else {
                            throw new RuntimeException("Unexpected term field name: " + termFieldName + " at "
                                    + jsonParser.getCurrentLocation());
                        }
                    }
                    HighlightTerm highlightTerm = new HighlightTerm(termDocId, termField, termStart, termEnd,
                            imageIndex, pageIndex);
                    highlightTerm.setWeight(weight);
                    this.highlightTerms.add(highlightTerm);
                }
            } else {
                throw new RuntimeException(
                        "Unexpected field name: " + fieldName + " at " + jsonParser.getCurrentLocation());
            }
        }
    } catch (JsonParseException e) {
        LOG.error(e);
        throw new RuntimeException(e);
    } catch (IOException e) {
        LOG.error(e);
        throw new RuntimeException(e);
    }
}

From source file:eu.project.ttc.readers.TermSuiteJsonCasDeserializer.java

private static void fillWordAnnotations(JsonParser parser, JsonToken token, WordAnnotation wa)
        throws IOException {
    if (token.equals(JsonToken.FIELD_NAME)) {
        switch (parser.getCurrentName()) {
        case F_CATEGORY:
            wa.setCategory(parser.nextTextValue());
            break;
        case F_LEMMA:
            wa.setLemma(parser.nextTextValue());
            break;
        case F_STEM:
            wa.setStem(parser.nextTextValue());
            break;
        case F_TAG:
            wa.setTag(parser.nextTextValue());
            break;
        case F_SUB_CATEGORY:
            wa.setSubCategory(parser.nextTextValue());
            break;
        case F_REGEX_LABEL:
            wa.setRegexLabel(parser.nextTextValue());
            break;
        case F_NUMBER:
            wa.setNumber(parser.nextTextValue());
            break;
        case F_GENDER:
            wa.setGender(parser.nextTextValue());
            break;
        case F_CASE:
            wa.setCase(parser.nextTextValue());
            break;
        case F_MOOD:
            wa.setMood(parser.nextTextValue());
            break;
        case F_TENSE:
            wa.setTense(parser.nextTextValue());
            break;
        case F_PERSON:
            wa.setPerson(parser.nextTextValue());
            break;
        case F_DEGREE:
            wa.setDegree(parser.nextTextValue());
            break;
        case F_FORMATION:
            wa.setFormation(parser.nextTextValue());
            break;
        case F_LABELS:
            wa.setLabels(parser.nextTextValue());
            break;
        case F_BEGIN:
            wa.setBegin(parser.nextIntValue(0));
            break;
        case F_END:
            wa.setEnd(parser.nextIntValue(0));
            break;
        }//from  w w  w .  ja v a 2  s . c  om
    }
}

From source file:eu.project.ttc.models.index.JsonTermIndexIO.java

/**
 * Loads the json-serialized term index into the param {@link TermIndex} object.
 * /*from   w w w . j  ava  2 s .c  om*/
 * @param reader
 * @param options
 *          The deserialization {@link IOOptions}.
 * @return
 * @throws JsonParseException
 * @throws IOException
 */
public static TermIndex load(Reader reader, JsonOptions options) throws JsonParseException, IOException {
    TermIndex termIndex = null;
    JsonFactory jsonFactory = new JsonFactory();
    JsonParser jp = jsonFactory.createParser(reader); // or Stream, Reader
    jp.enable(JsonParser.Feature.ALLOW_UNQUOTED_FIELD_NAMES);
    jp.enable(JsonParser.Feature.STRICT_DUPLICATE_DETECTION);
    String fieldname;
    String compLemma = null;
    int fileSource = -1;
    String wordLemma = null;
    String syntacticLabel = null;
    int begin = -1;
    int end = -1;
    int nbWordAnnos = -1;
    int nbSpottedTerms = -1;
    Term b;
    Term v;
    String text;
    String base;
    String variant;
    //      String rule;
    String infoToken;
    String variantType;
    double variantScore;

    Map<Integer, String> inputSources = Maps.newTreeMap();

    Map<Integer, List<TempVecEntry>> contextVectors = Maps.newHashMap();

    OccurrenceStore occurrenceStore = null;

    // useful var for debug
    JsonToken tok;

    while ((tok = jp.nextToken()) != JsonToken.END_OBJECT) {

        fieldname = jp.getCurrentName();
        if (METADATA.equals(fieldname)) {
            jp.nextToken();
            String termIndexName = null;
            Lang lang = null;
            String corpusID = null;
            String occurrenceStorage = null;
            String occurrenceStoreURI = null;

            while ((tok = jp.nextToken()) != JsonToken.END_OBJECT) {
                fieldname = jp.getCurrentName();
                if (LANG.equals(fieldname)) {
                    lang = Lang.forName(jp.nextTextValue());
                } else if (NAME.equals(fieldname)) {
                    termIndexName = jp.nextTextValue();
                } else if (NB_WORD_ANNOTATIONS.equals(fieldname)) {
                    nbWordAnnos = jp.nextIntValue(-1);
                } else if (NB_SPOTTED_TERMS.equals(fieldname)) {
                    nbSpottedTerms = jp.nextIntValue(-1);
                } else if (CORPUS_ID.equals(fieldname)) {
                    corpusID = jp.nextTextValue();
                } else if (OCCURRENCE_STORAGE.equals(fieldname)) {
                    occurrenceStorage = jp.nextTextValue();
                } else if (OCCURRENCE_MONGODB_STORE_URI.equals(fieldname)) {
                    occurrenceStoreURI = jp.nextTextValue();
                }
            }
            Preconditions.checkState(lang != null, "The property meta.lang must be defined");
            Preconditions.checkState(termIndexName != null, "The property meta.name must be defined");

            if (occurrenceStorage != null && occurrenceStorage.equals(OCCURRENCE_STORAGE_MONGODB)) {
                Preconditions.checkNotNull(occurrenceStoreURI,
                        "Missing attribute " + OCCURRENCE_MONGODB_STORE_URI);
                occurrenceStore = new MongoDBOccurrenceStore(occurrenceStoreURI, OccurrenceStore.State.INDEXED);
            } else
                occurrenceStore = new MemoryOccurrenceStore();

            termIndex = new MemoryTermIndex(termIndexName, lang, occurrenceStore);
            if (corpusID != null)
                termIndex.setCorpusId(corpusID);
            if (nbWordAnnos != -1)
                termIndex.setWordAnnotationsNum(nbWordAnnos);
            if (nbSpottedTerms != -1)
                termIndex.setSpottedTermsNum(nbSpottedTerms);

            if (options.isMetadataOnly())
                return termIndex;

        } else if (WORDS.equals(fieldname)) {
            jp.nextToken();
            while ((tok = jp.nextToken()) != JsonToken.END_ARRAY) {
                WordBuilder wordBuilder = WordBuilder.start();
                while ((tok = jp.nextToken()) != JsonToken.END_OBJECT) {
                    fieldname = jp.getCurrentName();
                    if (LEMMA.equals(fieldname))
                        wordBuilder.setLemma(jp.nextTextValue());
                    else if (COMPOUND_TYPE.equals(fieldname))
                        wordBuilder.setCompoundType(CompoundType.fromName(jp.nextTextValue()));
                    else if (STEM.equals(fieldname))
                        wordBuilder.setStem(jp.nextTextValue());
                    else if (COMPONENTS.equals(fieldname)) {
                        while ((tok = jp.nextToken()) != JsonToken.END_ARRAY) {
                            while ((tok = jp.nextToken()) != JsonToken.END_OBJECT) {
                                fieldname = jp.getCurrentName();
                                if (LEMMA.equals(fieldname))
                                    compLemma = jp.nextTextValue();
                                else if (BEGIN.equals(fieldname))
                                    begin = jp.nextIntValue(-2);
                                else if (END.equals(fieldname))
                                    end = jp.nextIntValue(-2);
                            }
                            wordBuilder.addComponent(begin, end, compLemma);
                        }
                    }
                }
                try {
                    termIndex.addWord(wordBuilder.create());
                } catch (Exception e) {
                    LOGGER.error("Could not add word " + wordBuilder.getLemma() + " to term index", e);
                    LOGGER.warn("Error ignored, trying ton continue the loading of TermIndex");
                }
            }
        } else if (TERMS.equals(fieldname)) {
            jp.nextToken();
            while ((tok = jp.nextToken()) != JsonToken.END_ARRAY) {
                TermBuilder builder = TermBuilder.start(termIndex);
                List<TempVecEntry> currentContextVector = Lists.newArrayList();
                int currentTermId = -1;
                while ((tok = jp.nextToken()) != JsonToken.END_OBJECT) {
                    fieldname = jp.getCurrentName();
                    if (GROUPING_KEY.equals(fieldname))
                        builder.setGroupingKey(jp.nextTextValue());
                    else if (SPOTTING_RULE.equals(fieldname))
                        builder.setSpottingRule(jp.nextTextValue());
                    else if (ID.equals(fieldname)) {
                        currentTermId = jp.nextIntValue(-2);
                        builder.setId(currentTermId);
                    } else if (RANK.equals(fieldname)) {
                        builder.setRank(jp.nextIntValue(-1));
                    } else if (FREQUENCY.equals(fieldname)) {
                        builder.setFrequency(jp.nextIntValue(-1));
                    } else {
                        if (FREQ_NORM.equals(fieldname)) {
                            jp.nextToken();
                            builder.setFrequencyNorm((double) jp.getFloatValue());
                        } else if (SPECIFICITY.equals(fieldname)) {
                            jp.nextToken();
                            builder.setSpecificity((double) jp.getDoubleValue());
                        } else if (GENERAL_FREQ_NORM.equals(fieldname)) {
                            jp.nextToken();
                            builder.setGeneralFrequencyNorm((double) jp.getFloatValue());
                        } else if (WORDS.equals(fieldname)) {
                            while ((tok = jp.nextToken()) != JsonToken.END_ARRAY) {
                                wordLemma = null;
                                syntacticLabel = null;
                                while ((tok = jp.nextToken()) != JsonToken.END_OBJECT) {
                                    fieldname = jp.getCurrentName();
                                    if (LEMMA.equals(fieldname))
                                        wordLemma = jp.nextTextValue();
                                    else if (SYN.equals(fieldname))
                                        syntacticLabel = jp.nextTextValue();
                                }
                                Preconditions.checkArgument(wordLemma != null, MSG_EXPECT_PROP_FOR_TERM_WORD,
                                        LEMMA);
                                Preconditions.checkArgument(syntacticLabel != null,
                                        MSG_EXPECT_PROP_FOR_TERM_WORD, SYN);
                                builder.addWord(termIndex.getWord(wordLemma), syntacticLabel);
                            } // end words

                        } else if (OCCURRENCES.equals(fieldname)) {
                            tok = jp.nextToken();
                            if (tok == JsonToken.START_ARRAY) {

                                while ((tok = jp.nextToken()) != JsonToken.END_ARRAY) {
                                    begin = -1;
                                    end = -1;
                                    fileSource = -1;
                                    text = null;
                                    while ((tok = jp.nextToken()) != JsonToken.END_OBJECT) {
                                        fieldname = jp.getCurrentName();
                                        if (BEGIN.equals(fieldname))
                                            begin = jp.nextIntValue(-1);
                                        else if (TEXT.equals(fieldname))
                                            text = jp.nextTextValue();
                                        else if (END.equals(fieldname))
                                            end = jp.nextIntValue(-1);
                                        else if (FILE.equals(fieldname)) {
                                            fileSource = jp.nextIntValue(-1);
                                        }
                                    }

                                    Preconditions.checkArgument(begin != -1, MSG_EXPECT_PROP_FOR_OCCURRENCE,
                                            BEGIN);
                                    Preconditions.checkArgument(end != -1, MSG_EXPECT_PROP_FOR_OCCURRENCE, END);
                                    Preconditions.checkArgument(fileSource != -1,
                                            MSG_EXPECT_PROP_FOR_OCCURRENCE, FILE);
                                    Preconditions.checkNotNull(inputSources.get(fileSource),
                                            "No file source with id: %s", fileSource);
                                    Preconditions.checkNotNull(text, MSG_EXPECT_PROP_FOR_OCCURRENCE, TEXT);
                                    if (occurrenceStore.getStoreType() == OccurrenceStore.Type.MEMORY)
                                        builder.addOccurrence(begin, end,
                                                termIndex.getDocument(inputSources.get(fileSource)), text);
                                }
                            }
                            // end occurrences
                        } else if (CONTEXT.equals(fieldname)) {
                            @SuppressWarnings("unused")
                            int totalCooccs = 0;
                            while ((tok = jp.nextToken()) != JsonToken.END_OBJECT) {
                                fieldname = jp.getCurrentName();
                                if (TOTAL_COOCCURRENCES.equals(fieldname))
                                    /*
                                     * value never used since the total will 
                                     * be reincremented in the contextVector
                                     */
                                    totalCooccs = jp.nextIntValue(-1);
                                else if (CO_OCCURRENCES.equals(fieldname)) {
                                    jp.nextToken();
                                    while ((tok = jp.nextToken()) != JsonToken.END_ARRAY) {
                                        TempVecEntry entry = new TempVecEntry();
                                        while ((tok = jp.nextToken()) != JsonToken.END_OBJECT) {
                                            fieldname = jp.getCurrentName();
                                            if (NB_COCCS.equals(fieldname))
                                                entry.setNbCooccs(jp.nextIntValue(-1));
                                            else if (ASSOC_RATE.equals(fieldname)) {
                                                jp.nextToken();
                                                entry.setAssocRate(jp.getFloatValue());
                                            } else if (CO_TERM.equals(fieldname))
                                                entry.setTermGroupingKey(jp.nextTextValue());
                                            else if (FILE.equals(fieldname)) {
                                                fileSource = jp.nextIntValue(-1);
                                            }
                                        }
                                        currentContextVector.add(entry);
                                    }
                                }
                            }
                        }
                    } //end if fieldname

                } // end term object
                try {
                    builder.createAndAddToIndex();
                } catch (Exception e) {
                    LOGGER.error("Could not add term " + builder.getGroupingKey() + " to term index", e);
                    LOGGER.warn("Error ignored, trying ton continue the loading of TermIndex");
                }

                if (options.isWithContexts())
                    contextVectors.put(currentTermId, currentContextVector);

            } // end array of terms

        } else if (INPUT_SOURCES.equals(fieldname)) {
            jp.nextToken();
            while ((tok = jp.nextToken()) != JsonToken.END_OBJECT) {
                String id = jp.getCurrentName();
                try {
                    inputSources.put(Integer.parseInt(id), jp.nextTextValue());
                } catch (NumberFormatException e) {
                    IOUtils.closeQuietly(jp);
                    throw new IllegalArgumentException("Bad format for input source key: " + id);
                }
            }
        } else if (TERM_VARIATIONS.equals(fieldname)) {
            jp.nextToken();
            while ((tok = jp.nextToken()) != JsonToken.END_ARRAY) {
                base = null;
                variant = null;
                infoToken = null;
                variantType = null;
                variantScore = 0;
                while ((tok = jp.nextToken()) != JsonToken.END_OBJECT) {
                    fieldname = jp.getCurrentName();
                    if (BASE.equals(fieldname))
                        base = jp.nextTextValue();
                    else if (VARIANT.equals(fieldname))
                        variant = jp.nextTextValue();
                    else if (VARIANT_TYPE.equals(fieldname))
                        variantType = jp.nextTextValue();
                    else if (VARIANT_SCORE.equals(fieldname)) {
                        jp.nextToken();
                        variantScore = jp.getDoubleValue();
                    } else if (INFO.equals(fieldname))
                        infoToken = jp.nextTextValue();
                } // end syntactic variant object
                Preconditions.checkNotNull(base, MSG_EXPECT_PROP_FOR_VAR, BASE);
                Preconditions.checkNotNull(variant, MSG_EXPECT_PROP_FOR_VAR, VARIANT);
                Preconditions.checkNotNull(infoToken, MSG_EXPECT_PROP_FOR_VAR, INFO);
                b = termIndex.getTermByGroupingKey(base);
                v = termIndex.getTermByGroupingKey(variant);
                if (b != null && v != null) {

                    VariationType vType = VariationType.fromShortName(variantType);

                    TermVariation tv = new TermVariation(vType, b, v,
                            vType == VariationType.GRAPHICAL ? Double.parseDouble(infoToken) : infoToken);
                    tv.setScore(variantScore);
                    b.addTermVariation(tv);
                } else {
                    if (b == null)
                        LOGGER.warn("Could not build variant because term \"{}\" was not found.", base);
                    if (v == null)
                        LOGGER.warn("Could not build variant because term \"{}\" was not found.", variant);
                }

                //               Preconditions.checkNotNull(b, MSG_TERM_DOES_NOT_EXIST, base);
                //               Preconditions.checkNotNull(v, MSG_TERM_DOES_NOT_EXIST, variant);

            } // end syntactic variations array
        }
    }
    jp.close();

    if (options.isWithContexts()) {
        /*
         *  map term ids with terms in context vectors and
         *  set context vectors
         */
        List<TempVecEntry> currentTempVecList;
        Term term = null;
        Term coTerm = null;
        ContextVector contextVector;
        for (int termId : contextVectors.keySet()) {
            currentTempVecList = contextVectors.get(termId);
            term = termIndex.getTermById(termId);
            contextVector = new ContextVector(term);
            for (TempVecEntry tempVecEntry : currentTempVecList) {
                coTerm = termIndex.getTermByGroupingKey(tempVecEntry.getTermGroupingKey());
                contextVector.addEntry(coTerm, tempVecEntry.getNbCooccs(), tempVecEntry.getAssocRate());
            }
            if (!contextVector.getEntries().isEmpty())
                term.setContextVector(contextVector);
        }
    }

    return termIndex;
}