# Modeling words in a language based on their characters

I have different sets of strings, where I assume that each set follows some rules or patterns. For example, the first character must be a number, or the 3rd and the last characters must be the same, etc.

I want to be able to determine, given a string, what is the probability that it belongs to a specific set.

Are there any techniques from NLP that might help me do that? for example if I look at the similar problem of assigning a probability of some unknown word to be a part of a language given its characters? is there a common method to do that?

Thank you.

You could also slightly tweak your favorite language model to model $$p(x|c)$$, where $$c$$ is the the category / set. Then $$p(c|x) \propto p(x|c)p(c)$$.