watson-developer-cloud / java-sdk

:1st_place_medal: Java SDK to use the IBM Watson services.
http://watson-developer-cloud.github.io/java-sdk/
Apache License 2.0
590 stars 533 forks source link

Create configuration is not working #817

Closed chethan-89 closed 6 years ago

chethan-89 commented 6 years ago

I am using the latest SDK version and was trying to create a configuration. The api documentation still does not reflect latest changes to SDK. I made the necessary changes and tried creating the configuration. But it is not working. Looks like the configuration created using GSON function is skipping the Enrichment options part from the config JSON file. Below is the code I used

CreateConfigurationOptions.Builder createBuilder = new CreateConfigurationOptions.Builder(environmentId);
        Configuration configuration =  GsonSingleton.getGson().fromJson(
            new FileReader("config.json"), com.ibm.watson.developer_cloud.discovery.v1.model.Configuration.class);
        createBuilder.configuration(configuration);
        Configuration createResponse = discovery.createConfiguration(createBuilder.build()).execute();
germanattanasio commented 6 years ago

@lpatino10 can you take a look at this when you come back from SF?

lpatino10 commented 6 years ago

I'm taking a look at this now. In the meantime @chethan-89, you should be able to create a configuration successfully by manually populating a CreateConfigurationOptions object. An example of this can be found in the DiscoveryServiceIT file in the createConfigurationIsSuccessful test.

lpatino10 commented 6 years ago

@chethan-89 could you give more details as to what the issue is? Is your EnrichmentOptions object empty in your returned configuration?

I ran the method with the following configuration and got back everything in my response object. It could be that the configuration file format is different:

{
  "configuration_id": "*****",
  "name": "doc-config",
  "description": "this is a demo configuration",
  "created": "2016-12-14T02:33:34.396Z",
  "updated": "2016-12-14T02:33:34.396Z",
  "conversions": {
    "word": {
      "heading": {
        "fonts": [
          {
            "level": 1,
            "min_size": 24,
            "bold": false,
            "italic": false
          },
          {
            "level": 2,
            "min_size": 18,
            "max_size": 23,
            "bold": true,
            "italic": false
          },
          {
            "level": 3,
            "min_size": 14,
            "max_size": 17,
            "bold": false,
            "italic": false
          },
          {
            "level": 4,
            "min_size": 13,
            "max_size": 13,
            "bold": true,
            "italic": false
          }
        ],
        "styles": [
          {
            "level": 1,
            "names": [
              "pullout heading",
              "pulloutheading",
              "header"
            ]
          },
          {
            "level": 2,
            "names": [
              "subtitle"
            ]
          }
        ]
      }
    },
    "pdf": {
      "heading": {
        "fonts": [
          {
            "level": 1,
            "min_size": 24,
            "max_size": 80
          },
          {
            "level": 2,
            "min_size": 18,
            "max_size": 24,
            "bold": false,
            "italic": false
          },
          {
            "level": 2,
            "min_size": 18,
            "max_size": 24,
            "bold": true
          },
          {
            "level": 3,
            "min_size": 13,
            "max_size": 18,
            "bold": false,
            "italic": false
          },
          {
            "level": 3,
            "min_size": 13,
            "max_size": 18,
            "bold": true
          },
          {
            "level": 4,
            "min_size": 11,
            "max_size": 13,
            "bold": false,
            "italic": false
          }
        ]
      }
    },
    "html": {
      "exclude_tags_completely": [
        "script",
        "sup"
      ],
      "exclude_tags_keep_content": [
        "font",
        "em",
        "span"
      ],
      "exclude_content": {
        "xpaths": []
      },
      "keep_content": {
        "xpaths": []
      },
      "exclude_tag_attributes": [
        "EVENT_ACTIONS"
      ]
    },
    "json_normalizations": []
  },
  "enrichments": [
    {
      "destination_field": "enriched_text",
      "source_field": "text",
      "enrichment": "alchemy_language",
      "options": {
        "extract": [
          "keyword",
          "entity",
          "doc-sentiment",
          "taxonomy",
          "concept",
          "relation"
        ],
        "sentiment": true,
        "quotations": true
      }
    }
  ]
}
germanattanasio commented 6 years ago

closing due to inactivity