def words_to_word_ids(data=[], word_to_id={}, unk_key='UNK'):
 word_ids = []
 for word in data:
  if (word_to_id.get(word) is not None):
   word_ids.append(word_to_id[word])
  else:
   word_ids.append(word_to_id[unk_key])
 return word_ids

def words_to_word_ids ( data = [ ] , word_to_id = { } , unk_key = 'UNK' ) : word_ids = [ ] for word in data : if ( word_to_id . get ( word ) is not None ) : word_ids . append ( word_to_id [ word ] ) else : word_ids . append ( word_to_id [ unk_key ] ) return word_ids
given a context in list format and the vocabulary .