docarray.simple.score module

class docarray.simple.score.NamedScore(obj=None, copy=False, **kwargs)[source]

Bases: docarray.base.BaseProtoView

NamedScore is one of the primitive data type in Jina.

It offers a Pythonic interface to allow users access and manipulate jina.docarray_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 docarray_pb2.NamedScoreProto (as a weak reference or a deep copy) or from a set of attributes from docarray_pb2.NamedScoreProto passed to the constructor.

from jina.types.score import NamedScore
from docarray_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)
Parameters
  • score (Optional[docarray_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.

Return type

float

Returns

the score value

property ref_id: str

Return the ref_id of this NamedScore, the id of which this NamedScore is a score.

Return type

str

Returns

the ref_id

property op_name: str

Return the op_name of this NamedScore

Return type

str

Returns

the op_name

property description: str

Return the description of this NamedScore

Return type

str

Returns

the description

property operands: List[docarray.simple.score.NamedScore]

Returns list of nested NamedScore operands.

Return type

List[NamedScore]

Returns

list of nested NamedScore operands.