39 lines
1.2 KiB
C#
39 lines
1.2 KiB
C#
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<string, int> serverpartRules = new Dictionary<string, int>
|
|
{
|
|
{ "新桥服务区", 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 : "未找到服务区";
|
|
}
|
|
}
|
|
}
|