From 2735a6f6b5713a7979380ca12cc647bdd8e83647 Mon Sep 17 00:00:00 2001 From: "DESKTOP-3BO4HSG\\ksat" Date: Wed, 28 Dec 2022 17:47:37 +0800 Subject: [PATCH] perf: update optimized identification --- STranslate/Style/Dark/DictionaryCommonDark.xaml | 2 ++ STranslate/ViewModel/MainVM.cs | 5 +++++ 2 files changed, 7 insertions(+) diff --git a/STranslate/Style/Dark/DictionaryCommonDark.xaml b/STranslate/Style/Dark/DictionaryCommonDark.xaml index db95788..d6e053a 100644 --- a/STranslate/Style/Dark/DictionaryCommonDark.xaml +++ b/STranslate/Style/Dark/DictionaryCommonDark.xaml @@ -55,6 +55,8 @@ + + diff --git a/STranslate/ViewModel/MainVM.cs b/STranslate/ViewModel/MainVM.cs index 44f0da2..c4d9689 100644 --- a/STranslate/ViewModel/MainVM.cs +++ b/STranslate/ViewModel/MainVM.cs @@ -79,6 +79,11 @@ namespace STranslate.ViewModel /// private Tuple AutomaticLanguageRecognition(string text) { + //https://www.techiedelight.com/zh/strip-punctuations-from-a-string-in-csharp/ + //预处理 + text = System.Text.RegularExpressions.Regex.Replace(text, + "[1234567890!\"#$%&'()*+,-./:;<=>?@\\[\\]^_`{|}~,。、《》?;‘’:“”【】、{}|·!@#¥%……&*()——+~\\\\]", + string.Empty); //如果输入是中文 if (System.Text.RegularExpressions.Regex.IsMatch(text, @"^[\u4e00-\u9fa5]+$")) {