# -*- coding: utf-8 -*-
#
# Autogenerated by Thrift Compiler (0.11.0)
#
# DO NOT EDIT UNLESS YOU ARE SURE THAT YOU KNOW WHAT YOU ARE DOING
#
#  options string: py:coding=utf-8
#

from thrift.Thrift import TType, TMessageType, TFrozenDict, TException, TApplicationException
from thrift.protocol.TProtocol import TProtocolException
from thrift.TRecursive import fix_spec

import sys
import concrete.communication.ttypes
import concrete.services.ttypes
import concrete.structure.ttypes
import concrete.uuid.ttypes

from thrift.transport import TTransport
all_structs = []


class SummarySourceType(object):
    DOCUMENT = 0
    TOKENIZATION = 1
    ENTITY = 2

    _VALUES_TO_NAMES = {
        0: "DOCUMENT",
        1: "TOKENIZATION",
        2: "ENTITY",
    }

    _NAMES_TO_VALUES = {
        "DOCUMENT": 0,
        "TOKENIZATION": 1,
        "ENTITY": 2,
    }


class SummarizationRequest(object):
    """
    A request to summarize which specifies the length of the desired
    summary and the text data to be summarized.
    Either set sourceCommunication or sourceType and sourceIds.

    Attributes:
     - queryTerms: Terms or features pertinent to the query.
    Can be empty, meaning summarize all source material with
    no a priori beliefs about what is important to summarize.
     - maximumTokens: Limit on how long the returned summary can be in tokens.
     - maximumCharacters: Limit on how long the returned summary can be in characters.
     - sourceType: How to interpret the ids in sourceIds.
    May be null is sourceIds is null, otherwise must be populated.
     - sourceIds: A list of concrete object ids which serve as the material
    to summarize.
     - sourceCommunication: Alternative to sourceIds+sourceType: provide a Communication
    of text to summarize.
    """


    def __init__(self, queryTerms=None, maximumTokens=None, maximumCharacters=None, sourceType=None, sourceIds=None, sourceCommunication=None,):
        self.queryTerms = queryTerms
        self.maximumTokens = maximumTokens
        self.maximumCharacters = maximumCharacters
        self.sourceType = sourceType
        self.sourceIds = sourceIds
        self.sourceCommunication = sourceCommunication

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.LIST:
                    self.queryTerms = []
                    (_etype3, _size0) = iprot.readListBegin()
                    for _i4 in range(_size0):
                        _elem5 = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                        self.queryTerms.append(_elem5)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.I32:
                    self.maximumTokens = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.I32:
                    self.maximumCharacters = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 4:
                if ftype == TType.I32:
                    self.sourceType = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 5:
                if ftype == TType.LIST:
                    self.sourceIds = []
                    (_etype9, _size6) = iprot.readListBegin()
                    for _i10 in range(_size6):
                        _elem11 = concrete.uuid.ttypes.UUID()
                        _elem11.read(iprot)
                        self.sourceIds.append(_elem11)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            elif fid == 6:
                if ftype == TType.STRUCT:
                    self.sourceCommunication = concrete.communication.ttypes.Communication()
                    self.sourceCommunication.read(iprot)
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('SummarizationRequest')
        if self.queryTerms is not None:
            oprot.writeFieldBegin('queryTerms', TType.LIST, 1)
            oprot.writeListBegin(TType.STRING, len(self.queryTerms))
            for iter12 in self.queryTerms:
                oprot.writeString(iter12.encode('utf-8') if sys.version_info[0] == 2 else iter12)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.maximumTokens is not None:
            oprot.writeFieldBegin('maximumTokens', TType.I32, 2)
            oprot.writeI32(self.maximumTokens)
            oprot.writeFieldEnd()
        if self.maximumCharacters is not None:
            oprot.writeFieldBegin('maximumCharacters', TType.I32, 3)
            oprot.writeI32(self.maximumCharacters)
            oprot.writeFieldEnd()
        if self.sourceType is not None:
            oprot.writeFieldBegin('sourceType', TType.I32, 4)
            oprot.writeI32(self.sourceType)
            oprot.writeFieldEnd()
        if self.sourceIds is not None:
            oprot.writeFieldBegin('sourceIds', TType.LIST, 5)
            oprot.writeListBegin(TType.STRUCT, len(self.sourceIds))
            for iter13 in self.sourceIds:
                iter13.write(oprot)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        if self.sourceCommunication is not None:
            oprot.writeFieldBegin('sourceCommunication', TType.STRUCT, 6)
            self.sourceCommunication.write(oprot)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)


class SummaryConcept(object):
    """
    A mention of a concept described in a summary which is thought
    to be informative. Concepts might be named entities, facts, or
    events which were determined to be salient in the text being
    summarized.

    Attributes:
     - tokens: Location in summaryCommunication of this concept
     - concept: Short description of the concept being evoked, e.g. "kbrel:bornIn" or "related:ACME_Corp"
     - confidence: How confident is the system that this concept was evoked by this mention, in [0,1]
     - utility: How informative/important it is that this concept be included in the summary (non-negative).
    """


    def __init__(self, tokens=None, concept=None, confidence=1, utility=1,):
        self.tokens = tokens
        self.concept = concept
        self.confidence = confidence
        self.utility = utility

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.STRUCT:
                    self.tokens = concrete.structure.ttypes.TokenRefSequence()
                    self.tokens.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRING:
                    self.concept = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            elif fid == 3:
                if ftype == TType.DOUBLE:
                    self.confidence = iprot.readDouble()
                else:
                    iprot.skip(ftype)
            elif fid == 4:
                if ftype == TType.DOUBLE:
                    self.utility = iprot.readDouble()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('SummaryConcept')
        if self.tokens is not None:
            oprot.writeFieldBegin('tokens', TType.STRUCT, 1)
            self.tokens.write(oprot)
            oprot.writeFieldEnd()
        if self.concept is not None:
            oprot.writeFieldBegin('concept', TType.STRING, 2)
            oprot.writeString(self.concept.encode('utf-8') if sys.version_info[0] == 2 else self.concept)
            oprot.writeFieldEnd()
        if self.confidence is not None:
            oprot.writeFieldBegin('confidence', TType.DOUBLE, 3)
            oprot.writeDouble(self.confidence)
            oprot.writeFieldEnd()
        if self.utility is not None:
            oprot.writeFieldBegin('utility', TType.DOUBLE, 4)
            oprot.writeDouble(self.utility)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)


class Summary(object):
    """
    A shortened version of some text, possibly with some concepts
    annotated as justifications for why particular pieces of the
    summary were kept.

    Attributes:
     - summaryCommunication: Contains the text of the generated summary.
     - concepts: Concepts mentioned in the summary which are believed to be
    interesting and/or worth highlighting.
    """


    def __init__(self, summaryCommunication=None, concepts=None,):
        self.summaryCommunication = summaryCommunication
        self.concepts = concepts

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.STRUCT:
                    self.summaryCommunication = concrete.communication.ttypes.Communication()
                    self.summaryCommunication.read(iprot)
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.LIST:
                    self.concepts = []
                    (_etype17, _size14) = iprot.readListBegin()
                    for _i18 in range(_size14):
                        _elem19 = SummaryConcept()
                        _elem19.read(iprot)
                        self.concepts.append(_elem19)
                    iprot.readListEnd()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('Summary')
        if self.summaryCommunication is not None:
            oprot.writeFieldBegin('summaryCommunication', TType.STRUCT, 1)
            self.summaryCommunication.write(oprot)
            oprot.writeFieldEnd()
        if self.concepts is not None:
            oprot.writeFieldBegin('concepts', TType.LIST, 2)
            oprot.writeListBegin(TType.STRUCT, len(self.concepts))
            for iter20 in self.concepts:
                iter20.write(oprot)
            oprot.writeListEnd()
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)


class SummarizationCapability(object):
    """
    Attributes:
     - type
     - lang
    """


    def __init__(self, type=None, lang=None,):
        self.type = type
        self.lang = lang

    def read(self, iprot):
        if iprot._fast_decode is not None and isinstance(iprot.trans, TTransport.CReadableTransport) and self.thrift_spec is not None:
            iprot._fast_decode(self, iprot, [self.__class__, self.thrift_spec])
            return
        iprot.readStructBegin()
        while True:
            (fname, ftype, fid) = iprot.readFieldBegin()
            if ftype == TType.STOP:
                break
            if fid == 1:
                if ftype == TType.I32:
                    self.type = iprot.readI32()
                else:
                    iprot.skip(ftype)
            elif fid == 2:
                if ftype == TType.STRING:
                    self.lang = iprot.readString().decode('utf-8') if sys.version_info[0] == 2 else iprot.readString()
                else:
                    iprot.skip(ftype)
            else:
                iprot.skip(ftype)
            iprot.readFieldEnd()
        iprot.readStructEnd()

    def write(self, oprot):
        if oprot._fast_encode is not None and self.thrift_spec is not None:
            oprot.trans.write(oprot._fast_encode(self, [self.__class__, self.thrift_spec]))
            return
        oprot.writeStructBegin('SummarizationCapability')
        if self.type is not None:
            oprot.writeFieldBegin('type', TType.I32, 1)
            oprot.writeI32(self.type)
            oprot.writeFieldEnd()
        if self.lang is not None:
            oprot.writeFieldBegin('lang', TType.STRING, 2)
            oprot.writeString(self.lang.encode('utf-8') if sys.version_info[0] == 2 else self.lang)
            oprot.writeFieldEnd()
        oprot.writeFieldStop()
        oprot.writeStructEnd()

    def validate(self):
        if self.type is None:
            raise TProtocolException(message='Required field type is unset!')
        if self.lang is None:
            raise TProtocolException(message='Required field lang is unset!')
        return

    def __repr__(self):
        L = ['%s=%r' % (key, value)
             for key, value in self.__dict__.items()]
        return '%s(%s)' % (self.__class__.__name__, ', '.join(L))

    def __eq__(self, other):
        return isinstance(other, self.__class__) and self.__dict__ == other.__dict__

    def __ne__(self, other):
        return not (self == other)
all_structs.append(SummarizationRequest)
SummarizationRequest.thrift_spec = (
    None,  # 0
    (1, TType.LIST, 'queryTerms', (TType.STRING, 'UTF8', False), None, ),  # 1
    (2, TType.I32, 'maximumTokens', None, None, ),  # 2
    (3, TType.I32, 'maximumCharacters', None, None, ),  # 3
    (4, TType.I32, 'sourceType', None, None, ),  # 4
    (5, TType.LIST, 'sourceIds', (TType.STRUCT, [concrete.uuid.ttypes.UUID, None], False), None, ),  # 5
    (6, TType.STRUCT, 'sourceCommunication', [concrete.communication.ttypes.Communication, None], None, ),  # 6
)
all_structs.append(SummaryConcept)
SummaryConcept.thrift_spec = (
    None,  # 0
    (1, TType.STRUCT, 'tokens', [concrete.structure.ttypes.TokenRefSequence, None], None, ),  # 1
    (2, TType.STRING, 'concept', 'UTF8', None, ),  # 2
    (3, TType.DOUBLE, 'confidence', None, 1, ),  # 3
    (4, TType.DOUBLE, 'utility', None, 1, ),  # 4
)
all_structs.append(Summary)
Summary.thrift_spec = (
    None,  # 0
    (1, TType.STRUCT, 'summaryCommunication', [concrete.communication.ttypes.Communication, None], None, ),  # 1
    (2, TType.LIST, 'concepts', (TType.STRUCT, [SummaryConcept, None], False), None, ),  # 2
)
all_structs.append(SummarizationCapability)
SummarizationCapability.thrift_spec = (
    None,  # 0
    (1, TType.I32, 'type', None, None, ),  # 1
    (2, TType.STRING, 'lang', 'UTF8', None, ),  # 2
)
fix_spec(all_structs)
del all_structs
