I have been trying to implement an algorithm using Python in order to perform contextual matching in a set of documents. My ultimate goal would be to be able to perform queries using positive keywords (and bigrams as well) but also negative ones. For instance a potential query could be:

"food" + "healthy" - "children"

which would target healthy foods for adults or expressed in a different manner, show me healthy food articles and leave out any articles that are about kids.

So far I have been using a simple tf-idf implementation with cosine similarity in order to be able to query my dataset.

Another thought I had is by using a Bag-of-Words model and set the kid, kids, child, children and many other words to null in order to exclude those results (and not should whether that would work as expected). Not sure how that would perform but sounds like a bad solution as there are bigrams as well in the text and queries that I should exclude and so on.

I know that what I am describing sounds a lot like Word2vec and I tried to train a model but I should mention that I am not working with english text and I do not have enough data to get it working properly.

Any suggestions?


Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Browse other questions tagged or ask your own question.