# jina.executors.crafters¶

class jina.executors.crafters.BaseCrafter(*args, **kwargs)[source]

A BaseCrafter transforms the content of DocumentProto or Chunk. It can be used for preprocessing, segmenting etc. It is an interface for Crafters which is a family of executors intended to apply transformations to single documents. The apply function is craft(), where the name of the arguments will be used as keys of the content.

craft(*args, **kwargs)[source]

The apply function of this executor. The name of the arguments are used as keys, which are then used to tell Driver what information to extract from the protobuf request accordingly. Therefore the name of the arguments should be always valid keys defined in the protobuf.

Return type

Dict

class jina.executors.crafters.BaseSegmenter(*args, **kwargs)[source]

BaseSegmenter works on doc-level, it receives value on the doc-level and returns new value on the chunk-level

craft(*args, **kwargs)[source]

The apply function of this executor. Unlike BaseCrafter, the craft() here works on doc-level info and the output is defined on chunk-level. Therefore the name of the arguments should be always valid keys defined in the doc-level protobuf whereas the output dict keys should always be valid keys defined in the chunk-level protobuf. :rtype: List[Dict] :return: a list of chunks-level info represented by a dict