(doc: Doc)
return f'Doc({len(doc)} tokens: "{snippet}")'
Get a short preview of ``doc``, including the number of tokens and a snippet.
    Typically used as a custom extension, like ``doc._.preview`` .
Get a short preview of ``doc``, including the number of tokens and a snippet.
    Typically used as a custom extension, like ``doc._.preview`` .
Get a short preview of doc including the number of tokens and a snippet . Typically used as a custom extension like doc . _ . preview .
def get_doc_preview(doc: Doc) -> str:
    """
    Get a short preview of ``doc``, including the number of tokens and a snippet.
    Typically used as a custom extension, like ``doc._.preview`` .
    """
    snippet = doc.text[:50].replace("\n", " ")
    if len(snippet) == 50:
        snippet = snippet[:47] + "..."
    return f'Doc({len(doc)} tokens: "{snippet}")'
def get_doc_preview ( doc : Doc ) -> str : snippet = doc . text [ : 50 ] . replace ( "\n" , " " ) if len ( snippet ) == 50 : snippet = snippet [ : 47 ] + "..." return f'Doc({len(doc)} tokens: "{snippet}")'