def cleanCorpus(src_file, tgt_file, src_cleaned, tgt_cleaned):

    line_cnt = 0
    filt_line_cnt = 0
    sF = open(src_file, 'r')
    tF = open(tgt_file, 'r')
    oF1 = open(src_cleaned, 'w')
    oF2 = open(tgt_cleaned, 'w')

    while True:
        # read source and target lines
        src_line = sF.readline()
        tgt_line = tF.readline()
        if src_line == '' and tgt_line =='': break

        line_cnt += 1
        src_line = src_line.strip()
        tgt_line = tgt_line.strip()
        src_len = len( src_line.split() )
        tgt_len = len( tgt_line.split() )

        if src_len == 0 or src_len > MAX_SENT_LEN: continue
        elif tgt_len == 0 or tgt_len > MAX_SENT_LEN: continue
        else:
            oF1.write( "%s\n" % src_line )
            oF2.write( "%s\n" % tgt_line )
            filt_line_cnt += 1

    sF.close()
    tF.close()
    oF1.close()
    oF2.close()

    print "# of lines in corpus before cleaning : %d" % line_cnt
    print "# of lines in corpus after cleaning  : %d" % filt_line_cnt
    print (line_cnt - filt_line_cnt) % "# of lines ignored in cleaning       : %d"
    return None
dataset/ETHPy150Open sfu-natlang/Kriya/src/Kriya-Grammar-Xtrctr/pre-process/clean_corpus.py/cleanCorpus/swapped operands of `%`