Skip to content

Commit

Permalink
Merge branch 'master' into vishwac/lu-phraselist-fix
Browse files Browse the repository at this point in the history
  • Loading branch information
vishwacsena committed Nov 11, 2019
2 parents 8038442 + 6a93b22 commit 3e92306
Show file tree
Hide file tree
Showing 8 changed files with 537 additions and 3 deletions.
2 changes: 1 addition & 1 deletion packages/dialog/test/commands/dialog/merge.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ describe('Test schema merge', async () => {
await tracker.addDialogFiles(["examples/*.dialog"]);
});

it('packages', async () => {
xit('packages', async () => {
let json = await fs.readJSON("examples/packages.schema");
expect(json.definitions.packages, "Failed reading packages.config");
expect(json.definitions.CSProj, "Failed reading CSProj");
Expand Down
2 changes: 1 addition & 1 deletion packages/lu/src/parser/converters/luistocsconverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ module.exports = {
]);
writer.increaseIndentation();
composite.attributes.forEach(attr => {
writer.writeLineIndented(getEntityWithType(attr, app.listEntities.includes(attr) ? 'list' : attr));
writer.writeLineIndented(this.getEntityWithType(attr, app.listEntities.includes(attr) ? 'list' : attr));
});
writer.writeLineIndented([
'[JsonProperty("$instance")]',
Expand Down
2 changes: 1 addition & 1 deletion packages/lu/src/parser/converters/luistotsconverter.js
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ module.exports = {
writer.writeLineIndented(`export interface ${name} {`);
writer.increaseIndentation();
composite.attributes.forEach(attribute => {
writer.writeLineIndented(getEntityWithType(attribute, isList(attribute, app)));
writer.writeLineIndented(this.getEntityWithType(attribute, this.isList(attribute, app)));
});
writer.writeLineIndented(`$instance?: GeneratedInstance${name}`);
writer.decreaseIndentation();
Expand Down
11 changes: 11 additions & 0 deletions packages/lu/test/commands/luis/generate/cs.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -107,6 +107,17 @@ describe('luis:generate:cs', () => {
expect(ctx.stderr).to.include('Invalid LUIS JSON file content.')
})

test
.stdout()
.command(['luis:generate:cs',
'--in',
`${path.join(__dirname, '../../../fixtures/generate/FlightBooking.json')}`,
'--out',
`${path.join(__dirname, '../../../fixtures/generate/results/FlightBooking.cs')}`])
.it('FlightBooking sample json generated correct cs class', async () => {
await compareSourceFiles('../../../fixtures/generate/FlightBooking.cs', '../../../fixtures/generate/results/FlightBooking.cs')
})

test
.stdout()
.command(['luis:generate:cs',
Expand Down
12 changes: 12 additions & 0 deletions packages/lu/test/commands/luis/generate/ts.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -63,6 +63,18 @@ describe('luis:generate:ts', () => {
await compareSourceFiles('../../../fixtures/generate/closed-lists.ts', '../../../fixtures/generate/results/closed-lists.ts')
})


test
.stdout()
.command(['luis:generate:ts',
'--in',
`${path.join(__dirname, '../../../fixtures/generate/FlightBooking.json')}`,
'--out',
`${path.join(__dirname, '../../../fixtures/generate/results/FlightBooking.ts')}`])
.it('FlightBooking sample json generated correct ts class', async () => {
await compareSourceFiles('../../../fixtures/generate/FlightBooking.ts', '../../../fixtures/generate/results/FlightBooking.ts')
})

test
.stdout()
.command(['luis:generate:ts',
Expand Down
106 changes: 106 additions & 0 deletions packages/lu/test/fixtures/generate/FlightBooking.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,106 @@
// <auto-generated>
// Code generated by luis:generate:cs
// Tool github: https://github.com/microsoft/botframwork-cli
// Changes may cause incorrect behavior and will be lost if the code is
// regenerated.
// </auto-generated>
using Newtonsoft.Json;
using System.Collections.Generic;
using Microsoft.Bot.Builder;
using Microsoft.Bot.Builder.AI.Luis;
namespace Luis
{
public partial class FlightBooking: IRecognizerConvert
{
[JsonProperty("text")]
public string Text;

[JsonProperty("alteredText")]
public string AlteredText;

public enum Intent {
BookFlight,
Cancel,
GetWeather,
None
};
[JsonProperty("intents")]
public Dictionary<Intent, IntentScore> Intents;

public class _Entities
{
// Built-in entities
public DateTimeSpec[] datetime;

// Lists
public string[][] Airport;


// Composites
public class _InstanceFrom
{
public InstanceData[] Airport;
}
public class FromClass
{
public string[][] Airport;
[JsonProperty("$instance")]
public _InstanceFrom _instance;
}
public FromClass[] From;

public class _InstanceTo
{
public InstanceData[] Airport;
}
public class ToClass
{
public string[][] Airport;
[JsonProperty("$instance")]
public _InstanceTo _instance;
}
public ToClass[] To;

// Instance
public class _Instance
{
public InstanceData[] Airport;
public InstanceData[] From;
public InstanceData[] To;
public InstanceData[] datetime;
}
[JsonProperty("$instance")]
public _Instance _instance;
}
[JsonProperty("entities")]
public _Entities Entities;

[JsonExtensionData(ReadData = true, WriteData = true)]
public IDictionary<string, object> Properties {get; set; }

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

public (Intent intent, double score) TopIntent()
{
Intent maxIntent = Intent.None;
var max = 0.0;
foreach (var entry in Intents)
{
if (entry.Value.Score > max)
{
maxIntent = entry.Key;
max = entry.Value.Score.Value;
}
}
return (maxIntent, max);
}
}
}
Loading

0 comments on commit 3e92306

Please sign in to comment.