ejh243 / MunroeJargonProfiler

web app to analyse the jargon content of a text document
MIT License
1 stars 0 forks source link

Improve get_common loop #22

Closed rgaiacs closed 7 years ago

rgaiacs commented 7 years ago

We can improve

def get_common():  
    '''
    Opens the text file containing the list of 1000 most common words found at
    http://www.ef.co.uk/english-resources/english-vocabulary/top-1000-words/
    removes the newlines and returns them as a list.
    '''
    text = []
    with open('1000common.txt', 'r') as f:
        raw_text = f.readlines()
        for line in raw_text:
            if line.endswith('\n'):
                text.append(line[0:-1])
            else:
                text.append(line)
    return text

by using

    with open('1000common.txt', 'r') as f:
        for line in f:
            if line.endswith('\n'):
                text.append(line[0:-1])
            else:
                text.append(line)
    return text

@etattershall I will let you make the change.

etattershall commented 7 years ago

I've put it in