示例#1
0
 def create(self):
     doc = Document()
     if field_type == 'text':
         doc.text = 'aaa'
     elif field_type == 'buffer':
         doc.buffer = b'\x01\x02\x03'
     elif field_type == 'blob':
         doc.blob = np.array([1, 1, 1])
     return doc
示例#2
0
 def create(self):
     gt = Document()
     if field_type == 'text':
         gt.text = 'aaaa'
     elif field_type == 'buffer':
         gt.buffer = b'\x01\x02\x03\04'
     elif field_type == 'blob':
         gt.blob = np.array([1, 1, 1, 1])
     return gt
示例#3
0
 def request(field_type):
     num_docs = 10
     req = jina_pb2.RequestProto()
     for idx in range(num_docs):
         doc = req.index.docs.add()
         gt = req.index.groundtruths.add()
         chunk_doc = Document(doc.chunks.add())
         chunk_gt = Document(gt.chunks.add())
         chunk_doc.granularity = 1
         chunk_gt.granularity = 1
         if field_type == 'text':
             chunk_doc.text = 'aaa'
             chunk_gt.text = 'aaaa'
         elif field_type == 'buffer':
             chunk_doc.buffer = b'\x01\x02\x03'
             chunk_gt.buffer = b'\x01\x02\x03\x04'
         elif field_type == 'blob':
             chunk_doc.blob = np.array([1, 1, 1])
             chunk_gt.blob = np.array([1, 1, 1, 1])
     return Request(req).as_typed_request('index')