[Tutor] Replacing fields in lines of various lengths

2009-05-04 Thread Dan Liang
(Please disregard my earlier message that was sent by mistake before I finished composing. Sorry about that! :(). Hello Spir, Alan, and Paul, and tutors, Thank you Spir, Alan, and Paul for your help with my previous code! Earlier, I was asking how to separate a composite tag like the one in field

Re: [Tutor] Tutor Digest, Vol 63, Issue 8

2009-05-04 Thread Dan Liang
Hello Spir, Alan, and Paul, 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, I have #!usr/bin/python tags = { 'noun-prop': 'noun_prop null null'.split(), 'case_def_gen': 'case_def gen null'.split(), 'dem_pron_f': 'dem_pron

Re: [Tutor] Iterating over a long list with regular expressions and changing each item?

2009-05-04 Thread Dan Liang
--- Traceback (most recent call last): File "tag.formatter.py", line 36, in ? replaceTagging(source_name, target_name) File "tag.formatter.py", line 28, in replaceTagging new_line = newlyTaggedWord(line) + '\n' File "tag.formatter.py", l

[Tutor] Iterating over a long list with regular expressions and changing each item?

2009-05-03 Thread Dan Liang
Hi tutors, I am working on a file and need to replace each occurrence of a certain label (part of speech tag in this case) by a number of sub-labels. The file has the following format: word1 \tTag1 word2 \tTag2 word3 \tTag3 Now the tags are complex and I wanted to split them in a

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-27 Thread Dan Liang
continue for offset in (1, 2, 3, 4, 5, 6, 7, 8): if i+offset < len(ListLines) and ListLines[i+offset].endswith('no'): countNo+=1 print "countNo", countNo, "\t\t", ListLines[i+offset] Thank you again! --dan On Sun, Apr 26, 2009 at 10:55 AM

Re: [Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-25 Thread Dan Liang
ne does not end in "yes" or "no"? I forgot to mention that I know for sure that the file has ONLY lines that end in either "yes" or "no". Any suggestions are appreciated. Also, I feel that my code is not the best way of solving the problem even if the

[Tutor] Working with lines from file and printing to another keeping sequential order

2009-04-25 Thread Dan Liang
Dear Tutors, I have a file from which I want to extract lines that end in certain strings and print to a second file. More specifically, I want to: 1) iterate over each line in the file, and if it ends in "yes", print it. 2) move to the line following the one described in #1 above, and if it end