using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.Text.RegularExpressions; using System.Threading.Tasks; namespace DataBaseProcessing { public class ServerpartRecognizer { // 定义时间解析规则表 public static Dictionary serverpartRules = new Dictionary { { "新桥服务区", 416 }, { "新桥", 416 }, }; // 构建正则表达式来匹配服务区 private static string serverpartPattern = string.Join("|", serverpartRules.Keys); // 判断输入的句子中是否包含服务区 public static bool ContainsServerpart(string input) { // 使用正则表达式来匹配服务区 Regex regex = new Regex(serverpartPattern); return regex.IsMatch(input); } // 如果包含服务区,返回匹配的服务区名称 public static string GetServerpartName(string input) { Regex regex = new Regex(serverpartPattern); Match match = regex.Match(input); return match.Success ? match.Value : "未找到服务区"; } } }