Permalink
Browse files

Merge remote-tracking branch 'denselmann/feature/custom-entities' int…

…o feature/custom-entities
  • Loading branch information...
antoniusostermann committed Nov 8, 2018
2 parents ef57576 + 2c0b732 commit 313a7a376be98794baca3855782c73435ee8dc64
@@ -41,11 +41,6 @@ export const descriptor: ComponentDescriptor<Configuration.Defaults> = {
return swapHash(context.container.get<Component<Configuration.Runtime>>("meta:component//core:unifier").configuration.entities);
});
// Bind same swapped entity configuration to own extension
bindService
.bindExtension<PlatformGenerator.EntityMapping>(componentInterfaces.entityMapping)
.toDynamicValue(context => context.container.get<PlatformGenerator.EntityMapping>("core:unifier:user-entity-mappings"));
// Bind same swapped entity configuration to own extension
bindService
.bindExtension<PlatformGenerator.EntityMapping>(componentInterfaces.entityMapping)
@@ -99,7 +99,7 @@ export class Generator implements CLIGeneratorExtension {
...new Set(
intentUtterances
// Match all entities
.map(utterance => utterance.match(/(?<=\{\{[A-Za-z0-9_äÄöÖüÜß,;'"\|\s]*)(\w)+(?=\}\})/g))
.map(utterance => utterance.match(/(?<=\{\{)(\w)+(?=\}\})/g))
// Flatten array
.reduce((prev, curr) => {
if (curr !== null) {
@@ -166,8 +166,7 @@ export class Generator implements CLIGeneratorExtension {
// Extract all slots and substitute them with a placeholder
templates.map(template => {
const slots: string[][] = [];
const repTemplate = template.replace(/\{([A-Za-z0-9_äÄöÖüÜß,;'"()-\|\s]+)\}(?!\})/g, (match: string, param: string) => {
const repTemplate = template.replace(/\{([^}]+)\}(?!\})/g, (match: string, param: string) => {
slots.push(param.split("|"));
return `{${slots.length - 1}}`;
});
@@ -180,12 +179,11 @@ export class Generator implements CLIGeneratorExtension {
preUtterances.push(template);
}
});
// Extract entities and expland utterances with entity combinations
preUtterances.map(utterance => {
const slots: string[][] = [];
const repUtterance = utterance.replace(/(?<=\{\{)([A-Za-z0-9_äÄöÖüÜß,;'"()-\|\s]+)\|?(\w+)*(?=\}\})/g, (match: string, entityValue: string) => {
const repUtterance = utterance.replace(/(?<=\{\{)(.+)\|?(\w+)*(?=\}\})/g, (match: string, entityValue: string) => {
const entityName = match.split("|").pop();
// Iterate through values when no example like {{example|entity}} is given
@@ -5,8 +5,7 @@ export const componentInterfaces = {
platformGenerator: Symbol("platform-generator"),
requestProcessor: Symbol("request-processor"),
requestModifier: Symbol("request-modifier"),
utteranceTemplateService: Symbol("utterance-template-service"),
entityMapper: Symbol("entity-mapping"),
utteranceTemplateService: Symbol("utterance-template-service")
};
export namespace Configuration {

0 comments on commit 313a7a3

Please sign in to comment.