A computer readable medium storing computer executable instructions that when executed by a processor cause the processor to perform a method for classifying an input query within multiple domains for natural language processing, the method comprising generating trigram corpora, each trigram corpus for a domain, comprising:
- defining a query model for the domain comprising at least an ontology having a set of semantic tokens organized in hierarchical levels, and a set of domain-specific semantic constructions each including one or more of the semantic tokens linked by one of a set of predefined grammatical relations;
- obtaining an expanded set of semantic constructions as a semantic corpus for the domain by replacing at least one of the semantic tokens of at least one of the semantic constructions of the query model with corresponding semantic tokens at a lower hierarchical level in the ontology of the query model;
- performing a trigram analysis on the semantic corpus to obtain the trigram corpus for the domain comprising entries each corresponding to a trigram of three-token sequence appearing in the semantic corpus, each entry comprising:
- a three-token sequence having a first, second and third semantic token;
- and
- a corresponding trigram probability representing a relative probability associated with the third semantic token appearing in the semantic corpus given the first and the second semantic tokens;
- obtaining an input query text from a remote device via a network connection;
- determining normalized relevance scores for the input query text corresponding to the multiple domains based on the input query text, query models of the multiple domains and the trigram corpora of the multiple domains;
- ordering the normalized relevance scores for the input query text with respect to the multiple domains;
- classifying the input query text according to the ordering;
- and
- transmitting, to the remote device, a communication comprising the input query text based upon the classifying.