ChatBot in C#
This commit is contained in:
+22
@@ -0,0 +1,22 @@
|
||||
|
||||
Microsoft Visual Studio Solution File, Format Version 12.00
|
||||
# Visual Studio Version 17
|
||||
VisualStudioVersion = 17.0.31903.59
|
||||
MinimumVisualStudioVersion = 10.0.40219.1
|
||||
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "ChatBot", "ChatBot\ChatBot.csproj", "{E19F4577-A213-4A2A-A839-A8DAD17B54B6}"
|
||||
EndProject
|
||||
Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Release|Any CPU = Release|Any CPU
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{E19F4577-A213-4A2A-A839-A8DAD17B54B6}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{E19F4577-A213-4A2A-A839-A8DAD17B54B6}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{E19F4577-A213-4A2A-A839-A8DAD17B54B6}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{E19F4577-A213-4A2A-A839-A8DAD17B54B6}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
EndGlobalSection
|
||||
EndGlobal
|
||||
@@ -0,0 +1,10 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net9.0</TargetFramework>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,128 @@
|
||||
using System.Globalization;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using Microsoft.VisualBasic.FileIO;
|
||||
Dictionary<string, string> dialogs = new Dictionary<string, string>();
|
||||
Dictionary<string, string> otherDialogs = new Dictionary<string, string>();
|
||||
dialogs.Add("pedido", "Qual é o problema com o pedido?");
|
||||
dialogs.Add("atraso", "Certo, o pedido está em atraso...\nHá alguma ocorrência de atraso com esse número de pedido?");
|
||||
dialogs.Add("falta", "Hum... houve falta nesse pedido. Certo, esse produto foi faturado na nota fiscal?");
|
||||
dialogs.Add("resposta atraso sim 1", "Verifique as tarefas desta ocorrência e veja se alguma delas está dentro do prazo ou se estão todas encerradas. Se estiverem, encaminhe o caso para o suporte e aguarde a resposta.");
|
||||
dialogs.Add("resposta atraso nao 1", "Verifique com o cliente se ele ainda deseja receber o pedido.\nSe sim, abra uma ocorrência de atraso na entrega, descrevendo que o cliente deseja receber o pedido. Informe o SLA e o número de protocolo ao cliente.\nTabulação \nPrmeira categoria:Transporte \nSegunda categoria:Atraso na entrega \nMotivo:Pedido não entregue");
|
||||
dialogs.Add("resposta falta sim", "Abra uma ocorrência de falta de produto:\nCategoria: Pós-compra\nSubcategoria: Falta\nMotivo: Produto faturado.");
|
||||
dialogs.Add("resposta falta nao", "Então o produto não consta na nota fiscal? Ou ele foi cortado?");
|
||||
dialogs.Add("resposta nao consta", "Se o produto não consta na nota fiscal, então ele não foi pedido. Não é possível abrir uma ocorrência de falta de algo que não foi comprado.");
|
||||
dialogs.Add("resposta cortado", "Certo. Abra uma ocorrência de falta de produto:\nCategoria: Pós-compra\nSubcategoria: Falta\nMotivo: Produto não faturado.");
|
||||
dialogs.Add("Cadastro", "Cliente está com problema no cadastro? Qual a mensagem de erro?");
|
||||
dialogs.Add("Cadastro, CPF já cadastrado", "Quando ocorre esse erro Você tem quem reprocessar no GPP \nCaso não apareceça em 5 minutos \nPrencha esse formulário \nMatricula: \nCPF: \n Nome Completo: \nData de nascimento: \n Cep: \nEndereço completo: \nE-mail: \nTelefone de contato:");
|
||||
dialogs.Add("help", "Voce pode me perguntar sobre Pedidos, sobre o que fazer quando tem Atraso, se esta em Falta ou ate mesmo sobre o cadastro do cliente, caso deseje finalizar nossa coneversa digite 'sair' para encerrar.");
|
||||
otherDialogs.Add("erro", "Desculpe, não entendi. Pode reformular?");
|
||||
otherDialogs.Add("farewells", "Até mais! Volte sempre que precisar. 😊");
|
||||
otherDialogs.Add("welcome", "Olá! Meu nome é Rey. Com o que o cliente está tendo problema?");
|
||||
string RemoveAccents(string text)
|
||||
{
|
||||
var normalizedString = text.Normalize(NormalizationForm.FormD);
|
||||
var stringBuilder = new StringBuilder();
|
||||
|
||||
foreach (var c in normalizedString.EnumerateRunes())
|
||||
{
|
||||
var unicodeCategory = Rune.GetUnicodeCategory(c);
|
||||
if (unicodeCategory != UnicodeCategory.NonSpacingMark)
|
||||
{
|
||||
stringBuilder.Append(c);
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString().Normalize(NormalizationForm.FormC);
|
||||
}
|
||||
string RemovePunctuation(string texto)
|
||||
{
|
||||
var stringBuilder = new StringBuilder();
|
||||
foreach (char c in texto)
|
||||
{
|
||||
if(!char.IsPunctuation(c))
|
||||
{
|
||||
stringBuilder.Append(c);
|
||||
}
|
||||
}
|
||||
return stringBuilder.ToString();
|
||||
}
|
||||
string NormalizedText(string text)
|
||||
{
|
||||
text = text.ToLower();
|
||||
text = RemovePunctuation(text);
|
||||
text = RemoveAccents(text);
|
||||
return text;
|
||||
}
|
||||
void ConsoleResponse(string texto)
|
||||
{
|
||||
Console.WriteLine("ChatBot: "+texto);
|
||||
}
|
||||
void ChatBot()
|
||||
{
|
||||
ConsoleResponse(otherDialogs["welcome"]);
|
||||
string lastResponse = string.Empty;
|
||||
string response = string.Empty;
|
||||
while(true)
|
||||
{
|
||||
Console.Write("Você: ");
|
||||
string userInput = Console.ReadLine()!;
|
||||
string normalizedString = NormalizedText(userInput);
|
||||
if (normalizedString == "sair")
|
||||
{
|
||||
ConsoleResponse(otherDialogs["farewells"]);
|
||||
break;
|
||||
}else if (lastResponse == dialogs["atraso"])
|
||||
{
|
||||
if (normalizedString == "sim")
|
||||
{
|
||||
response = dialogs["resposta atraso sim"];
|
||||
}else if (normalizedString == "nao")
|
||||
{
|
||||
response = dialogs["resposta atraso nao"];
|
||||
}else
|
||||
{
|
||||
response = otherDialogs["erro"];
|
||||
}
|
||||
}else if (lastResponse == dialogs["falta"])
|
||||
{
|
||||
if (normalizedString == "sim")
|
||||
{
|
||||
response = dialogs["resposta falta sim"];
|
||||
}else if (normalizedString == "nao")
|
||||
{
|
||||
response = dialogs["resposta falta nao"];
|
||||
}else
|
||||
{
|
||||
response = otherDialogs["erro"];
|
||||
}
|
||||
}else if (lastResponse == dialogs["resposta falta nao"])
|
||||
{
|
||||
if (normalizedString == "sim")
|
||||
{
|
||||
response = dialogs["resposta nao consta"];
|
||||
}else if (normalizedString == "nao")
|
||||
{
|
||||
response = dialogs["resposta cortado"];
|
||||
}else
|
||||
{
|
||||
response = otherDialogs["erro"];
|
||||
}
|
||||
}else
|
||||
{
|
||||
foreach (string keyword in dialogs.Keys)
|
||||
{
|
||||
if (keyword == normalizedString)
|
||||
{
|
||||
response = dialogs[keyword];
|
||||
break;
|
||||
}else
|
||||
{
|
||||
response = otherDialogs["erro"];
|
||||
}
|
||||
}
|
||||
}
|
||||
ConsoleResponse(response);
|
||||
lastResponse = response;
|
||||
}
|
||||
}
|
||||
ChatBot();
|
||||
Executable
BIN
Binary file not shown.
@@ -0,0 +1,23 @@
|
||||
{
|
||||
"runtimeTarget": {
|
||||
"name": ".NETCoreApp,Version=v9.0",
|
||||
"signature": ""
|
||||
},
|
||||
"compilationOptions": {},
|
||||
"targets": {
|
||||
".NETCoreApp,Version=v9.0": {
|
||||
"ChatBot/1.0.0": {
|
||||
"runtime": {
|
||||
"ChatBot.dll": {}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"libraries": {
|
||||
"ChatBot/1.0.0": {
|
||||
"type": "project",
|
||||
"serviceable": false,
|
||||
"sha512": ""
|
||||
}
|
||||
}
|
||||
}
|
||||
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,12 @@
|
||||
{
|
||||
"runtimeOptions": {
|
||||
"tfm": "net9.0",
|
||||
"framework": {
|
||||
"name": "Microsoft.NETCore.App",
|
||||
"version": "9.0.0"
|
||||
},
|
||||
"configProperties": {
|
||||
"System.Runtime.Serialization.EnableUnsafeBinaryFormatterSerialization": false
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,68 @@
|
||||
{
|
||||
"format": 1,
|
||||
"restore": {
|
||||
"/home/ratix/Public/Csharp/ChatBot/ChatBot/ChatBot.csproj": {}
|
||||
},
|
||||
"projects": {
|
||||
"/home/ratix/Public/Csharp/ChatBot/ChatBot/ChatBot.csproj": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "/home/ratix/Public/Csharp/ChatBot/ChatBot/ChatBot.csproj",
|
||||
"projectName": "ChatBot",
|
||||
"projectPath": "/home/ratix/Public/Csharp/ChatBot/ChatBot/ChatBot.csproj",
|
||||
"packagesPath": "/home/ratix/.nuget/packages/",
|
||||
"outputPath": "/home/ratix/Public/Csharp/ChatBot/ChatBot/obj/",
|
||||
"projectStyle": "PackageReference",
|
||||
"configFilePaths": [
|
||||
"/home/ratix/.nuget/NuGet/NuGet.Config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
"net9.0"
|
||||
],
|
||||
"sources": {
|
||||
"/usr/lib/dotnet/library-packs": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"projectReferences": {}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
},
|
||||
"restoreAuditProperties": {
|
||||
"enableAudit": "true",
|
||||
"auditLevel": "low",
|
||||
"auditMode": "direct"
|
||||
},
|
||||
"SdkAnalysisLevel": "9.0.100"
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
"net47",
|
||||
"net471",
|
||||
"net472",
|
||||
"net48",
|
||||
"net481"
|
||||
],
|
||||
"assetTargetFallback": true,
|
||||
"warn": true,
|
||||
"frameworkReferences": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "/usr/lib/dotnet/sdk/9.0.103/PortableRuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,15 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
|
||||
<PropertyGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<RestoreSuccess Condition=" '$(RestoreSuccess)' == '' ">True</RestoreSuccess>
|
||||
<RestoreTool Condition=" '$(RestoreTool)' == '' ">NuGet</RestoreTool>
|
||||
<ProjectAssetsFile Condition=" '$(ProjectAssetsFile)' == '' ">$(MSBuildThisFileDirectory)project.assets.json</ProjectAssetsFile>
|
||||
<NuGetPackageRoot Condition=" '$(NuGetPackageRoot)' == '' ">/home/ratix/.nuget/packages/</NuGetPackageRoot>
|
||||
<NuGetPackageFolders Condition=" '$(NuGetPackageFolders)' == '' ">/home/ratix/.nuget/packages/</NuGetPackageFolders>
|
||||
<NuGetProjectStyle Condition=" '$(NuGetProjectStyle)' == '' ">PackageReference</NuGetProjectStyle>
|
||||
<NuGetToolVersion Condition=" '$(NuGetToolVersion)' == '' ">6.12.2</NuGetToolVersion>
|
||||
</PropertyGroup>
|
||||
<ItemGroup Condition=" '$(ExcludeRestorePackageImports)' != 'true' ">
|
||||
<SourceRoot Include="/home/ratix/.nuget/packages/" />
|
||||
</ItemGroup>
|
||||
</Project>
|
||||
@@ -0,0 +1,2 @@
|
||||
<?xml version="1.0" encoding="utf-8" standalone="no"?>
|
||||
<Project ToolsVersion="14.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003" />
|
||||
@@ -0,0 +1,4 @@
|
||||
// <autogenerated />
|
||||
using System;
|
||||
using System.Reflection;
|
||||
[assembly: global::System.Runtime.Versioning.TargetFrameworkAttribute(".NETCoreApp,Version=v9.0", FrameworkDisplayName = ".NET 9.0")]
|
||||
@@ -0,0 +1,22 @@
|
||||
//------------------------------------------------------------------------------
|
||||
// <auto-generated>
|
||||
// This code was generated by a tool.
|
||||
//
|
||||
// Changes to this file may cause incorrect behavior and will be lost if
|
||||
// the code is regenerated.
|
||||
// </auto-generated>
|
||||
//------------------------------------------------------------------------------
|
||||
|
||||
using System;
|
||||
using System.Reflection;
|
||||
|
||||
[assembly: System.Reflection.AssemblyCompanyAttribute("ChatBot")]
|
||||
[assembly: System.Reflection.AssemblyConfigurationAttribute("Debug")]
|
||||
[assembly: System.Reflection.AssemblyFileVersionAttribute("1.0.0.0")]
|
||||
[assembly: System.Reflection.AssemblyInformationalVersionAttribute("1.0.0")]
|
||||
[assembly: System.Reflection.AssemblyProductAttribute("ChatBot")]
|
||||
[assembly: System.Reflection.AssemblyTitleAttribute("ChatBot")]
|
||||
[assembly: System.Reflection.AssemblyVersionAttribute("1.0.0.0")]
|
||||
|
||||
// Generated by the MSBuild WriteCodeFragment class.
|
||||
|
||||
@@ -0,0 +1 @@
|
||||
2808eda853cdcc375f9ab3aee93cb821821745458823c10ec082428829ca9987
|
||||
@@ -0,0 +1,15 @@
|
||||
is_global = true
|
||||
build_property.TargetFramework = net9.0
|
||||
build_property.TargetPlatformMinVersion =
|
||||
build_property.UsingMicrosoftNETSdkWeb =
|
||||
build_property.ProjectTypeGuids =
|
||||
build_property.InvariantGlobalization =
|
||||
build_property.PlatformNeutralAssembly =
|
||||
build_property.EnforceExtendedAnalyzerRules =
|
||||
build_property._SupportedPlatformList = Linux,macOS,Windows
|
||||
build_property.RootNamespace = ChatBot
|
||||
build_property.ProjectDir = /home/ratix/Public/Csharp/ChatBot/ChatBot/
|
||||
build_property.EnableComHosting =
|
||||
build_property.EnableGeneratedComInterfaceComImportInterop =
|
||||
build_property.EffectiveAnalysisLevelStyle = 9.0
|
||||
build_property.EnableCodeStyleSeverity =
|
||||
@@ -0,0 +1,8 @@
|
||||
// <auto-generated/>
|
||||
global using global::System;
|
||||
global using global::System.Collections.Generic;
|
||||
global using global::System.IO;
|
||||
global using global::System.Linq;
|
||||
global using global::System.Net.Http;
|
||||
global using global::System.Threading;
|
||||
global using global::System.Threading.Tasks;
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
a2c526e10e0d5e3da96149988541bfb0b5af5624427791be8fcfef69b635753f
|
||||
@@ -0,0 +1,14 @@
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/bin/Debug/net9.0/ChatBot
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/bin/Debug/net9.0/ChatBot.deps.json
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/bin/Debug/net9.0/ChatBot.runtimeconfig.json
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/bin/Debug/net9.0/ChatBot.dll
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/bin/Debug/net9.0/ChatBot.pdb
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/obj/Debug/net9.0/ChatBot.GeneratedMSBuildEditorConfig.editorconfig
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/obj/Debug/net9.0/ChatBot.AssemblyInfoInputs.cache
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/obj/Debug/net9.0/ChatBot.AssemblyInfo.cs
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/obj/Debug/net9.0/ChatBot.csproj.CoreCompileInputs.cache
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/obj/Debug/net9.0/ChatBot.dll
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/obj/Debug/net9.0/refint/ChatBot.dll
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/obj/Debug/net9.0/ChatBot.pdb
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/obj/Debug/net9.0/ChatBot.genruntimeconfig.cache
|
||||
/home/ratix/Public/Csharp/ChatBot/ChatBot/obj/Debug/net9.0/ref/ChatBot.dll
|
||||
Binary file not shown.
@@ -0,0 +1 @@
|
||||
c54a66318e6cd0a9eaad536a582637c78466007c1f353db95471ac73a02e280b
|
||||
Binary file not shown.
Executable
BIN
Binary file not shown.
Binary file not shown.
Binary file not shown.
@@ -0,0 +1,73 @@
|
||||
{
|
||||
"version": 3,
|
||||
"targets": {
|
||||
"net9.0": {}
|
||||
},
|
||||
"libraries": {},
|
||||
"projectFileDependencyGroups": {
|
||||
"net9.0": []
|
||||
},
|
||||
"packageFolders": {
|
||||
"/home/ratix/.nuget/packages/": {}
|
||||
},
|
||||
"project": {
|
||||
"version": "1.0.0",
|
||||
"restore": {
|
||||
"projectUniqueName": "/home/ratix/Public/Csharp/ChatBot/ChatBot/ChatBot.csproj",
|
||||
"projectName": "ChatBot",
|
||||
"projectPath": "/home/ratix/Public/Csharp/ChatBot/ChatBot/ChatBot.csproj",
|
||||
"packagesPath": "/home/ratix/.nuget/packages/",
|
||||
"outputPath": "/home/ratix/Public/Csharp/ChatBot/ChatBot/obj/",
|
||||
"projectStyle": "PackageReference",
|
||||
"configFilePaths": [
|
||||
"/home/ratix/.nuget/NuGet/NuGet.Config"
|
||||
],
|
||||
"originalTargetFrameworks": [
|
||||
"net9.0"
|
||||
],
|
||||
"sources": {
|
||||
"/usr/lib/dotnet/library-packs": {},
|
||||
"https://api.nuget.org/v3/index.json": {}
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"projectReferences": {}
|
||||
}
|
||||
},
|
||||
"warningProperties": {
|
||||
"warnAsError": [
|
||||
"NU1605"
|
||||
]
|
||||
},
|
||||
"restoreAuditProperties": {
|
||||
"enableAudit": "true",
|
||||
"auditLevel": "low",
|
||||
"auditMode": "direct"
|
||||
},
|
||||
"SdkAnalysisLevel": "9.0.100"
|
||||
},
|
||||
"frameworks": {
|
||||
"net9.0": {
|
||||
"targetAlias": "net9.0",
|
||||
"imports": [
|
||||
"net461",
|
||||
"net462",
|
||||
"net47",
|
||||
"net471",
|
||||
"net472",
|
||||
"net48",
|
||||
"net481"
|
||||
],
|
||||
"assetTargetFallback": true,
|
||||
"warn": true,
|
||||
"frameworkReferences": {
|
||||
"Microsoft.NETCore.App": {
|
||||
"privateAssets": "all"
|
||||
}
|
||||
},
|
||||
"runtimeIdentifierGraphPath": "/usr/lib/dotnet/sdk/9.0.103/PortableRuntimeIdentifierGraph.json"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,8 @@
|
||||
{
|
||||
"version": 2,
|
||||
"dgSpecHash": "FAFvucqaMvk=",
|
||||
"success": true,
|
||||
"projectFilePath": "/home/ratix/Public/Csharp/ChatBot/ChatBot/ChatBot.csproj",
|
||||
"expectedPackageFiles": [],
|
||||
"logs": []
|
||||
}
|
||||
Reference in New Issue
Block a user