From 17eae392508480b677323a7a64f02fb6efb2fd68 Mon Sep 17 00:00:00 2001 From: Miguel Date: Wed, 22 May 2024 11:12:46 +0200 Subject: [PATCH] Modificado para que con Ortografia no muestre mas el resultado. Ademas se quitan los [[ ]] que fueron agregados para las palabras tecnicas --- App.xaml.cs | 10 +++++++--- Obsidean.cs | 16 ++++++++++++++++ Program.cs | 5 ++++- VentanaResultado.xaml | 2 +- gtpask.cs | 29 +++++++++++++++++++---------- 5 files changed, 47 insertions(+), 15 deletions(-) diff --git a/App.xaml.cs b/App.xaml.cs index 2440eb5..5ceb84b 100644 --- a/App.xaml.cs +++ b/App.xaml.cs @@ -36,7 +36,7 @@ namespace GTPCorrgir GTP.TextoACorregir = System.Windows.Clipboard.GetText(); } - if (Opciones.Instance.modo == Opciones.modoDeUso.Corregir) + if (Opciones.Instance.modo == Opciones.modoDeUso.Corregir || Opciones.Instance.modo == Opciones.modoDeUso.Ortografia) { stopwatch.Start(); @@ -68,10 +68,14 @@ namespace GTPCorrgir System.Windows.Clipboard.SetText(GTP.TextoCorregido); ShowCustomNotification("Se puede pegar", $"Corrección en : {Math.Round(stopwatch.ElapsedMilliseconds / 1000.0, 1)} s"); - var resultadoWindow = new VentanaResultado(GTP.TextoCorregido); - resultadoWindow.Show(); + if (Opciones.Instance.modo == Opciones.modoDeUso.Corregir) + { + var resultadoWindow = new VentanaResultado(GTP.TextoCorregido); + resultadoWindow.Show(); + } await Task.Delay(5000); // Asíncrono espera 5 segundos + Application.Current.Shutdown(); } else { diff --git a/Obsidean.cs b/Obsidean.cs index 416c193..60b275b 100644 --- a/Obsidean.cs +++ b/Obsidean.cs @@ -108,6 +108,22 @@ namespace GTPCorrgir }, RegexOptions.IgnoreCase); } + public string RemoveTechnicalTermMarkers(string text) + { + // Utilizar Regex para encontrar y remover los dobles corchetes + return Regex.Replace(text, @"\[\[(.*?)\]\]", match => + { + string word = match.Groups[1].Value; + // Verificar si la palabra está en el conjunto de términos técnicos, ignorando mayúsculas y minúsculas + if (technicalTerms.Contains(word)) + { + return word; // Devolver la palabra sin corchetes si es técnica + } + return match.Value; // Devolver la palabra con corchetes si no es técnica + }); + } + + } } diff --git a/Program.cs b/Program.cs index 3dff841..5b76a60 100644 --- a/Program.cs +++ b/Program.cs @@ -18,6 +18,7 @@ namespace GTPCorrgir public enum modoDeUso { Corregir, + Ortografia, Chat, } @@ -75,7 +76,9 @@ namespace GTPCorrgir else if (arg.StartsWith("--Groq")) Opciones.Instance.LLM = Opciones.LLM_a_Usar.Groq; else if (arg.StartsWith("--Chat")) - Opciones.Instance.modo = Opciones.modoDeUso.Chat; + Opciones.Instance.modo = Opciones.modoDeUso.Chat; + else if (arg.StartsWith("--Ortografia")) + Opciones.Instance.modo = Opciones.modoDeUso.Ortografia; } } diff --git a/VentanaResultado.xaml b/VentanaResultado.xaml index da86d1b..911cbd4 100644 --- a/VentanaResultado.xaml +++ b/VentanaResultado.xaml @@ -2,7 +2,7 @@ xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:local="clr-namespace:GTPCorrgir" - WindowStyle="None" AllowsTransparency="True" Background="Transparent" + WindowStyle="None" AllowsTransparency="True" Background="White" Topmost="True" ShowInTaskbar="False" MouseLeftButtonDown="Window_MouseLeftButtonDown"> diff --git a/gtpask.cs b/gtpask.cs index 01f0d03..32bc8d5 100644 --- a/gtpask.cs +++ b/gtpask.cs @@ -33,23 +33,32 @@ namespace GTPCorrgir public string TextoCorregido; public string TextodeSistema; private const bool Simulacion = false; - private string CrearMensajeDeSistema() { - if (Opciones.Instance.modo == Opciones.modoDeUso.Corregir) - return "You are an engineer working in industrial automation. Your task is to review texts and rewrite them in a simple and concise manner, making sure to preserve important technical terms and markdown language if present. Please rewrite the following text in " + IdiomaDetectado + " and respond in the following JSON format: { \"Rewritten_text\": \"Your text here\" }."; - else - return "You are an engineer working specialiazed industrial automation. Please answer the following question in " + IdiomaDetectado + " and respond in the following JSON format: { \"Reply_text\": \"Your text here\" }."; + switch (Opciones.Instance.modo) + { + case Opciones.modoDeUso.Corregir: + return "You are an engineer working in industrial automation. Your task is to review texts and rewrite them in a simple and concise manner, making sure to preserve important technical terms and markdown language if present. Please rewrite the following text in " + IdiomaDetectado + " and respond in the following JSON format: { \"Rewritten_text\": \"Your text here\" }."; + case Opciones.modoDeUso.Ortografia: + return "Please check the following text for spelling errors and provide the corrected version. Do not change the meaning or structure of the sentences. Only correct any spelling mistakes you find, making sure to preserve important technical terms and markdown language if present. Please write in " + IdiomaDetectado + " and respond in the following JSON format: { \"Rewritten_text\": \"Your text here\" }."; + default: + return "You are an engineer working specialiazed industrial automation. Please answer the following question in " + IdiomaDetectado + " and respond in the following JSON format: { \"Reply_text\": \"Your text here\" }."; + } } private string CrearMensajeDeUsuario(string texto) { - if (Opciones.Instance.modo == Opciones.modoDeUso.Corregir) - return "Please rewrite and improve the following text to make it clearer and more concise the words inside brackets are technical words: \"" + texto + "\""; - else - return texto; + switch (Opciones.Instance.modo) + { + case Opciones.modoDeUso.Corregir: + return "Please rewrite and improve the following text to make it clearer and more concise the words inside brackets are technical words: \"" + texto + "\""; + case Opciones.modoDeUso.Ortografia: + return "Please check the following text for spelling errors and provide the corrected version. Do not change the meaning or structure of the sentences. Only correct any spelling mistakes you find on: \"" + texto + "\""; + default: + return texto; + } } @@ -121,7 +130,7 @@ namespace GTPCorrgir TextoCorregido = "Error en la respuesta."; // Elimina comillas al principio y al final si existen - TextoCorregido = TextoCorregido.Trim('\"'); + TextoCorregido = md.RemoveTechnicalTermMarkers(TextoCorregido).Trim('\"'); Log.Log("Texto corregido: " + TextoCorregido); }