|
|
@@ -32,6 +32,7 @@ namespace CallCenter.WebChatServer
|
|
32
|
32
|
public static string DoGetKeyword(string keyText)
|
|
33
|
33
|
{
|
|
34
|
34
|
if (String.IsNullOrEmpty(keyText)) return "";
|
|
|
35
|
+ if (JudgementStr(keyText)) return "";
|
|
35
|
36
|
|
|
36
|
37
|
LoadDict();
|
|
37
|
38
|
LoadDictBaidu();
|
|
|
@@ -390,5 +391,52 @@ namespace CallCenter.WebChatServer
|
|
390
|
391
|
{
|
|
391
|
392
|
return _StopWordsList.Contains(str);
|
|
392
|
393
|
}
|
|
|
394
|
+
|
|
|
395
|
+ /// <summary>
|
|
|
396
|
+ /// 用正则表达式来验证字符串是否为数字字符串
|
|
|
397
|
+ /// </summary>
|
|
|
398
|
+ /// <param name="message"></param>
|
|
|
399
|
+ /// <param name="result"></param>
|
|
|
400
|
+ /// <returns></returns>
|
|
|
401
|
+ private static bool isNumberic(string message, out int result)
|
|
|
402
|
+ {
|
|
|
403
|
+ System.Text.RegularExpressions.Regex rex = new System.Text.RegularExpressions.Regex(@"^\d+$");
|
|
|
404
|
+ result = -1;
|
|
|
405
|
+ if (rex.IsMatch(message))
|
|
|
406
|
+ {
|
|
|
407
|
+ result = int.Parse(message);
|
|
|
408
|
+ return true;
|
|
|
409
|
+ }
|
|
|
410
|
+ else
|
|
|
411
|
+ return false;
|
|
|
412
|
+ }
|
|
|
413
|
+
|
|
|
414
|
+ /// <summary>
|
|
|
415
|
+ /// 字符串过滤
|
|
|
416
|
+ /// 1、纯数字大于4个数字
|
|
|
417
|
+ /// 2、不是纯数字大于2个字
|
|
|
418
|
+ /// </summary>
|
|
|
419
|
+ /// <param name="key"></param>
|
|
|
420
|
+ /// <returns></returns>
|
|
|
421
|
+ private static bool JudgementStr(string key)
|
|
|
422
|
+ {
|
|
|
423
|
+ bool b = false;
|
|
|
424
|
+ byte[] keyText2 = Encoding.Default.GetBytes(key);
|
|
|
425
|
+ int key_l = keyText2.Length;
|
|
|
426
|
+ int result = 0;
|
|
|
427
|
+ if (isNumberic(key, out result))
|
|
|
428
|
+ {
|
|
|
429
|
+ // 4个数字
|
|
|
430
|
+ if (key_l < 5)
|
|
|
431
|
+ b = true;
|
|
|
432
|
+ }
|
|
|
433
|
+ else
|
|
|
434
|
+ {
|
|
|
435
|
+ // 2个字
|
|
|
436
|
+ if (key_l < 4)
|
|
|
437
|
+ b = true;
|
|
|
438
|
+ }
|
|
|
439
|
+ return b;
|
|
|
440
|
+ }
|
|
393
|
441
|
}
|
|
394
|
442
|
}
|