How hard is it to do this with your own database?

It's this easy:
Set up VB ELF and a data source on your Internet server. Run the VB ELF analysis to create an interface. ("Northwind" takes about a minute, larger databases take a little longer.)

Create a form to accept English questions on an .HTM or .ASP page. The one on our demo page is generated by HTML code like this:

<FORM NAME="EnglishQuestion" ACTION="vbelf.asp" METHOD=POST>
<B>Question:</B> <INPUT TYPE=TEXT SIZE=79 NAME="Question">
<INPUT TYPE=SUBMIT NAME="Submit" VALUE = "Submit new"> </FORM>

Notice that the action of this form sends the question to the page VBELF.ASP. Here's the heart of the VBELF.ASP page that accepts the question, translates it into a query, runs the query against your database, and returns the result recordset:

<%
Set MyELF = CreateObject("VBELF32.ELF") ' create an ELF Web object
ThisQuestion = Request.Form("Question") ' retrieve question from calling form
result = MyELF.elfSelectJetMDB(Server.MapPath("\") & "\Data\Northwind.mdb") ' select the data source
result = MyELF.elfOpenGrammar("Northwind.ELF","VB ELF Directory") ' choose the natural language interface you want to use
QueryName = MyELF.elfTranslate(ThisQuestion,5) ' translate question & return the result SQL query name

' now use the translation to create a recordset:
Set oRS = Server.CreateObject("ADODB.Recordset")
oRS.Open QueryName, "Driver={Microsoft Access Driver (*.mdb)};DBQ=" & MyELF.JetMDB & ";"

' if you like, make another call to get the last SQL translation for display purposes:
SQL = MyELF.elfTranslate("",6)
%>

That's pretty much it. We've translated the question into SQL, and automatically created a QueryDef inside our MDB with this SQL. Its name has been returned in the QueryName variable, and we've used this name to actually open up an ADO recordset to return the data.

The next step is to format the data in HTML. We use a simple loop, but you could use the Microsoft HTML Table Formatter, or a method of your choice.

Of course, it's just as easy to use VB ELF against enterprise database systems like SQL Server and Oracle.

Download the source: Click here for source code for these ASP pages

Submit more questions: Click here for return to demo




http://www.babblebooks.com/shopping/shoppodcasts.asp http://www.babblebooks.com/shopping/bbcatalog.htm