How to Create PRC Service with Slamby TAU and .Net SDK

In this tutorial, we will show you how to prepare and run a PRC service.

You can use this service for similar document detection, document match-making, keyword extraction, duplicated document detection. PRC service analyzes all incoming documents by using Slamby Twister algorithm to provide perfect result with a relevant score.

Slamby TAU is an integrated data management solution that communicates directly with your Slamby Server. It makes you able to use your server resources in the cloud and manage your data easily in a real-time on your computer.

PRC Service Video Tutorial

1. Creating a PRC Service

Let’s start with adding a new PRC service.

Example TAU Create New Service Screen
Slamby TAU PRC Service Creation

To create a PRC Service, provide the significant name and the short description. Then, click on the ‘Okay’ button. Now, you can see that service is displayed in New status.

Create New Service Example using .Net SDK

var service = new Service()
{
Name = "Classifier",
Description = "This is a demo service description",
Type = ServiceTypeEnum.Prc
};
var result = await serviceManager.CreateServiceAsync(service);
var createdService = result.ResponseObject;

2. Preparation of PRC Service

To prepare your PRC Service, provide your custom settings by using Json.

Example TAU Preparation Setting Screen
Slamby TAU PRC Service Preparation

Define the Source Dataset name that you are going to use and provide the tag IDs or just keep it as 'null' to use all the leaf tag IDs.

{
"DataSetName": "demo-dataset",
"TagIdList": [ "4", "132", "211", "3" ],
}

Then, Click on the OK button to start the process.

Tips: to select your custom Tag Ids and paste it into the JSON setting, select your required Tags in Data>Tags, and press ctrl+c, then ctrl+v in the json document. The selected Tag IDs array will be pasted as a JSON array.

Preparation of New Service Example using .Net SDK

var prcServiceManager = new PrcServiceManager(_configuration);
var prcPrepareSettings = new PrcPrepareSettings()
{
DataSetName = "demo-dataset",
TagIdList = new List() { "4", "132", "211", "3" }
};
var prepareResponse = await prcServiceManager.PrepareServiceAsync(serviceId, prcPrepareSettings);
var process = prepareResponse.ResponseObject;

3. Activation of PRC Service

After preparation process is finished, you can set the activation settings in a JSON format.

Example TAU Activation Setting Screen
Slamby TAU PRC Service Activation

Define interpreted fields for recommendation or keep it as null to use all the fields. Those fields should be identical with your document database fields.

{
"FieldsForRecommendation": [ "Subject", "Body" ]
}

Then, click on the OK button to activate the service.

Activation of PRC Service Example using .Net SDK

var prcServiceManager = new PrcServiceManager(_configuration);
var prcActivateSettings = new Models.Services.PrcActivateSettings()
{
FieldsForRecommendation = new List() { "title" }
};
var activateResponse = await prcServiceManager.ActivateServiceAsync(serviceId, prcActivateSettings);

4. Testing of PRC Service

And finally, everything is ready to test the PRC Service. To test it, click on the Recommend button. You just need to fill the JSON setting input form with the available settings and send your request to the Service API endpoint.

Example TAU Recommend Screen
Slamby TAU PRC Service Recommendation

This text will be analyzed and used for recommendation. Set the count to determine the number of result items in response body. Set the Need document in result as ‘true or false’ in order to receive full detailed document response or just document IDs in response. Set the TagID to determine the Target Tag ID where the analysis is going to be processed. By using Filter, you can make the analysis on the filtered documents. And by using weights, you can customize your fields in an order. Weight can be any number between -10 to 10.

{
"Text": "Black Leather Laptop Bag",
"Count": 3,
"NeedDocumentInResult": true,
"TagId": 3,
"Filter": null,
"Weights": null,
}

And now, you can click on OK button to receive the recommendation results.

Recommendation of PRC Service Example using .Net SDK

var prcServiceManager = new PrcServiceManager(_configuration);
var prcRecommendationRequest = new Models.Services.PrcRecommendationRequest()
{
Text = "Black Leather Laptop Bag",
NeedDocumentInResult = true,
Count = 3,
TagId = "3"
};
var recommendResponse = (await prcServiceManager.RecommendServiceAsync(serviceId, prcRecommendationRequest));

5. PRC Service Recommendation Result

The score is between 0 to 2.

Example TAU PRC Result Screen
Slamby TAU PRC Service Recommendation Result

When the score is 1, all the relevant keywords are the same and basically it means a duplication. When the score is higher than 1, the documents contain the same keywords but more frequently.

Response Example of PRC Service Result

[
{
"DocumentId": "280092",
"Score": 1.1760036101632098,
"Document": {
"ad_id": "280092",
"category_id": "8392",
"subject": "Black Leather Laptop Bag",
"body": "Maxam Brand Italian Mosaic Design Genuine Black Leather Business Briefcase, Laptop Bag, Messenger or Carry On Bag. Features exterior zippered pockets on both sides. The zippered top opens into 3 compartments and another zipper-secured pocket. Hand grips are trimmed with silver-tone hardware. It can be shoulder carried by using the added detachable shoulder strap. Measures 16-1/2'' x 11'' x 5''.",
"moderation_status": "1",
}
]

 

Download our SDKs from Github.com/Slamby

Leave a Reply

Your email address will not be published. Required fields are marked *