public RecordingText(InterpretationResult interpretation, AudioBinary audioBinary) { if (interpretation == null) { throw new InvalidOperationException("Inerpretation must contain data!"); } Text = interpretation.ResultText; InterpreterName = interpretation.InterpreterName; AudioBinary = audioBinary; }
public override InterpretationResult Interpret(System.Xml.XmlElement _node, Scope _scope) { Infinity_Grammar_Script_1_0 type = (Infinity_Grammar_Script_1_0)Enum.Parse(typeof(Infinity_Grammar_Script_1_0), _node.Name); Variable value = null; InterpretationResult result = new InterpretationResult(); switch (type) { } return(null); }
private async Task HandleInterpretationResult(InterpretationResult result, BehaviorContext context) { if (result.State == InterpretationResultState.Failed) { _logger.LogError($"Interpretation step failed. BotId: {context.ServiceContext.BotId}"); await _outgoingServicePool.Resolve(context.ServiceContext.TransportName).SendAsync("Невозможно выполнить команду. Обратитесь к системному администратору.", context.Client.Id); //todo: обработка ошибки интерпретации } if (result.ResultType == Interpreter.Expressions.ExpressionResultType.TransportCommand) { result.Command.ConnectionId = context.ConnectionId; await _outgoingServicePool.Resolve(context.ServiceContext.TransportName).SendAsync(result.Command); } }
private async Task <string> GetAnswerAsync(InterpretationResult interpretation) { if (interpretation.IsCompleted) { return interpretation.DetectedIntent switch { IntentType.DefinitionIntent => await _knowledgeRepository.GetDefinitionAsync( interpretation.Parameters["definitiontype"], interpretation.Parameters["keyword"]) .ConfigureAwait(false) ?? "Entschuldige, das kann ich leider nicht erklären!", IntentType.DefaultFallback => "Entschuldige, das habe ich nicht verstanden. Kannst du das noch einmal anders formulieren?", _ => throw new ArgumentOutOfRangeException() } } ; return(interpretation.AnswerString); }
public async Task <InterpretationResult> InterpretAsync(IPlatformDatabase database, Dialog dialog) { var parameters = _parameters.Split(' ').Select(x => x.Trim()); var result = new InterpretationResult { Result = false, ResultType = ExpressionResultType.Boolean }; foreach (var p in parameters) { if (dialog.CurrentMessage.Payload.Contains(p, System.StringComparison.OrdinalIgnoreCase)) { result.Result = true; } } return(result); }
/// <summary> /// Processes the next node of the dialog. /// Returns that the node can be interpreted (that is to say it is neither undefined nor an end of dialog). /// </summary> /// <param name="nextDelay">The delay to wait before processing the next node, according to the dialog graph.</param> /// <returns>Returns that the node can be interpreted (that is to say it is neither undefined nor an end of dialog).</returns> public virtual bool ProcessNextNode(out float nextDelay) { InterpretationResult result = dialogInterpreter.InterpretNextNode(); float replyLength = 0; switch (result.ResultType) { case InterpretationResultType.UNDEFINED: case InterpretationResultType.FLOW_NODE: break; case InterpretationResultType.SAY_REPLICA: replyLength = SayReply(result.Reply, result.Target); break; case InterpretationResultType.CHOICE: ProcessChoice(result.Choice); break; } nextDelay = result.Delay + replyLength; // The delay specified in the node + the time needed to say the reply entirely, if the node is a reply node return(result.ResultType != InterpretationResultType.END_OF_DIALOG && result.ResultType != InterpretationResultType.UNDEFINED); }
private void SetFromRegex(string regex) { this.RegularExpression = regex; this.Result = InterpretationResult.Custom; this.EditText = this.RegularExpression; if (regex == ".*") { this.DisplayText = "(any)"; this.Result = InterpretationResult.Any; } //else if (regex == @".*\..*") //{ // this.DisplayText = "(any with extension)"; // this.EditText = ""; // this.Result = InterpretationResult.Any; //} else if (Regex.IsMatch(regex, @"^\^[a-zA-Z0-9_]+$\$?")) { if (regex[regex.Length - 1] == '$') { this.DisplayText = regex.Substring(1, regex.Length - 2); this.EditText = this.DisplayText; this.Result = InterpretationResult.Name; } else { this.DisplayText = regex.Substring(1); this.EditText = this.DisplayText; this.Result = InterpretationResult.StartsWith; } } else if (Regex.IsMatch(regex, @"^\^?[a-zA-Z0-9_]+\$$")) { if (regex[0] == '^') { this.DisplayText = regex.Substring(1, regex.Length - 2); this.EditText = this.DisplayText; this.Result = InterpretationResult.Name; } else { this.DisplayText = regex.Substring(0, regex.Length - 1); this.EditText = this.DisplayText; this.Result = InterpretationResult.EndsWith; } } else if (this.treatAsFileName) { var match = Regex.Match(regex, @"^\^?\.*\\.([a-z0-9]+)"); if (match.Success) { this.DisplayText = "*." + match.Groups[1].Value; this.EditText = match.Groups[1].Value; this.Result = InterpretationResult.Extension; } else { match = Regex.Match(regex, @"^\^?\.\*\\\.\[(\w{2})\]\[(\w{2})\]\[(\w{2})\]\$$"); if (match.Success) { var f1 = match.Groups[1].Value.ToLowerInvariant(); var f2 = match.Groups[2].Value.ToLowerInvariant(); var f3 = match.Groups[3].Value.ToLowerInvariant(); if (f1[0] == f1[1] && f2[0] == f2[1] && f3[0] == f3[1]) { this.DisplayText = "*." + f1[0] + f2[0] + f3[0]; this.EditText = "" + f1[0] + f2[0] + f3[0]; this.Result = InterpretationResult.Extension; } } else { match = Regex.Match(regex, @"^\^?([^\\?*\.\^\$\(\)\[\]]+)\\.([^\\?*\.\^\$\(\)\[\]]+)\$$"); if (match.Success) { if (match.Value[0] == '^') { this.DisplayText = match.Groups[1].Value + "." + match.Groups[2].Value; this.EditText = this.DisplayText; this.Result = InterpretationResult.Name; } else { this.DisplayText = match.Groups[1].Value + "." + match.Groups[2].Value; this.EditText = this.DisplayText; this.Result = InterpretationResult.EndsWith; } } } } } }