Re: How to find all the same words in a text?

2007-02-11 Thread Samuel Karl Peterson
Johny [EMAIL PROTECTED] on 10 Feb 2007 05:29:23 -0800 didst step forth and proclaim thus: I need to find all the same words in a text . What would be the best idea to do that? I make no claims of this being the best approach: def findOccurances(a_string, word):

Re: How to find all the same words in a text?

2007-02-11 Thread Neil Cerutti
On 2007-02-10, Johny [EMAIL PROTECTED] wrote: I need to find all the same words in a text . What would be the best idea to do that? I used string.find but it does not work properly for the words. Let suppose I want to find a number 324 in the text '45 324 45324' there is only one

Re: How to find all the same words in a text?

2007-02-11 Thread Maƫl Benjamin Mettler
In order to find all the words in a text, you need to tokenize it first. The rest is a matter of calling the count method on the list of tokenized words. For tokenization look here: http://nltk.sourceforge.net/lite/doc/en/words.html A little bit of warning: depending on what exactly you need to

Re: How to find all the same words in a text?

2007-02-11 Thread attn . steven . kuo
On Feb 11, 5:13 am, Samuel Karl Peterson [EMAIL PROTECTED] wrote: Johny [EMAIL PROTECTED] on 10 Feb 2007 05:29:23 -0800 didst step forth and proclaim thus: I need to find all the same words in a text . What would be the best idea to do that? I make no claims of this being the best

Re: How to find all the same words in a text?

2007-02-11 Thread Samuel Karl Peterson
[EMAIL PROTECTED] on 11 Feb 2007 08:16:11 -0800 didst step forth and proclaim thus: More concisely: import re pattern = re.compile(r'\b324\b') indices = [ match.start() for match in pattern.finditer(target_string) ] print Indices, indices print Count: , len(indices) Thank you, this

How to find all the same words in a text?

2007-02-10 Thread Johny
I need to find all the same words in a text . What would be the best idea to do that? I used string.find but it does not work properly for the words. Let suppose I want to find a number 324 in the text '45 324 45324' there is only one occurrence of 324 word but string.find() finds 2

Re: How to find all the same words in a text?

2007-02-10 Thread Marco Giusti
On Sat, Feb 10, 2007 at 05:29:23AM -0800, Johny wrote: I need to find all the same words in a text . What would be the best idea to do that? I used string.find but it does not work properly for the words. Let suppose I want to find a number 324 in the text '45 324 45324' there is only one

Re: How to find all the same words in a text?

2007-02-10 Thread Johny
On Feb 10, 2:42 pm, Marco Giusti [EMAIL PROTECTED] wrote: On Sat, Feb 10, 2007 at 05:29:23AM -0800, Johny wrote: I need to find all the same words in a text . What would be the best idea to do that? I used string.find but it does not work properly for the words. Let suppose I want to find a

Re: How to find all the same words in a text?

2007-02-10 Thread ZeD
Johny wrote: Let suppose I want to find a number 324 in the text '45 324 45324' there is only one occurrence of 324 word but string.find() finds 2 occurrences ( in 45324 too) '45 324 45324'.split().count('324') 1 ciao Marco, Thank you for your help. It works

Re: How to find all the same words in a text?

2007-02-10 Thread Marco Giusti
On Sat, Feb 10, 2007 at 06:00:05AM -0800, Johny wrote: On Feb 10, 2:42 pm, Marco Giusti [EMAIL PROTECTED] wrote: On Sat, Feb 10, 2007 at 05:29:23AM -0800, Johny wrote: I need to find all the same words in a text . What would be the best idea to do that? I used string.find but it does not work

Re: How to find all the same words in a text?

2007-02-10 Thread Thorsten Kampe
* Johny (10 Feb 2007 05:29:23 -0800) I need to find all the same words in a text . What would be the best idea to do that? I used string.find but it does not work properly for the words. Let suppose I want to find a number 324 in the text '45 324 45324' there is only one occurrence