|
xAIgent is a RESTful API key phrase extraction
technology designed to work with any Integrated
Development Environment supporting RESTful services. |
|
|
|
Integrate Document Key
Phrase Extraction
with the xAIgent RESTful API and Unlock the True Value
of Enterprise Content
|
The following
discussion illustrates how to incorporate the xAIgent
API in to a Visual Studio project.
Note: The sample code presented here is taken
from the sample projects available via the download
links below.
|
|
1. Add the xAIgent
RESTful API to the project. |
In the Solution Explorer, right mouse click on the
References node.
|
|
|
Select Add Service
Reference...
In the Address: enter the address of the xAIgent wsdl
(Web Services Description Language) file. |
|
|
|
Change the default
namespace to xAIgentService... |
|
|
|
And press the OK
button, the IDE will now add the service reference and
generate the necessary handlers. |
|
|
|
2. Once the service
has been added to the project you can now program
against the service using its request and response
classes. NOTE: The xAIgent API exposes two
methods for the developer:
GetExtraction - Requires an
ExtractionRequest object and Returns an ExtractionResult
object
GetTokenStatus - Requires a
TokenStatusRequest object and Returns a
TokenStatusResult object. For more information on the
GetTokenStatus method please review the sample
application download below.
The following code is taken from the sample application
available for download below that submits text from a
text box and parses the response in to a second text box
...
C Sharp sample: |
xAIgentService.DBIXServiceClient myxAIgentService = new
xAIgentService.DBIXServiceClient(); //Create an instance
of the xAIgent restful service
xAIgentService.ExtractionRequest myxAIgentRequest = new
xAIgentService.ExtractionRequest(); //Create an instance
of the xAIgent request
xAIgentService.ExtractionResult myxAIgentResponse = new
xAIgentService.ExtractionResult(); //Create an instance
of the xAIgent result
myxAIgentRequest.ApplicationID = "xAIgent C# sample";
//Set the application ID to identify the application
calling the xAIgent service
myxAIgentRequest.LanguageID = 0; //Set the language for
the document to be extracted to Auto Detect. NOTE: This
does not work with Japanese or Korean
myxAIgentRequest.NumberOfPhrasesToReturn = 5; //Set the
number of phrases to return
myxAIgentRequest.SubscriptionID = "Your Subscription
ID"; //Set the Subscription ID for authentication to use
the xAIgent service
myxAIgentRequest.XTractionDocument =
this.TextBoxExtractee.Text; //Set the document for
extraction to the text in the TextBoxExtractee text box
try
{
|
myxAIgentResponse =
myxAIgentService.GetExtraction(myxAIgentRequest); //Run
the xAIgent Service to extract the text and return the
key phrases.
int myResultsCounter = 1;
this.TextBoxResults.Text = "";
if (myxAIgentResponse.KeyPhrases.Count() > 0)
}
|
//Process each key phrase
object in the response.
foreach (xAIgentService.KeyPhrase keyPhrase2Process in
myxAIgentResponse.KeyPhrases)
|
{
|
keyPhrase2Process.Phrase =
keyPhrase2Process.Phrase.ToUpper();
keyPhrase2Process.Highlight =
keyPhrase2Process.Highlight;
//Output the keyphrase object to the results text box.
this.TextBoxResults.Text = this.TextBoxResults.Text +
myResultsCounter.ToString() + ". " +
keyPhrase2Process.Phrase + System.Environment.NewLine +
_
|
"Score: " +
keyPhrase2Process.Score.ToString() +
System.Environment.NewLine + _
"Highlight: " + keyPhrase2Process.Highlight +
System.Environment.NewLine + System.Environment.NewLine;
|
myResultsCounter =
myResultsCounter + 1;
|
}
|
}
|
else
|
this.TextBoxResults.Text = "No
Results were returned.";
|
}
|
catch (Exception ex)
|
{
|
this.TextBoxResults.Text =
ex.Message.ToString();
|
}
|
VB.NET sample:VB.NET
sample:
|
Dim myxAIgentService As New
xAIgentService.DBIXServiceClient 'Create an instance of
the xAIgent restful service
Dim myxAIgentRequest As New
xAIgentService.ExtractionRequest 'Create an instance of
the xAIgent request
Dim myxAIgentResponse As New
xAIgentService.ExtractionResult 'Create an instance of
the xAIgent result
myxAIgentRequest.ApplicationID = "xAIgent VB.NET sample"
'Set the application ID to identify the application
calling the xAIgent service
myxAIgentRequest.LanguageID = 0 'Set the language for
the document to be extracted to Auto Detect. NOTE: This
does not work with Japanese or Korean
myxAIgentRequest.NumberOfPhrasesToReturn = 5 'Set the
number of phrases to return
myxAIgentRequest.SubscriptionID = "Your Subscription ID"
'Set the Subscription ID for authentication to use the
xAIgent service
myxAIgentRequest.XTractionDocument =
Me.TextBoxExtractee.Text 'Set the document for
extraction to the text in the TextBoxExtractee text box
Try
|
myxAIgentResponse =
myxAIgentService.GetExtraction(myxAIgentRequest) 'Run
the xAIgent Service to extract the text and return the
key phrases.
Dim myResultsCounter As Integer = 1
Me.TextBoxResults.Text = ""
If myxAIgentResponse.KeyPhrases.Count > 0 Then
|
'Process each key phrase object
in the response.
Dim keyPhrase2Process As xAIgentService.KeyPhrase
For Each keyPhrase2Process In
myxAIgentResponse.KeyPhrases
|
keyPhrase2Process.Phrase =
keyPhrase2Process.Phrase.ToUpper
keyPhrase2Process.Highlight =
keyPhrase2Process.Highlight.ToCharArray()
'Output the keyphrase object to the results text box.
Me.TextBoxResults.Text = Me.TextBoxResults.Text &
myResultsCounter.ToString & ". " &
keyPhrase2Process.Phrase & vbCrLf & _
|
"Score: " &
keyPhrase2Process.Score.ToString & vbCrLf & _
"Highlight: " & keyPhrase2Process.Highlight & vbCrLf &
vbCrLf
|
myResultsCounter =
myResultsCounter + 1
|
Next
|
Else
|
Me.TextBoxResults.Text = "No
Results were returned."
|
End If
|
Catch ex As Exception
|
Me.TextBoxResults.Text =
ex.Message.ToString()
|
End Try
|
|
Download the Visual
Studio 2015 projects here
|
C Sharp Project
|
VB.NET Project
|
|
|
|
Automatically, without training, of any subject matter
|
Objectively
retrieve the key terms, keyphrases, keywords of any
text
|
Accurately within milliseconds.
|
Automatically create lists of
key phrases in ascending / descending order of importance
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|