Project

General

Profile

« Previous | Next » 

Revision 4626

canon, translate, filter_out_ci: Support vocabularies/dictionaries with additional columns in addition to the functional column(s) used by the program. These columns can contain comments, etc. This was not originally supported because Python 2's iterable unpacking only supports "an iterable with the same number of items as there are targets in the target list" (http://docs.python.org/reference/simple_stmts.html#assignment-statements). We now use numeric array indexes instead to get around this limitation, and for consistency with other map-manipulation scripts.

View differences:

bin/filter_out_ci
19 19
    stream = open(vocab_path, 'rb')
20 20
    reader = csv.reader(stream)
21 21
    reader.next() # skip header
22
    for term, in reader: vocab.add(simplify(term))
22
    for row in reader: vocab.add(simplify(row[0]))
23 23
    stream.close()
24 24
    
25 25
    # Filter input
bin/translate
18 18
    stream = open(dict_path, 'rb')
19 19
    reader = csv.reader(stream)
20 20
    reader.next() # skip header
21
    for from_, to in reader: dict_[from_] = to
21
    for row in reader: dict_[row[0]] = row[1]
22 22
    stream.close()
23 23
    
24 24
    # Translate input
bin/canon
21 21
    stream = open(vocab_path, 'rb')
22 22
    reader = csv.reader(stream)
23 23
    reader.next() # skip header
24
    for term, in reader: dict_[simplify(term)] = term
24
    for row in reader: dict_[simplify(row[0])] = row[0]
25 25
    stream.close()
26 26
    
27 27
    # Canonicalize input

Also available in: Unified diff