jina.types.score package


Module contents

class jina.types.score.NamedScore(score=None, copy=False, **kwargs)[source]

Bases: jina.types.mixin.ProtoTypeMixin

NamedScore is one of the primitive data type in Jina.

It offers a Pythonic interface to allow users access and manipulate jina.jina_pb2.NamedScoreProto object without working with Protobuf itself.

To create a NamedScore object, simply:

from jina.types.score import NamedScore
score = NamedScore()
score.value = 10.0

NamedScore can be built from jina_pb2.NamedScoreProto (as a weak reference or a deep copy) or from a set of attributes from jina_pb2.NamedScoreProto passed to the constructor.

from jina.types.score import NamedScore
from jina_pb2 import NamedScoreProto
score = NamedScore(value=10.0, op_name='ranker', description='score computed by ranker')

score_proto = NamedScoreProto()
score_proto.value = 10.0
score = NamedScore(score_proto)
  • score (Optional[jina_pb2.NamedScoreProto]) – The score to construct from, depending on the copy, it builds a view or a copy from it.

  • copy (bool) – When score is given as a NamedScoreProto object, build a view (i.e. weak reference) from it or a deep copy from it.

  • kwargs – Other parameters to be set

property value: float

Return the value of this NamedScore, the id of which this NamedScore is a score. :rtype: float :return:: the score value

property ref_id: str

Return the ref_id of this NamedScore, the id of which this NamedScore is a score. :rtype: str :return:: the ref_id

property op_name: str

Return the op_name of this NamedScore :rtype: str :return:: the op_name

property description: str

Return the description of this NamedScore :rtype: str :return:: the description

property operands: List[jina.types.score.NamedScore]

Returns list of nested NamedScore operands. :rtype: List[NamedScore] :return:: list of nested NamedScore operands.


Udate NamedScore fields with key-value specified in kwargs.


kwargs – Key-value parameters to be set