[Tutor] comparing files
Kent_Johnson at skillsoft.com
Thu Sep 16 04:40:43 CEST 2004
The easiest way to speed up the search of the English word list is to put it in a dictionary (or set) instead of a list. Searching a long list can slow your program down a lot.
Another way to approach the problem would be to see if any of the original French words appear in the English text.
From: tutor-bounces at python.org on behalf of Brian van den Broek
3) for each element in the MT output word list, check if it is in the
reference word list. That will need a for loop and the in keyword. Using
if test, augment appropriate counters as you go.
There are several ways that I can think of where you could speed this up,
and surely a good many more that I haven't seen. For instance, once you
get something like that going, you might think about breaking the standard
word list up into sub-lists, one for words that start with 'a', etc. (This
would reduce how many comparisons you have to make for each word.) You
might also look to serialize (or store) those canonical word lists to save
the step of constructing them each time. But, once you've got it done as I
outline above, you should be well on your way to knowing how to improve it
in these or other ways.
More information about the Tutor