0

i am trying to run proses_wiki2 but an error occured:

ValueError: not enough values to unpack (expected 2, got 0)

anyone can help?

i use spyder python 3.6, on windows 10.

import logging
import os.path
import sys
import warnings
warnings.filterwarnings(action='ignore', category=UserWarning, 
module='gensim')
from gensim.corpora import WikiCorpus

if __name__ == '__main__':
    program = os.path.basename(sys.argv[0])
    logger = logging.getLogger(program)

    logging.basicConfig(format='%(asctime)s: %(levelname)s: %(message)s')
    logging.root.setLevel(level=logging.INFO)
    logger.info("Running %s", ' '.join(sys.argv))

    if len(sys.argv) < 3:
        print(globals()['__doc__'] % locals())
    inp, outp = sys.argv[1:3]

    wiki = WikiCorpus(inp, lemmatize=False, dictionary={})
    with open(outp, 'w', encoding="utf-8") as output:
        for i, text in enumerate(wiki.get_texts()):
            # Note: if you're using Python 2, use:
            # output.write(" ".join(unicode(text)) + "\n")
            output.write(" ".join(text) + "\n")
            if i > 0 and i % 10000 == 0:
                logger.info("Saved %s articles", i)
            n = i

    logger.info("Finished saving %s articles", n)

This is the message that it shows when I run the program: Traceback (most recent call last):

File "E:/pra tesis/Koding LSTM/proses_wiki2.py", line 18, in inp, outp = sys.argv[1:3]

ValueError: not enough values to unpack (expected 2, got 0)

  • You are supposed to provide command line arguments to the script. – gmds Jun 21 '19 at 08:44
  • Check the length of `sys.argv`, only if it's `3`, you can do `inp, outp = sys.argv[1:3]` to get `sys[1]` to `inp` and `sys[2]` to `outp` – Devesh Kumar Singh Jun 21 '19 at 08:44
  • Possible duplicate of [Error related to input file, ValueError: need more than 1 value to unpack](https://stackoverflow.com/questions/56424976/error-related-to-input-file-valueerror-need-more-than-1-value-to-unpack) – CristiFati Jun 21 '19 at 08:45

0 Answers0