Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings
This repository was archived by the owner on Jan 15, 2025. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
35 changes: 34 additions & 1 deletion 35 packages/lu/src/parser/converters/luistocsconverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -17,6 +17,7 @@ module.exports = {
'public IDictionary<string, object> Properties {get; set; }'
]);
this.converter(className, writer);
this.onError(writer);
this.topScoringIntent(writer);
writer.decreaseIndentation();
writer.writeLineIndented('}'); // Class
Expand All @@ -33,6 +34,8 @@ module.exports = {
'// regenerated.',
'// </auto-generated>',
'using Newtonsoft.Json;',
'using Newtonsoft.Json.Serialization;',
'using System;',
'using System.Collections.Generic;',
'using Microsoft.Bot.Builder;',
'using Microsoft.Bot.Builder.AI.Luis;',
Expand Down Expand Up @@ -211,8 +214,23 @@ module.exports = {
'{'
]);
writer.increaseIndentation();
writer.writeLineIndented(
`var app = JsonConvert.DeserializeObject<${className}>(`,
);
writer.increaseIndentation();
writer.writeLineIndented(
'JsonConvert.SerializeObject('
);
writer.increaseIndentation();
writer.writeLineIndented([
'result,',
'new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Error = OnError }'
]);
writer.decreaseIndentation();
writer.writeLineIndented(')');
writer.decreaseIndentation();
writer.writeLineIndented([
`var app = JsonConvert.DeserializeObject<${className}>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));`,
');',
'Text = app.Text;',
'AlteredText = app.AlteredText;',
'Intents = app.Intents;',
Expand All @@ -222,6 +240,21 @@ module.exports = {
writer.decreaseIndentation();
writer.writeLineIndented('}');
},
onError: function(writer) {
writer.writeLine();
writer.writeLineIndented([
'private static void OnError(object sender, ErrorEventArgs args)',
'{'
]);
writer.increaseIndentation();
writer.writeLineIndented([
'// If needed, put your custom error logic here',
'Console.WriteLine(args.ErrorContext.Error.Message);',
'args.ErrorContext.Handled = true;'
]);
writer.decreaseIndentation();
writer.writeLineIndented('}');
},
topScoringIntent: function(writer) {
writer.writeLine();
writer.writeLineIndented([
Expand Down
16 changes: 15 additions & 1 deletion 16 packages/lu/test/fixtures/generate/ClosedLists.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
Expand Down Expand Up @@ -49,14 +51,26 @@ public class _Instance

public void Convert(dynamic result)
{
var app = JsonConvert.DeserializeObject<ContosoApp>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));
var app = JsonConvert.DeserializeObject<ContosoApp>(
JsonConvert.SerializeObject(
result,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Error = OnError }
)
);
Text = app.Text;
AlteredText = app.AlteredText;
Intents = app.Intents;
Entities = app.Entities;
Properties = app.Properties;
}

private static void OnError(object sender, ErrorEventArgs args)
{
// If needed, put your custom error logic here
Console.WriteLine(args.ErrorContext.Error.Message);
args.ErrorContext.Handled = true;
}

public (Intent intent, double score) TopIntent()
{
Intent maxIntent = Intent.None;
Expand Down
16 changes: 15 additions & 1 deletion 16 packages/lu/test/fixtures/generate/CompositeEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
Expand Down Expand Up @@ -63,14 +65,26 @@ public class _Instance

public void Convert(dynamic result)
{
var app = JsonConvert.DeserializeObject<ContosoApp>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));
var app = JsonConvert.DeserializeObject<ContosoApp>(
JsonConvert.SerializeObject(
result,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Error = OnError }
)
);
Text = app.Text;
AlteredText = app.AlteredText;
Intents = app.Intents;
Entities = app.Entities;
Properties = app.Properties;
}

private static void OnError(object sender, ErrorEventArgs args)
{
// If needed, put your custom error logic here
Console.WriteLine(args.ErrorContext.Error.Message);
args.ErrorContext.Handled = true;
}

public (Intent intent, double score) TopIntent()
{
Intent maxIntent = Intent.None;
Expand Down
16 changes: 15 additions & 1 deletion 16 packages/lu/test/fixtures/generate/ContosoApp.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
Expand Down Expand Up @@ -256,14 +258,26 @@ public class _Instance

public void Convert(dynamic result)
{
var app = JsonConvert.DeserializeObject<ContosoApp>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));
var app = JsonConvert.DeserializeObject<ContosoApp>(
JsonConvert.SerializeObject(
result,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Error = OnError }
)
);
Text = app.Text;
AlteredText = app.AlteredText;
Intents = app.Intents;
Entities = app.Entities;
Properties = app.Properties;
}

private static void OnError(object sender, ErrorEventArgs args)
{
// If needed, put your custom error logic here
Console.WriteLine(args.ErrorContext.Error.Message);
args.ErrorContext.Handled = true;
}

public (Intent intent, double score) TopIntent()
{
Intent maxIntent = Intent.None;
Expand Down
16 changes: 15 additions & 1 deletion 16 packages/lu/test/fixtures/generate/FlightBooking.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
Expand Down Expand Up @@ -80,14 +82,26 @@ public class _Instance

public void Convert(dynamic result)
{
var app = JsonConvert.DeserializeObject<FlightBooking>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));
var app = JsonConvert.DeserializeObject<FlightBooking>(
JsonConvert.SerializeObject(
result,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Error = OnError }
)
);
Text = app.Text;
AlteredText = app.AlteredText;
Intents = app.Intents;
Entities = app.Entities;
Properties = app.Properties;
}

private static void OnError(object sender, ErrorEventArgs args)
{
// If needed, put your custom error logic here
Console.WriteLine(args.ErrorContext.Error.Message);
args.ErrorContext.Handled = true;
}

public (Intent intent, double score) TopIntent()
{
Intent maxIntent = Intent.None;
Expand Down
16 changes: 15 additions & 1 deletion 16 packages/lu/test/fixtures/generate/Intents.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
Expand Down Expand Up @@ -52,14 +54,26 @@ public class _Instance

public void Convert(dynamic result)
{
var app = JsonConvert.DeserializeObject<ContosoApp>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));
var app = JsonConvert.DeserializeObject<ContosoApp>(
JsonConvert.SerializeObject(
result,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Error = OnError }
)
);
Text = app.Text;
AlteredText = app.AlteredText;
Intents = app.Intents;
Entities = app.Entities;
Properties = app.Properties;
}

private static void OnError(object sender, ErrorEventArgs args)
{
// If needed, put your custom error logic here
Console.WriteLine(args.ErrorContext.Error.Message);
args.ErrorContext.Handled = true;
}

public (Intent intent, double score) TopIntent()
{
Intent maxIntent = Intent.None;
Expand Down
16 changes: 15 additions & 1 deletion 16 packages/lu/test/fixtures/generate/NamespaceClass.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
Expand Down Expand Up @@ -63,14 +65,26 @@ public class _Instance

public void Convert(dynamic result)
{
var app = JsonConvert.DeserializeObject<NameOfTheClass>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));
var app = JsonConvert.DeserializeObject<NameOfTheClass>(
JsonConvert.SerializeObject(
result,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Error = OnError }
)
);
Text = app.Text;
AlteredText = app.AlteredText;
Intents = app.Intents;
Entities = app.Entities;
Properties = app.Properties;
}

private static void OnError(object sender, ErrorEventArgs args)
{
// If needed, put your custom error logic here
Console.WriteLine(args.ErrorContext.Error.Message);
args.ErrorContext.Handled = true;
}

public (Intent intent, double score) TopIntent()
{
Intent maxIntent = Intent.None;
Expand Down
16 changes: 15 additions & 1 deletion 16 packages/lu/test/fixtures/generate/PatternEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
Expand Down Expand Up @@ -53,14 +55,26 @@ public class _Instance

public void Convert(dynamic result)
{
var app = JsonConvert.DeserializeObject<ContosoApp>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));
var app = JsonConvert.DeserializeObject<ContosoApp>(
JsonConvert.SerializeObject(
result,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Error = OnError }
)
);
Text = app.Text;
AlteredText = app.AlteredText;
Intents = app.Intents;
Entities = app.Entities;
Properties = app.Properties;
}

private static void OnError(object sender, ErrorEventArgs args)
{
// If needed, put your custom error logic here
Console.WriteLine(args.ErrorContext.Error.Message);
args.ErrorContext.Handled = true;
}

public (Intent intent, double score) TopIntent()
{
Intent maxIntent = Intent.None;
Expand Down
16 changes: 15 additions & 1 deletion 16 packages/lu/test/fixtures/generate/PrebuiltEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
Expand Down Expand Up @@ -119,14 +121,26 @@ public class _Instance

public void Convert(dynamic result)
{
var app = JsonConvert.DeserializeObject<ContosoApp>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));
var app = JsonConvert.DeserializeObject<ContosoApp>(
JsonConvert.SerializeObject(
result,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Error = OnError }
)
);
Text = app.Text;
AlteredText = app.AlteredText;
Intents = app.Intents;
Entities = app.Entities;
Properties = app.Properties;
}

private static void OnError(object sender, ErrorEventArgs args)
{
// If needed, put your custom error logic here
Console.WriteLine(args.ErrorContext.Error.Message);
args.ErrorContext.Handled = true;
}

public (Intent intent, double score) TopIntent()
{
Intent maxIntent = Intent.None;
Expand Down
16 changes: 15 additions & 1 deletion 16 packages/lu/test/fixtures/generate/RegexEntities.cs
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using Newtonsoft.Json.Serialization;
using System;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
Expand Down Expand Up @@ -41,14 +43,26 @@ public class _Instance

public void Convert(dynamic result)
{
var app = JsonConvert.DeserializeObject<ContosoApp>(JsonConvert.SerializeObject(result, new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore }));
var app = JsonConvert.DeserializeObject<ContosoApp>(
JsonConvert.SerializeObject(
result,
new JsonSerializerSettings { NullValueHandling = NullValueHandling.Ignore, Error = OnError }
)
);
Text = app.Text;
AlteredText = app.AlteredText;
Intents = app.Intents;
Entities = app.Entities;
Properties = app.Properties;
}

private static void OnError(object sender, ErrorEventArgs args)
{
// If needed, put your custom error logic here
Console.WriteLine(args.ErrorContext.Error.Message);
args.ErrorContext.Handled = true;
}

public (Intent intent, double score) TopIntent()
{
Intent maxIntent = Intent.None;
Expand Down
Loading
Morty Proxy This is a proxified and sanitized view of the page, visit original site.