e0830d7736bb620f926545078bea5620a8b4a19c,src/gensim/utils.py,,isCorpus,#Any#,199

Before Change


    **NOTE**: When called on an empty corpus (no documents), will return False.
    
    try:
        if hasattr(obj, "next"):
            return False // iterators are not allowed to be corpora (need an iterable)
        doc1 = iter(obj).next() // obj supports iteration and is not empty
        if len(doc1) == 0: // the first document is empty
            return True
        id1, val1 = iter(doc1).next() // or the first document is a 2-tuple
        id1, val1 = int(id1), float(val1) // id must be an integer, weight a float

After Change


    result is forcefully defined as `is_corpus=False`.
    
    try:
        if hasattr(obj, "next"):
            if hasattr(obj, "__iter__"):
                logger.warning("corpus-testing objects that are both iterators and iterables is ambiguous; assuming iterator (one-pass).")
            // the input is an iterator (not iterable), meaning once we call next()
            // that element is gone forever. we must be careful to put whatever we
            // retrieve back again
            doc1 = obj.next()
            obj = itertools.chain([doc1], obj)
        else:
            doc1 = iter(obj).next()
        if not list(doc1):
            return True, obj // the first document is empty, assume this is a corpus
        id1, val1 = iter(doc1).next()
        id1, val1 = int(id1), float(val1) // must be a 2-tuple (integer, float)
Italian Trulli
In pattern: SUPERPATTERN

Frequency: 3

Non-data size: 7

Instances


Project Name: RaRe-Technologies/gensim
Commit Name: e0830d7736bb620f926545078bea5620a8b4a19c
Time: 2010-09-06
Author: piskvorky@92d0401f-a546-4972-9173-107b360ed7e5
File Name: src/gensim/utils.py
Class Name:
Method Name: isCorpus


Project Name: RaRe-Technologies/gensim
Commit Name: f96837d570ed738baa0f47924cfa09f40787cdbe
Time: 2010-09-06
Author: radimrehurek@seznam.cz
File Name: src/gensim/utils.py
Class Name:
Method Name: isCorpus


Project Name: dmlc/gluon-nlp
Commit Name: 03b0e7061cf477fbeccb9c128ee76603df582d86
Time: 2018-09-04
Author: leonard@lausen.nl
File Name: scripts/word_embeddings/evaluate_pretrained.py
Class Name:
Method Name: