On Mon, 8 Mar 2010 08:05:54 -0800 (PST)
Karjer Jdfjdf <[email protected]> wrote:

> I want to compare words in a text to a dictionary with values attached to the 
> words.
> 
> The dictionary  looks like:
> { word1: [1,2,3] word2: [2,3,4,a,b ] ... }

And how does your source text look like? (we have half of the data)
And please print (part of) your dict out (instead of providing erroneous data).

> I'm trying to find a way to achieve this, but I'm having trouble getting 
> corrects results.
> 
> If I do the def below, nothing is matched.
> 
> def searchWord(text, dictionary):
>     text = text.split()
>     for word in text:
>         print word

print word, word in dictionary  # would be useful for debug

>         if word in dictionary:
>             value = dictionary[str(word)]

word is already a string -- or should be ;-)

>         else:
>             value = None
>         return w

What is w? This is your main issue, I guess...

[...]


Denis
-- 
________________________________

la vita e estrany

spir.wikidot.com

_______________________________________________
Tutor maillist  -  [email protected]
To unsubscribe or change subscription options:
http://mail.python.org/mailman/listinfo/tutor

Reply via email to