f96837d570ed738baa0f47924cfa09f40787cdbe,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

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: 6

Instances


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: 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: pgmpy/pgmpy
Commit Name: daa7947850ea7df6763ec076548ae4b372ee3fb9
Time: 2015-03-25
Author: pratyaksh@me.com
File Name: pgmpy/inference/ExactInference.py
Class Name: VariableElimination
Method Name: induced_graph