Please use a sensible subject and don;t reporst the whole digest.
"Dan Liang" <danlian...@gmail.com> wrote in message
Thank you for your help. I have been working on the file, but I still
have a
problem doing what I wanted. As a reminder,
Can you tell us what exactly the problem is? It's easier than us
trying to guess.
#!usr/bin/python
tags = {
'noun-prop': 'noun_prop null null'.split(),
'case_def_gen': 'case_def gen null'.split(),
'dem_pron_f': 'dem_pron f null'.split(),
'case_def_acc': 'case_def acc null'.split(),
}
TAB = '\t'
def newlyTaggedWord(line):
(word,tag) = line.split(TAB) # separate parts of line, keeping
new_tags = tags[tag] # read in dict
tagging = TAB.join(new_tags) # join with TABs
return word + TAB + tagging # formatted result
def replaceTagging(source_name, target_name):
target_file = open(target_name, "w")
# replacement loop
for line in open(source_name, "r"):
new_line = newlyTaggedWord(line) + '\n'
target_file.write(new_line)
target_file.close()
if __name__ == "__main__":
source_name = sys.argv[1]
target_name = sys.argv[2]
replaceTagging(source_name, target_name)
_______________________________________________
Tutor maillist - Tutor@python.org
http://mail.python.org/mailman/listinfo/tutor