jina.types.score.map module

class jina.types.score.map.NamedScoreMapping(scores)[source]

Bases: collections.abc.MutableMapping

NamedScoreMapping is one of the primitive data type in Jina.

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

It offers an interface to access and update scores as NamedScore as values of a dict with a string key.

To create a NamedScoreMappingProto object, simply:

from jina.types.score.map import NamedScoreMapping
scores = NamedScoreMapping()
scores['score'] = 50

NamedScoreMapping can be built from jina_pb2.NamedScoreMappingProto (as a weak reference or a deep copy)

  • scores (MessageMapContainer) – The scores to construct from, depending on the copy, it builds a view or a copy from it.

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

  • kwargs – Other parameters to be set