Let's say that I want to classify whether a document is a legal document or not. I have a list of keywords that will be presented only in legal documents.
What is the proper way or algorithm to calculate probability based on this list?
Let's say that I want to classify whether a document is a legal document or not. I have a list of keywords that will be presented only in legal documents.
What is the proper way or algorithm to calculate probability based on this list?
Maybe this is what you are looking for: https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm
Basically you would
Then based on the result
This is a pretty classic case of document classification via the Naive-Bayes based Bag of Words Algorithm. It'll give you a prior probability based on your keywords. Try this link for more information. In your specific case, the "Bag" is already pre defined which makes things easier.
Another related question is this which may spawn more ideas for your use case. More generally though, if you format your problem as text classication using a feature vector constructed as some set of counts based on your keyword database then you can use pretty much any ML algorithm which gives you a baysian prior or some output probability.