nut icon indicating copy to clipboard operation
nut copied to clipboard

indent error

Open siegfang opened this issue 11 years ago • 2 comments

Hi! There have some indent miss in the code file, when I download the entire project, like nut/bow.py L39:

    for fname in bowfnames:
        with open(fname) as f:
        for i, line in enumerate(f):
        if maxlines != -1 and i >= maxlines:
            break
        label, tokens = parse_bow(line)
        for token,freq in tokens:
            fd[token] += 1

other files have the same error: bow.py: L63 pivotselection: L80, L102, L117, L136 util.py: L54, L71, L74

siegfang avatar May 21 '14 06:05 siegfang

hmm... this is strange - looks ok on github - maybe tabs? what error do you get when you run the Python interpreter?

pprett avatar May 21 '14 07:05 pprett

Well, after I download the code from the GitHub, the diference was found when I compare with the code presented in the GitHub page. I got the following error while running the interpreter:

Traceback (most recent call last):
  File "clscl_train.py", line 7, in <module>
    import nut.structlearn.clscl
  File "Z:\CodeSpace\Python\crossLing\nut-master-py2\nut\structlearn\clscl.py",
line 29, in <module>
    from ..bow import vocabulary, disjoint_voc, load
  File "Z:\CodeSpace\Python\crossLing\nut-master-py2\nut\bow.py", line 39
    for i, line in enumerate(f):
      ^
IndentationError: expected an indented block

if you examine the number of the tab and space, you can find some error. For exampe, use "→" and "--" to note the tab and 4 space in the code. When select the space before the "for" in bow.py#L39, you may found there miss a indent.

--for fname in bowfnames:
----with open(fname) as f:
→--for i, line in enumerate(f):
→→if maxlines != -1 and i >= maxlines:
→→--break
→→label, tokens = parse_bow(line)
→→for token,freq in tokens:
→→--fd[token] += 1

siegfang avatar May 22 '14 01:05 siegfang