Modificado para que con Ortografia no muestre mas el resultado. Ademas se quitan los [[ ]] que fueron agregados para las palabras tecnicas

This commit is contained in:
Miguel 2024-05-22 11:12:46 +02:00
parent fe707ea7fb
commit 17eae39250
5 changed files with 47 additions and 15 deletions

View File

@ -36,7 +36,7 @@ namespace GTPCorrgir
GTP.TextoACorregir = System.Windows.Clipboard.GetText(); 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(); stopwatch.Start();
@ -68,10 +68,14 @@ namespace GTPCorrgir
System.Windows.Clipboard.SetText(GTP.TextoCorregido); System.Windows.Clipboard.SetText(GTP.TextoCorregido);
ShowCustomNotification("Se puede pegar", $"Corrección en : {Math.Round(stopwatch.ElapsedMilliseconds / 1000.0, 1)} s"); ShowCustomNotification("Se puede pegar", $"Corrección en : {Math.Round(stopwatch.ElapsedMilliseconds / 1000.0, 1)} s");
var resultadoWindow = new VentanaResultado(GTP.TextoCorregido); if (Opciones.Instance.modo == Opciones.modoDeUso.Corregir)
resultadoWindow.Show(); {
var resultadoWindow = new VentanaResultado(GTP.TextoCorregido);
resultadoWindow.Show();
}
await Task.Delay(5000); // Asíncrono espera 5 segundos await Task.Delay(5000); // Asíncrono espera 5 segundos
Application.Current.Shutdown();
} }
else else
{ {

View File

@ -108,6 +108,22 @@ namespace GTPCorrgir
}, RegexOptions.IgnoreCase); }, 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
});
}
} }
} }

View File

@ -18,6 +18,7 @@ namespace GTPCorrgir
public enum modoDeUso public enum modoDeUso
{ {
Corregir, Corregir,
Ortografia,
Chat, Chat,
} }
@ -75,7 +76,9 @@ namespace GTPCorrgir
else if (arg.StartsWith("--Groq")) else if (arg.StartsWith("--Groq"))
Opciones.Instance.LLM = Opciones.LLM_a_Usar.Groq; Opciones.Instance.LLM = Opciones.LLM_a_Usar.Groq;
else if (arg.StartsWith("--Chat")) 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;
} }
} }

View File

@ -2,7 +2,7 @@
xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation" xmlns="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml"
xmlns:local="clr-namespace:GTPCorrgir" xmlns:local="clr-namespace:GTPCorrgir"
WindowStyle="None" AllowsTransparency="True" Background="Transparent" WindowStyle="None" AllowsTransparency="True" Background="White"
Topmost="True" ShowInTaskbar="False" Topmost="True" ShowInTaskbar="False"
MouseLeftButtonDown="Window_MouseLeftButtonDown"> MouseLeftButtonDown="Window_MouseLeftButtonDown">

View File

@ -33,23 +33,32 @@ namespace GTPCorrgir
public string TextoCorregido; public string TextoCorregido;
public string TextodeSistema; public string TextodeSistema;
private const bool Simulacion = false; private const bool Simulacion = false;
private string CrearMensajeDeSistema() private string CrearMensajeDeSistema()
{ {
if (Opciones.Instance.modo == Opciones.modoDeUso.Corregir) switch (Opciones.Instance.modo)
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 case Opciones.modoDeUso.Corregir:
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\" }."; 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) private string CrearMensajeDeUsuario(string texto)
{ {
if (Opciones.Instance.modo == Opciones.modoDeUso.Corregir) switch (Opciones.Instance.modo)
return "Please rewrite and improve the following text to make it clearer and more concise the words inside brackets are technical words: \"" + texto + "\""; {
else case Opciones.modoDeUso.Corregir:
return texto; 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."; TextoCorregido = "Error en la respuesta.";
// Elimina comillas al principio y al final si existen // Elimina comillas al principio y al final si existen
TextoCorregido = TextoCorregido.Trim('\"'); TextoCorregido = md.RemoveTechnicalTermMarkers(TextoCorregido).Trim('\"');
Log.Log("Texto corregido: " + TextoCorregido); Log.Log("Texto corregido: " + TextoCorregido);
} }