Skip to content

Improve findWrapper #28

@lsrdg

Description

@lsrdg

The find functionality is the base of the local searches and should be improved.

As of today it looks like this:

def findWrapper(inLanguageF, termInArgF):
    """
    Wrapper for the `find` functionality.
    Make use of the 'sentences.csv' file to to find a sentence containing
    a term in an language.
    """

    # findWrapper variables
    with open(realPath + '/sentences.csv') as listFile:
        readList = csv.reader(listFile, delimiter='\t')

        def findTermInLang():
            """
            function responsible for making the search AND looping the matches.
            """
            foundedTerm = [
                row
                for row in readList
                if row[1] == inLanguageF and termInArgF in row[2]
            ]

            for row in foundedTerm:
                print(row)

        findTermInLang()

This function, as far as I can see should iterate and return values as needed, not as huuuuge loop (sentences.csv is 6195641 lines long...).

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions