(
    doc: Doc,
    ns: int | Collection[int],
    *,
    include_pos: Optional[str | Collection[str]] = ("NOUN", "PROPN", "ADJ"),
)
Get candidate keyterms from ``doc``, where candidates are n-length sequences
    of tokens (for all n in ``ns``) that don't start/end with a stop word or
    contain punctuation tokens, and whose constituent tokens are filtered by POS tag.

    Args:
        doc
        ns: One or more n values for which to generate n-grams. For example,
            ``2`` gets bigrams; ``(2, 3)`` gets bigrams and trigrams.
        include_pos: One or more POS tags with which to filter ngrams.
            If None, include tokens of all POS tags.

    Yields:
        Next ngram candidate, as a tuple of constituent Tokens.

    See Also:
        :func:`textacy.extract.ngrams()`
Get candidate keyterms from ``doc``, where candidates are n-length sequences
    of tokens (for all n in ``ns``) that don't start/end with a stop word or
    contain punctuation tokens, and whose constituent tokens are filtered by POS tag.
Get candidate keyterms from doc where candidates are n - length sequences of tokens ( for all n in ns ) that don t start / end with a stop word or contain punctuation tokens and whose constituent tokens are filtered by POS tag .
def get_ngram_candidates(
    doc: Doc,
    ns: int | Collection[int],
    *,
    include_pos: Optional[str | Collection[str]] = ("NOUN", "PROPN", "ADJ"),
) -> Iterable[Tuple[Token, ...]]:
    """
    Get candidate keyterms from ``doc``, where candidates are n-length sequences
    of tokens (for all n in ``ns``) that don't start/end with a stop word or
    contain punctuation tokens, and whose constituent tokens are filtered by POS tag.

    Args:
        doc
        ns: One or more n values for which to generate n-grams. For example,
            ``2`` gets bigrams; ``(2, 3)`` gets bigrams and trigrams.
        include_pos: One or more POS tags with which to filter ngrams.
            If None, include tokens of all POS tags.

    Yields:
        Next ngram candidate, as a tuple of constituent Tokens.

    See Also:
        :func:`textacy.extract.ngrams()`
    """
    ns = utils.to_collection(ns, int, tuple)
    include_pos = utils.to_collection(include_pos, str, set)
    ngrams = itertoolz.concat(itertoolz.sliding_window(n, doc) for n in ns)
    ngrams = (
        ngram
        for ngram in ngrams
        if not (ngram[0].is_stop or ngram[-1].is_stop)
        and not any(word.is_punct or word.is_space for word in ngram)
    )
    if include_pos:
        ngrams = (
            ngram for ngram in ngrams if all(word.pos_ in include_pos for word in ngram)
        )
    for ngram in ngrams:
        yield ngram
def get_ngram_candidates ( doc : Doc , ns : int | Collection [ int ] , * , include_pos : Optional [ str | Collection [ str ] ] = ( "NOUN" , "PROPN" , "ADJ" ) , ) -> Iterable [ Tuple [ Token , ... ] ] : ns = utils . to_collection ( ns , int , tuple ) include_pos = utils . to_collection ( include_pos , str , set ) ngrams = itertoolz . concat ( itertoolz . sliding_window ( n , doc ) for n in ns ) ngrams = ( ngram for ngram in ngrams if not ( ngram [ 0 ] . is_stop or ngram [ - 1 ] . is_stop ) and not any ( word . is_punct or word . is_space for word in ngram ) ) if include_pos : ngrams = ( ngram for ngram in ngrams if all ( word . pos_ in include_pos for word in ngram ) ) for ngram in ngrams : yield ngram