0
for synset in wn.synsets(wordstr):
    len_lemma_names = len (synset.lemma_names)
    #print len_lemma_names, synset.lemma_names
    count_lemma = count_lemma + len_lemma_names
for synset_scores in swn_senti_synset:
    count_synset = count_synset + 1
    #print count_synset, synset_scores

I am trying to print len_lemma_names in front of count_synset but it did not work. Is there any way possible for printing them together? Thank you...

4
  • Are wn.synsets(wordstr) and swn_senti_synset always the same length? Commented Apr 19, 2012 at 13:42
  • Your question isn't clear. Which line are you trying to print it in? And where are the count_* variables defined? And what do they all mean? Commented Apr 19, 2012 at 13:43
  • Is there a relation between synsets and swn_senti_synset - or do you always want to print ALL len_lemma_names for each synset_score? Commented Apr 19, 2012 at 13:43
  • @Gjallar There is no relationship between synsets and swn_senti_synset. Yes I want to print Len_lemma_names for each synset_score. Commented Apr 19, 2012 at 13:48

1 Answer 1

1

I think that you are wanting to iterate over the two, together. If this is the case, you want to use zip, or to avoid turning it all into one big list at once, itertools.izip.

from itertools import izip

for synset, synset_scores in izip(wn.synsets(wordstr), swn_senti_synset):
    # Now you can deal with both at once in this loop.
    len_lemma_names = len(synset.lemma_names)
    count_lemma += len_lemma_names
    count_synset += 1
    # Mix to taste.
    print len_lemma_names, count_synset

Note that the count_synset part may be better done with enumerate (I don't know its initial value or whether you're wanting to use it outside this code).

Sign up to request clarification or add additional context in comments.

1 Comment

Thank you, that takes me over 10k :-)

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.