Lesson 3: Deploying an English Query Application

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

The English Query Object Model

Figure 11.5 shows a core portion of the English Query object model.

click to view at full size

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.

Creating and Initializing an English Query Session

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")) 

Passing String Text

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:

  • A statement
  • A request for clarification
  • The actual results of the query (if the domain file contains enough information)

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) 

Passing the Transact-SQL Statement

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) 

Deploying the Application in Other Environments

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

  • Creates a typical user interface that you can use as a template in your own projects
  • Provides examples of how to handle the UserClarifyResponse object, which is returned from English Query

Exercise 1: Using Your English Query Project in a Web Page

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.

  • To set up the sample Web site
    1. Copy the files located in C:\Program Files\Microsoft English Query\Samples\.ASP to the C:\Northwind folder you created in the last exercise.
    2. Right-click the C:\Northwind folder in Windows NT Explorer and select Sharing on the pop-up menu.
    3. Select the Web Sharing tab, and then select Share this folder. The Edit Alias dialog box will be displayed. If the Edit Alias dialog box is not displayed, click the Add button to open it.
    4. In the Edit Alias dialog box, ensure that the Alias is set to Northwind and that the Read and Scripts check boxes are checked. Click the OK button twice to close the Edit Alias and the Northwind properties dialog boxes.
    5. Using Notepad, edit the C:\Northwind\Response.ASP file. You need to update this file to reflect your domain file. Find the line that says
    6.  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") 

    7. Save your changes to the file.
    8. Using Notepad, edit the C:\Northwind\Common.INC file. This file contains subroutines common to all of the pages. Find the DoSQLCommand subroutine, which connects to the data source.
    9. You need to update this routine with credentials to connect to your SQL Server. Find the line that says
    10.  objDataConnection.Open "pubs," "guest", "guest" 

      and change it to read

       objDataConnection.Open "Northwind_Mart," "sa," "". 

    11. Save your changes to the file.
    12. Start Microsoft Internet Explorer, and browse to the http://localhost/Northwind URL.
    13. In the text box, type the question How many products are there? Click Submit.
    14. Submit a question for which you did not set up semantics, such as Show all products by Category. What happens?
    15. Submit the following questions that use product and customer names: How many Chai were bought by QUICK-Stop? and Which customers bought Alice Mutton?

Recommended Practices

These are some general guidelines to follow when creating your own English Query applications.

Provide Multiple Synonyms for Entities

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

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.

Regression-Test Your Most Common Questions

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 Sample Questions

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

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.

Lesson Summary

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.



Microsoft Corporation - Microsoft SQL Server 7 Data Warehousing Technical Support Training Kit
Microsoft SQL Server 7 Data Warehousing Technical Support Training Kit
ISBN: 0735606706
EAN: 2147483647
Year: 1999
Pages: 114

flylib.com © 2008-2017.
If you may any questions please contact us: flylib@qtcs.net