Re: string Index for the last position

2009-04-28 Thread Clarendon
Dear Christian Thank you so much! It works! -- http://mail.python.org/mailman/listinfo/python-list

string Index for the last position

2009-04-28 Thread Clarendon
I am trying to get the index for the last occurrance of a sub string. S = 'dab dab dab' print S.find('ab') 1 This gives me the index for the first position of 'ab'. But I need to index the last position of 'ab' here. Is there a quick option for find that will do this, or do I have to write a long

Re: Accessing a parse tree

2009-04-18 Thread Clarendon
Dear John Machin So sorry about the typo. It should be: "the program should *see* that the designated *words* are..." "a long way" has two parentheses to the left -- (VP (DT -- before it hits a separate group -- VBD came). If there are three parenthesis, for instance (NP, this will means that wha

Re: Accessing a parse tree

2009-04-17 Thread Clarendon
Thank you very much for this information. It seems to point me to the right direction. However, I do not fully understand the flatten function and its output. Some indices seem to be inaccurate. I tried to find this function at nltk.tree.Tree.flatten, but it returns a flattened tree, not a tuple.

Accessing a parse tree

2009-04-16 Thread Clarendon
Hello! I need a program that accesses a parse tree based on the designated words (terminals) within the tree. For instance, in: I came a long way in changing my habit. (ROOT (S (NP (PRP I)) (VP (VBD came) (NP (DT a) (JJ long) (NN way)) (PP (IN in) (S (VP (

Re: Python parser

2009-03-02 Thread Clarendon
Thank you, Lie and Andrew for your help. I have studied NLTK quite closely but its parsers seem to be only for demo. It has a very limited grammar set, and even a parser that is supposed to be "large" does not have enough grammar to cover common words like "I". I need to parse a large amount of t

Python parser

2009-03-02 Thread Clarendon
Can somebody recommend a good parser that can be used in Python programs? I need a parser with large grammar that can cover a large amount of random texts. Thank you very much. -- http://mail.python.org/mailman/listinfo/python-list

Re: Delete all items in the list

2009-02-28 Thread Clarendon
Thank you very much for all your replies. I actually used the while loop as the data is not large. But I was looking for a simpler, built in command, something like L.remove('a', all) or L.removeall('a'). Python has re.findall function, but why not removeall, so users have to make up long lines of

Delete all items in the list

2009-02-26 Thread Clarendon
Hi. This must be a simple command but I just can't find it in the Phthon manual. How do I delete all items with a certain condition from a list? For instance: L=['a', 'b', 'c', 'a'] I want to delete all 'a's from the list. But if L.remove('a') only deletes the first 'a'. How do you delete all 'a