You are viewing an old version of this page. View the current version.

Compare with Current View Page History

« Previous Version 3 Next »

You might wanna use this asset when you need to insert multiple entries at a dictionary. This my be used at the Synonyms Processor or at the following Recognizers: Regex, Advanced Regex, Simple Regex, Fragmented Regex, Best Bets, Entities, FAQ and Intent.

Step-by-step guide using the UI

Steps to use the Importer:

  1. Locate the import icon at top left of the dictionaries window
  2. It will display a formulary that contains the required fields for each component that looks like the first image bellow. Down the formulary there's also a component to browse or drag and drop the files you want to parse.
                                                 
  3. There 5 types of supported file extensions and multiple considerations to have at the files content.
    1. JSON: JSON files are meant for one single element to be inserted using the importer, this might be used as a format testing for the JSONL type because to inserts elements one by one is easier using the add button.
    2. JSONL: JSONL is a format where every single line of the file correspond to a JSON like element. This works to insert multiple elements at once.
    3. XML: for XML the format is very specific even though you don't need to name the tags with a specific format. XML required format is the following:

      1. mainTag: can have any name, it won't be used at the parsing all it does is to give the XML file a valid format to follow.
      2. parentTag: this field can also have any name but it must be specified at the formulary, this field represents each element that will be added.
      3. childTags: all the other fields contained between the parentTag, those fields represent the different fields needed for each type. Please notice the format for lists and JSON fields.
    4. XLSX: file extension for excel files allowed by this component. Only requisits are: parses only one Sheet at a time, make sure to create lists in one only cell separated by commas and JSON-like fields must be in a correct JSON format. The position of the columns at the sheet doesn't matter as long as the first row introducing the table has the name of each column, and the corresponding elements are bellow.
      1. SheetName: the name of the sheet to be processed. In this case FAQSaga.
      2. Columns: fill the other fields with the name of the columns that matches the element you want to map to it

    5. CSV: stands for "comma separated values" format of excel files, but it allows several separators delimited by a drop down (if the separator you require doesn't figures into the dropdown list, contact SAGA team).
      It requires the name of the columns at the first row and the following rows should follow this pattern, as it's illustrated in the following image:

      At any of those formats, "confidence" and "fields" fields are optional, if "confidence" is not included or doesn't have a value, 1 is automatically assigned to it. If "fields" is not included it stays blank.

  4. Once you have filled the form and uploaded the files to parse, you can press the now enabled import button:


You can use any name you want at the tags of any of the file formats as long as they are standardized in the file(s) you're going to upload. For example if you want to import 4 XML files make sure that they all have the same parent tags and child tags.

Use the Universal Importer via API


You can use the importer without the SAGA UI, there is an endpoint available to do imports (the same one that the UI uses, but on UI is more convenient to see all the options). However, if by any means, you need to do an import outside the UI, we've got you covered, you can call the SAGA API to do imports directly to a tag and to an specific recognizer (if the recognizer has the ability to import entries).

To do this, you need to make a POST request to the endpoint /saga/api/v2/importer/upload with the following body:


Body of the import request (must be a form-data body):


files => The file with the entries you want to import (Remember the 5 extension types we support)

config => The configuration of the current import

           This is a dictionary-like object with all the info needed regarding the file extension you are using and the mapping of the values inside the file you want to import and the values inside the tag/recognizer.

           Example: 

Example config key value
{"fileExtension":".json","id":"id","display":"display","patterns":"patterns","fields":"","confAdjust":""}


model => The model type you are using, depends on the type of recognizer you are trying to import to, it could be one out of these values:

  • AdvancedModel
  • BestbetsModel
  • EntitiesModel
  • FaqModel
  • FragmentedModel
  • IntentModel
  • RegexModel
  • SimpleRegexModel

tagId => The ID of the tag you want to import entries into.


Example image using Postman:

  • No labels