All Downloads are FREE. Search and download functionalities are using the official Maven repository.

com.basistech.rosette.dm.jackson.array.AnnotatedTextArrayMixin Maven / Gradle / Ivy

The newest version!
/*
* Copyright 2014 Basis Technology Corp.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
* distributed under the License is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
* See the License for the specific language governing permissions and
* limitations under the License.
*/

package com.basistech.rosette.dm.jackson.array;

import com.basistech.rosette.dm.BaseAttribute;
import com.basistech.rosette.dm.BaseNounPhrase;
import com.basistech.rosette.dm.CategorizerResult;
import com.basistech.rosette.dm.Dependency;
import com.basistech.rosette.dm.Entity;
import com.basistech.rosette.dm.Keyphrase;
import com.basistech.rosette.dm.LanguageDetection;
import com.basistech.rosette.dm.LayoutRegion;
import com.basistech.rosette.dm.ListAttribute;
import com.basistech.rosette.dm.RelationshipMention;
import com.basistech.rosette.dm.ScriptRegion;
import com.basistech.rosette.dm.Sentence;
import com.basistech.rosette.dm.Token;
import com.basistech.rosette.dm.Concept;
import com.basistech.rosette.dm.TranslatedData;
import com.basistech.rosette.dm.TranslatedTokens;
import com.basistech.rosette.dm.jackson.DmTypeIdResolver;
import com.basistech.rosette.dm.jackson.VersionCheckDeserializer;
import com.basistech.rosette.dm.jackson.VersionProperty;
import com.fasterxml.jackson.annotation.JsonCreator;
import com.fasterxml.jackson.annotation.JsonFormat;
import com.fasterxml.jackson.annotation.JsonIgnore;
import com.fasterxml.jackson.annotation.JsonProperty;
import com.fasterxml.jackson.annotation.JsonTypeInfo;
import com.fasterxml.jackson.databind.annotation.JsonAppend;
import com.fasterxml.jackson.databind.annotation.JsonDeserialize;
import com.fasterxml.jackson.databind.annotation.JsonSerialize;
import com.fasterxml.jackson.databind.annotation.JsonTypeIdResolver;
import com.fasterxml.jackson.databind.ser.std.ToStringSerializer;

import java.util.List;
import java.util.Map;

/**
 * {@link com.basistech.rosette.dm.AnnotatedText}.
 */
@JsonFormat(shape = JsonFormat.Shape.ARRAY)
@JsonAppend(props = { @JsonAppend.Prop(value = VersionProperty.class, name = "version")})
@SuppressWarnings("deprecated")
public abstract class AnnotatedTextArrayMixin {

    @JsonCreator
    AnnotatedTextArrayMixin(@JsonProperty("data") CharSequence data,
                            @JsonProperty("attributes") Map attributes,
                            @JsonProperty("documentMetadata") Map> documentMetadata,
                            @JsonDeserialize(using = VersionCheckDeserializer.class)
                            @JsonProperty("version") String version) {
        //
    }

    // The first two work right for deserialization but not for serialization, so we have the third.
    @JsonTypeInfo(use = JsonTypeInfo.Id.CUSTOM, include = JsonTypeInfo.As.WRAPPER_ARRAY)
    @JsonTypeIdResolver(DmTypeIdResolver.class)
    @JsonSerialize(using = TempAttributeMapSerializer.class)
    public abstract Map getAttributes();

    /* prevent Jackson from serializing a complex object here. */
    @JsonSerialize(using = ToStringSerializer.class)
    public abstract CharSequence getData();

    @JsonIgnore
    public abstract ListAttribute getTokens();

    @JsonIgnore
    public abstract ListAttribute getTranslatedData();

    @JsonIgnore
    public abstract ListAttribute getTranslatedTokens();

    @SuppressWarnings("deprecation")
    @JsonIgnore
    public abstract ListAttribute getEntityMentions();

    @SuppressWarnings("deprecation")
    @JsonIgnore
    public abstract ListAttribute getResolvedEntities();

    @JsonIgnore
    public abstract ListAttribute getRelationshipMentions();

    @JsonIgnore
    public abstract ListAttribute getScriptRegions();

    @JsonIgnore
    public abstract ListAttribute getSentences();

    @JsonIgnore
    public abstract ListAttribute getLayoutRegions();

    @JsonIgnore
    public abstract ListAttribute getBaseNounPhrases();

    @JsonIgnore
    public abstract ListAttribute getLanguageDetectionRegions();

    @JsonIgnore
    public abstract LanguageDetection getWholeTextLanguageDetection();

    @JsonIgnore
    public abstract ListAttribute getCategorizerResults();

    @JsonIgnore
    public abstract ListAttribute getSentimentResults();

    @JsonIgnore
    public abstract ListAttribute getTopicResults();

    @JsonIgnore
    public abstract ListAttribute getEntities();

    @JsonIgnore
    public abstract ListAttribute getDependencies();

    @JsonIgnore
    public abstract ListAttribute getConcepts();

    @JsonIgnore
    public abstract ListAttribute getKeyphrases();
}




© 2015 - 2024 Weber Informatics LLC | Privacy Policy