Intellexer Question Answering System can be easily integrated into custom Document/Knowledge management systems using programming languages C/C++ and C#. Our SDK contains all necessary include files and import libraries for binding user applications with Intellexer Indexer and Question Answering modules.
Here is a C++ example of how to add question answering technology to your application:
#include < iostream >
#include < Indexer.h >
#include < IndexManager.h >
#include < QPCore.h >
#include < LPXml.h >
#include < LRCore.h >
using std::cout;
using std::cerr;
using namespace NsSemSDK;
int main(int argc, char* argv[])
{
try
{
char szDBPath[] = "../../LDB"; //path to ldb
char szPluginsPath[] = "../../LPlugins"; //path to plugins
char szProvider[] = "FBIndexDriver"; //path to data provider
char szQuery[] = "What does the present invention relate to?"; //question
int nAnswerCount = 0;
// provide path to license file
SetQPLicensePath("../../ISDK_License.xml");
SetLPXMLLicensePath("../../ISDK_License.xml");
// necessary to use indexer for creating database
SetIndexerLicensePath("../../ISDK_License.xml");
SetLanguageRecognizerLicensePath("../../ISDK_License.xml");
// Create search index
// See IndexerSample-CPP sample for details
CInterfacePtr pIndex((IIndexManager *)CreateProvider("FBIndexDriver", "CreateIndexManager"));
pIndex->Open("../Data/QAS/Index.FDB");
pIndex->Clear();
CInterfacePtr pDB(LoadIndexerDB(szDBPath, szPluginsPath));
CInterfacePtr pIndexer(CreateIndexer(*pDB));
const char* arDocs[] =
{
"../Data/QAS/4,194,484.htm",
"../Data/QAS/6,812,981.htm",
"../Data/QAS/6,816,711.htm"
};
for (int i = 0; i < 3; ++i)
{
CInterfacePtr piDoc;
pIndexer->Process(arDocs[i], &piDoc);
pIndex->AddDocument(piDoc.Get());
}
pIndex->Close();
// ****** Search in index database *******
pIndex->Open("../Data/QAS/Index.FDB");
//Create query processor database
CInterfacePtr pQASLDB(CreateQueryLDB());
//Create query processor interface
CInterfacePtr pQAS(CreateQueryProcessor());
IQueryResult* pResult = NULL;
//Load query processor database
pQASLDB->Setup(szDBPath, pDB->GetLPDB());
//Initialize query processor with IQueryLDB* and IIndexDataProvider*
pQAS->Setup(pQASLDB.Get(), pIndex.Get());
//Process query
pResult = pQAS->Process(szQuery);
if (pResult != NULL)
{
//Get answer count
nAnswerCount = pResult->GetAnswerCount();
//Get and print answers
for (int i = 0; i < nAnswerCount; i++)
{
const IQueryAnswer* pAnswer = pResult->GetAnswer(i);
int nAnswerSize = 0;
const char* szAnswer = NULL;
//Print relevance
cout << pAnswer->GetRelevance() << "\t";
//Get sentence info by id
CInterfacePtr pSentInfoSet;
const ISentenceInfo* pSentInfo;
int nSentID = pAnswer->GetSentenceID();
pIndex->GetSentencesInfo(1, &nSentID, &pSentInfoSet);
pSentInfoSet->Reset();
if (pSentInfoSet->Next(&pSentInfo))
{
cout << pSentInfo->GetPath() << "\t\t" << pSentInfo->GetText() << "\n\n";
}
}
}
pIndex->Close();
}
catch (const CSemBaseException& x)
{
// Handle exceptions.
cerr << x.what();
}
return 0;
}
As a result, you get all found answers from indexed documents ordered by their relevance.