Jeff09 / Word-Sense-Disambiguation-using-Bidirectional-LSTM

10 stars 5 forks source link

How predict #1

Open alejandrods opened 6 years ago

alejandrods commented 6 years ago

Hi, I want to thank you the code because I'm studying NLP and now I'm working on word sense disambiguation. I have learn a lot of things about your code but I have a problem.

How predict with the model?

For instance I did:

prediction = model.predict([X, Y])

where X is a context with this form:

x_pred = array([[19837, 13, 15741, 1470, 796, 3, 21, 704, 13, 407, 9067, 19838, 25, 38, 11403, 21, 1, 9068, 174, 1, 82, 546, 2, 411, 11404, 141, 3569, 3, 608, 27715, 4, 2425, 47, 5, 10115, 2, 27716, 2544, 608, 7628, 2, 6203, 69, 27717, 3, 27718, 3, 2608, 27719, 2888, 25, 1511, 8288, 44, 205, 33, 1185, 2, 2811, 5, 2426, 2032, 10, 1, 143, 1720, 102, 44, 205, 151, 6, 43, 44, 113, 5, 6626, 21, 5, 10116, 608, 67, 233, 7, 246, 3, 705, 67, 21, 1, 169, 10116, 4077, 2235, 11404, 55, 20, 10117, 15, 17, 27720]])

and y_pred is the target:

y_pred = array([[ 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 27, 55, 1721, 4, 25, 1, 3266, 201, 245, 11404]])

How can I show the word that the model predicts?

Thank you so much and I want to congratulate you for this work.:)

Jeff09 commented 6 years ago

Hi, after you get y_pred, you need to mapping index to words in vocabulary, then you will have words that the model predicts.

alejandrods commented 6 years ago

But the model what predicts? : the target_sense ('art%1:06:00::',...) or target_word ('art', 'authority',...). So in the model.predict I have to insert the context (x_pred) and the target (y_pred), right¿? And then the result is like a matrix, how can I get the result word??

zobaed11 commented 4 years ago

Dear jeff09, Let's assume, test_sentence="I went to bank to deposit money" target_word='bank'

now, please give me an insight how can I load your model and predict the sense definition for the test sentence?

thanks