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):
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
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
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
[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
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
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
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
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
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
* 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
11 matches
Mail list logo