Migrating text analysis rules

You can use the IBM Watson® Explorer oneWEX REST API to migrate IBM Watson Explorer Analytical Components text analysis rules to a Watson™ Explorer oneWEX dictionary annotator.

You cannot edit migrated text analysis rules in Watson Explorer oneWEX. To make changes, you must edit the text analysis rules in Watson Explorer Analytical Components and redo the migration.

Get the Watson Explorer Analytical Components text analysis rules

Text analysis rules are stored in the Watson Explorer Analytical Components master server. The folder path is $ES_NODE_ROOT/master_config/<collection_id>.indexservice/resource/pattern. The category tree file is stored at $ES_NODE_ROOT/master_config/<collection_id>.indexservice. The file name is category_tree.xml.

Migrate the text analysis rules to Watson Explorer oneWEX

These instruction use the swagger interface to submit REST API calls to Watson Explorer oneWEX.

  1. Go to https://<wexONE_server>/docs/. Click Authorize and enter your signin credentials. Click Authorize and then click Done.
  2. Open the text analysis rules file in a text editor.
  3. Find the mi element, remove the first instance of $, and then save the file. For example, change
    <mi category="$.food_keywords.change_of_properties" value="${0.lex} ${1.lex}">
        <w id="0" str="cloudy" />
        <w id="1" pos="noun" str="/(white|yellow)/"/>
    </mi>

    to

    <mi category=".food_keywords.change_of_properties" value="${0.lex} ${1.lex}">
        <w id="0" str="cloudy" />
        <w id="1" pos="noun" str="/(white|yellow)/"/>
    </mi>
  4. Open FileResource > POST /api/v1/fileResources Create a file resource. Click Try it out.
  5. Update the body as shown below. Choose values for <rule_description> and <rule_name>.
    {
        "description": "<rule_description>",
        "id": "string",
        "metadata": {
            "lastModified": 1531288825136
        },
        "name": "<rule_name>",
        "tags": {
        },
        "type": "tpat"
    }
  6. Click Execute and confirm the server response code. is 200.
  7. Copy the value of the id field in the Response body.
  8. Open FileResource > POST /api/v1/fileResources/{fileResourceId}/upload Update a file resource content. Click Try it out.
  9. Enter the id from step 7 and click Choose File to browse to the file you created in step 3.
  10. Click Execute and confirm the server response code is 200.

Migrate the Watson Explorer Analytical Components category tree file

  1. Open Migration > POST /api/v1/migration/category Migrate category tree file. Click Try it out.
  2. Paste the contents of the category tree file into the body field.
  3. Click Execute and confirm the server response code is 200.
  4. Copy the contents of Response body into a file and save it as a JSON file. For example, migrated_tree.json.

Create enrichment

  1. Open Migration > POST /api/v1/enrichments Create an enrichment. Click Try it out.
  2. Update the body field as shown below. <enrichment_name> and <enrichment_description> are the enrichment name and description that you choose. <contents_of_category tree_file> is the entire content of the category tree file. The fileResources element contains the id values of the text analysis rules that you migrated.
    • <enrichment_name> and <enrichment_description> are the enrichment name and description that you choose.
    • <contents_of_migrated_category tree_file> is the entire content of the migrated category tree file.
    • The fileResources element contains the id values of the text analysis rules that you migrated.
    {
        "name": "<enrichment_name>",
        "description": "<enrichment_description>",
        "metadata": {
            "lastModified": 1532479085299
        },
        "tags": {
            "depends-on": "pos"
        },
        "type": "dict",
           "fileResources": [
            "<resource_id1>",
            "<resource_id2>"
        ],
        "category": {
            <contents_of_migrated_category tree_file>
            },
        "annotationIndexingSpecs": null,
        "facetDictionaries": [],
        "labelerId": null,
        "modelId": null
    }
  3. Click Execute and confirm the server response code is 200.
  4. Go to the Resources page of the Watson Explorer oneWEX Admin Console and verify the annotator has been added.