After you build the English Query application, you can use it in any COM- compliant environment. You can deploy an English Query application in several ways. The topics in this lesson describe deploying an English Query application in a Web-based environment. The general steps of the process and the types of files you ll need are discussed.
After this lesson, you will be able to:
- Deploy an English Query application in a Web page or other COM automation environment.
Estimated lesson time: 60 minutes
Figure 11.5 shows a core portion of the English Query object model.
Figure 11.5 Partial English Query object model diagram
The following topics discuss how to use the English Query object model in an ASP application. In order to deploy an English Query application in a Web-based application, you need Microsoft Internet Information Server and SQL Server.
The Session object is the object that represents a user session with English Query. Every English Query application must create an instance of the Session object for each user. The Session object must be initialized with a valid domain by calling the InitDomain method and specifying the .EQD file that the session will use.
Example
In this example, you create an instance of the English Query Session object and initialize it for the PUBS.EQD domain file. The ASP Server object CreateObject method is used to create the Session object; the ASP Application object is used to store a global variable that holds the path to the domain file.
Set EQSession = Server.CreateObject("MSEQ.Session") EQSession.InitDomain(Application("DomainFile")) |
After creating the session, pass a string text sentence (strQuestion) to English Query by calling the ParseRequest method.
Receiving Response from English Query
After passing a string text sentence, English Query may return one of the following as the Response object:
Example
In this example, the contents of the strQuestion variable are passed to the ParseRequest method, and the response object is assigned to the EQResult object variable.
Set EQResult = EQSession.ParseRequest(strQuestion) |
If you receive a command result, the Response object will have a Commands collection. The Commands collection will contain one or more Command objects. Each of these Command objects has a SQL property that contains a SQL statement. You can use ADO to pass the SQL statement to your database and retrieve an ADO recordset.
Example
In this example, the first Command in the Commands collection is retrieved from the response that was returned in the previous example. The SQL statement from the command is then used to populate an ADO recordset.
Set cmd = EQResult.Commands(0) Set rs = conn.OpenRecordset(cmd.SQL) |
You can also deploy an English Query application in a Microsoft Visual Basic or Microsoft Visual C++ application or in other COM automation environments. Creating a Visual Basic or Visual C++ project that uses natural language is similar to using English Query in a Web page.
A sample Visual Basic application is shipped with English Query. It can be found in the Program Files\Microsoft English Query\Samples\Vbui directory. This sample
In this exercise, you will use your domain file (Northwind_Mart.EQD) in a pre-created Web page. This Web page demonstrates basic functionality, such as asking the user for a question and either returning the result or requesting clarification. The Web page used in this exercise is installed as a sample project with English Query.
Set objEQSession= GetEQSession("pubs.eqd") |
and change pubs.EQD to Northwind_Mart.EQD so that the line now says
Set objEQSession= GetEQSession("Northwind_Mart.EQD") |
objDataConnection.Open "pubs," "guest", "guest" |
and change it to read
objDataConnection.Open "Northwind_Mart," "sa," "". |
These are some general guidelines to follow when creating your own English Query applications.
Provide as many synonyms as possible for the entities that you will use. Users may refer to the entities by several nouns. Providing synonyms will reduce the number of clarifications that English Query requests. This is particularly true when the application will support external users who may not use business syntax that is consistent with that of internal users.
Use primary key and foreign key relationships in the data source to identify links between entities in English Query. The relationships can be set up manually after import; however, doing so adds to development time.
Use regression tests to test common questions that users are going to be asking. Use as many questions and variations as possible to ensure compatibility before embedding the application in a project.
Provide a few sample questions to show users the kinds of questions they can ask. English Query is a new concept to users, and examples provide a guideline (which nouns, verbs, and sentence structure to use) for users to follow when formatting their own questions.
Log user questions to a file or table for later analysis. Your English Query project will be unable to answer some questions. By logging the kinds of questions users ask, you can stockpile a reference of future improvements needed in your English Query domain.
English Query applications can be used in any development environment that supports COM automation. The English Query object model provides a simple programmatic interface for developing sophisticated custom applications that use all of the functionality of the English Query run-time feature.