the thing which i have understood from your question you have some keywords and some other patterns containing those keywords in your lexicon and some others which come to your system from users question. then you need an algorithm to find these patterns in your system input. as i know in java if you define a pattern from Pattern class then you can do like below to achieve the thing which you want:(A simple example)
Pattern pat = Pattern.compile("[A-Z]+");
Matcher matcher = pat.matcher("ABCD");
if(matcher.matches()) {
System.out.println("it matchs.");
}