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?

  • 2
    $\begingroup$ The way this question is posed, it seems trivial: if any/all (depending on interpretation) of the keywords are present in the document, it is a legal document. Else it is undetermined. If this is not what you intended, can you clarify your question? $\endgroup$ Jan 4 at 21:14

Maybe this is what you are looking for: https://en.wikipedia.org/wiki/Aho%E2%80%93Corasick_algorithm

Basically you would

  1. build and store a finite-state machine that resembles a trie with additional links between the various internal nodes using the given keywords.
  2. for the candidate document, go through it with the above finite-state machine.

Then based on the result

  1. If there is any match, then the document is valid.
  2. Otherwise it is possible that the document is invalid. However, in terms of the probability, I do not have any good idea yet.

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.