February 2019
Beginner to intermediate
568 pages
13h 5m
English
In the previous section, we built two models, where the first model predicts the entities in a query and the second model extracts the intent of queries.
In this section, we will define a function that takes a query and converts it into a structured format:
def preprocessing(text): text2 = text.split() a=[] for i in range(len(text2)): a.append(sentence_word_to_int[text2[i]]) return a
text = "BOS i would fly from boston to dallas EOS"
indexed_text = preprocessing(text)padded_text=np.zeros(50)padded_text[:len(indexed_text)]=indexed_textpadded_text=padded_text.reshape(1,50)
The preceding ...
Read now
Unlock full access