title: How to get the princeton WN sense id given a sense offset? Python-NLTK
body: <p>I can get the sense offset from a princeton WN sense as marked in the NTLK corpus library:</p>
  
  <pre><code>[in]:'dog.n.01'
  &gt;&gt;&gt; from nltk.corpus import wordnet as wn
  &gt;&gt;&gt; ss = wn.synset('dog.n.01')
  &gt;&gt;&gt; offset = str(ss.offset).zfill(8)+"-"+ss.pos
  &gt;&gt;&gt; print offset
  [out]:'02084071-n'
  </code></pre>
  
  <p>That offset is similar to the convention used in <a href="http://casta-net.jp/~kuribayashi/cgi-bin/wn-multi.cgi?synset=02084071-n&amp;lang=eng" rel="nofollow">http://casta-net.jp/~kuribayashi/cgi-bin/wn-multi.cgi?synset=02084071-n&amp;lang=eng</a></p>
  
  <p><strong>How can i do the reverse without looping through the whole wordnet corpus?</strong> where:</p>
  
  <pre><code>[in]: '02084071-n'
  [out]: 'dog.n.01' or Synset('dog.n.01')
  </code></pre>
  
  <p>I could do this but it's just way way too long and too many redundant cycles:</p>
  
  <pre><code>[in]: '02084071-n'
  in_offset, in_pos = "02084071-n".split("-")
  from nltk.corpus import wordnet as wn
  nltk_ss = [i for i in wn.all_synsets() if i.offset == int(in_offset) and i.pos == in_pos][0]
  print nltk_ss
  [out]: Synset('dog.n.01')
  </code></pre>