Skip to content

Commit

Permalink
fix(nlu): hand edits
Browse files Browse the repository at this point in the history
  • Loading branch information
apaparazzi0329 committed Mar 17, 2023
1 parent 1b032ce commit de18cc7
Show file tree
Hide file tree
Showing 4 changed files with 3 additions and 202 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class StatusEnumValue
/// An optional map of metadata key-value pairs to store with this model.
/// </summary>
[JsonProperty("user_metadata", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, Dictionary> UserMetadata { get; set; }
public Dictionary<string, object> UserMetadata { get; set; }
/// <summary>
/// The 2-letter language code of this model.
/// </summary>
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public class StatusEnumValue
/// An optional map of metadata key-value pairs to store with this model.
/// </summary>
[JsonProperty("user_metadata", NullValueHandling = NullValueHandling.Ignore)]
public Dictionary<string, Dictionary> UserMetadata { get; set; }
public Dictionary<string, object> UserMetadata { get; set; }
/// <summary>
/// The 2-letter language code of this model.
/// </summary>
Expand Down

This file was deleted.

Original file line number Diff line number Diff line change
Expand Up @@ -314,171 +314,7 @@ public void AnalyzeWithSyntax()
Assert.IsTrue(result.Result.Syntax.Sentences.Count > 0);
Assert.IsTrue(result.Result.Syntax.Sentences[0].Text == "With great power comes great responsibility");
}


#region SentimentModel
[TestMethod]
public void TestCreateSentimentModel()
{
service.WithHeader("X-Watson-Test", "1");
MemoryStream trainingData = new MemoryStream(ASCIIEncoding.Default.GetBytes("This is a mock file."));

var response = service.CreateSentimentModel(
language: "en",
trainingData: trainingData,
name: "testString",
description: "testString",
modelVersion: "testString",
versionDescription: "testString"
);

Assert.IsNotNull(response.Result);
Assert.AreEqual(response.Result.Name, "testString");
Assert.AreEqual(response.Result.Language, "en");
Assert.AreEqual(response.Result.Description, "testString");
Assert.AreEqual(response.Result.ModelVersion, "testString");
Assert.AreEqual(response.Result.VersionDescription, "testString");

service.DeleteSentimentModel(
modelId: response.Result.ModelId
);
}

[TestMethod]
public void TestListSentimentModels()
{
service.WithHeader("X-Watson-Test", "1");
var response = service.ListSentimentModels();

Assert.IsNotNull(response.Result.Models);

foreach(SentimentModel sentimentModel in response.Result.Models)
{
if (sentimentModel.Name.StartsWith("testString"))
{
service.DeleteSentimentModel(
modelId: sentimentModel.ModelId
);
}
}
}

[TestMethod]
public void TestUpdateSentimentModel()
{
service.WithHeader("X-Watson-Test", "1");

string modelId = "";
try
{
MemoryStream trainingData = new MemoryStream(ASCIIEncoding.Default.GetBytes("This is a mock file."));

var response = service.CreateSentimentModel(
language: "en",
trainingData: trainingData,
name: "testString",
description: "testString",
modelVersion: "testString",
versionDescription: "testString"
);

Assert.IsNotNull(response.Result);
Assert.AreEqual(response.Result.Name, "testString");
Assert.AreEqual(response.Result.Language, "en");
Assert.AreEqual(response.Result.Description, "testString");
Assert.AreEqual(response.Result.ModelVersion, "testString");
Assert.AreEqual(response.Result.VersionDescription, "testString");

modelId = response.Result.ModelId;

var response2 = service.UpdateSentimentModel(
description: "newString",
name: "newString",
modelId: modelId,
language: "en",
trainingData: trainingData
);

Assert.IsNotNull(response2.Result);
Assert.AreEqual(response2.Result.Name, "newString");
Assert.AreEqual(response2.Result.Language, "en");
Assert.AreEqual(response2.Result.Description, "newString");
Assert.AreEqual(response2.Result.ModelVersion, "testString");
Assert.AreEqual(response2.Result.VersionDescription, "testString");

}
catch (Exception ex)
{
Console.WriteLine(ex.StackTrace);
}
finally
{
if (modelId != "")
{
service.DeleteSentimentModel(
modelId: modelId
);
}

}
}

[TestMethod]
public void TestGetSentimentModel()
{
service.WithHeader("X-Watson-Test", "1");

string modelId = "";
try
{
MemoryStream trainingData = new MemoryStream(ASCIIEncoding.Default.GetBytes("This is a mock file."));

var response = service.CreateSentimentModel(
language: "en",
trainingData: trainingData,
name: "testString",
description: "testString",
modelVersion: "testString",
versionDescription: "testString"
);

Assert.IsNotNull(response.Result);
Assert.AreEqual(response.Result.Name, "testString");
Assert.AreEqual(response.Result.Language, "en");
Assert.AreEqual(response.Result.Description, "testString");
Assert.AreEqual(response.Result.ModelVersion, "testString");
Assert.AreEqual(response.Result.VersionDescription, "testString");

modelId = response.Result.ModelId;

var response2 = service.GetSentimentModel(
modelId: modelId
);

Assert.IsNotNull(response2.Result);
Assert.AreEqual(response2.Result.Name, "testString");
Assert.AreEqual(response2.Result.Language, "en");
Assert.AreEqual(response2.Result.Description, "testString");
Assert.AreEqual(response2.Result.ModelVersion, "testString");
Assert.AreEqual(response2.Result.VersionDescription, "testString");

}
catch (Exception ex)
{
Console.WriteLine(ex.StackTrace);
}
finally
{
if (modelId != "")
{
service.DeleteSentimentModel(
modelId: modelId
);
}

}
}
#endregion


#region CategoriesModel
[TestMethod]
Expand Down

0 comments on commit de18cc7

Please sign in to comment.