def _NewDocumentFromPb(doc_pb):
 lang = None
 if doc_pb.has_language():
  lang = _DecodeUTF8(doc_pb.language())
 return Document(doc_id=_DecodeUTF8(doc_pb.id()), fields=_NewFieldsFromPb(doc_pb.field_list()), language=lang, rank=doc_pb.order_id())

def _NewDocumentFromPb ( doc_pb ) : lang = None if doc_pb . has_language ( ) : lang = _DecodeUTF8 ( doc_pb . language ( ) ) return Document ( doc_id = _DecodeUTF8 ( doc_pb . id ( ) ) , fields = _NewFieldsFromPb ( doc_pb . field_list ( ) ) , language = lang , rank = doc_pb . order_id ( ) )
constructs a document from a document_pb .