'Constructs a Document from a document_pb.Document protocol buffer.'

def _NewScoredDocumentFromPb(self, doc_pb, sort_scores, expressions, cursor):

    lang = None
    if doc_pb.has_language():
        lang = _DecodeUTF8(doc_pb.language())
    return ScoredDocument(doc_id=_DecodeUTF8(doc_pb.id()), fields=_NewFieldsFromPb(doc_pb.field_list()), facets=_NewFacetsFromPb(doc_pb.facet_list()), language=lang, rank=doc_pb.order_id(), sort_scores=sort_scores, expressions=_NewFieldsFromPb(expressions), cursor=cursor)
