0

I have a word dictionary stored in word_dict and I am trying to convert text to sequences manually using the function described below. But it is keep on throwing No Value Error. I have also checked the function by applying only one record of the dataset but it is not applying to the whole record.

def tex_to_sequences():
  word_seq=[]
  doc = nlp(text)
  print(len(doc))
  print(word_seq)
  for t in doc:
    word_seq.append(word_dict.get(t.text))
  print(len(word_seq))
  return word_seq
df['sequences']= df['text'].apply(tex_to_sequences)

it displays the output of first record and then immediately throughs error

Kbstar
  • 15
  • 8

1 Answers1

0

Can we have your dataframe ?

text param in your text_to_sequences function will represent the df['text'] column ? If that is the case you have to add another param to your text_to_sequences function like text_to_sequences(text,word_dict)

Also I suggest you to add axis = 1 in your apply like this :

df['sequences']=df['text'].apply(text_to_sequences(word_dict),axis=1)