time.yaml 4.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114
  1. # -*- coding: utf-8 -*-
  2. # 规则文件:时间格式正则
  3. # 源:assembly/time_attrs.py 第 55-56 行 my_time_format_pattern + time_sub_pattern
  4. # common/attr_utils.py 第 98-101 行 extract_serviceTime() 内 pattern1-4
  5. # 迁移日期:2026-08-17 Phase 7 §7.6 高优先级
  6. version: 1
  7. category: TIME
  8. description: |
  9. 时间文本提取与格式化的核心正则。
  10. - time_format: 主时间格式(年-月-日 + 可选时分秒),含命名组 year/month/day
  11. - time_sub: 时间文本中需清除的括号字符
  12. - service_date: 完整日期(年月日)提取,用于 extract_serviceTime()
  13. - service_duration: 时长表达式(数字+单位),用于服务期推断
  14. - service_ym: 年月格式(无日),用于 extract_serviceTime() fallback
  15. - service_duration_rev: 倒序时长(单位在前数字在后),用于 extract_serviceTime() fallback
  16. patterns:
  17. - id: time_format
  18. description: |
  19. 主时间格式正则。支持:
  20. - 年份 20xx / xx / 二〇xx 中文
  21. - 月日阿拉伯数字或中文
  22. - 可选时分秒后缀
  23. pattern: '((?:(?P<year>20\d{2}|\d{2}|二[零〇0][零〇一二三四五六七八九0]{2})\s*[-/年.]\s*)?(?P<month>\d{1,2}|[一二三四五六七八九十]{1,3})\s*[-/月.]\s*(?P<day>\d{1,2}|[一二三四五六七八九十]{1,3}))(?:.?(?:[0-1][0-9]|2[0-4]|[0-9]):[0-5][0-9](?::[0-5][0-9])?)?'
  24. method: search
  25. named_groups:
  26. - year
  27. - month
  28. - day
  29. golden_examples:
  30. - input: "2024年08月15日"
  31. should_match: true
  32. - input: "2024-08-15 14:30"
  33. should_match: true
  34. - input: "08月15日"
  35. should_match: true
  36. - input: "二〇二四年八月十五日"
  37. should_match: true
  38. - input: "24.8.15"
  39. should_match: true
  40. - input: "无日期文本"
  41. should_match: false
  42. - id: time_sub
  43. description: 时间文本中需清除的括号字符(中英文方括号、圆括号、花括号)
  44. pattern: '[\[\]【】()(){}{}]+'
  45. method: search
  46. golden_examples:
  47. - input: "【2024年】"
  48. should_match: true
  49. - input: "(08月15日)"
  50. should_match: true
  51. - input: "2024年08月15日"
  52. should_match: false
  53. - id: service_date
  54. description: 完整日期格式(年-月-日),用于 extract_serviceTime() pattern1
  55. pattern: '\d{4}[年\-./]\d{1,2}[月\-./]\d{1,2}日?'
  56. method: search
  57. golden_examples:
  58. - input: "2024年08月15日"
  59. should_match: true
  60. - input: "2024-08-15"
  61. should_match: true
  62. - input: "2024.8.15"
  63. should_match: true
  64. - input: "2024年8月"
  65. should_match: false
  66. - id: service_duration
  67. description: |
  68. 时长表达式(数字在前 + 单位)。单位包括:
  69. 日/天/周年/整年/学年/年/月/周/日历天/工作天 等。
  70. pattern: '\d+(?:\.\d+)?[((]?个?[^\d]?[^\d]?(?:日|天|周年|整年|学?年|月|周|日历[天日]|工作[天日])'
  71. method: search
  72. golden_examples:
  73. - input: "30天"
  74. should_match: true
  75. - input: "6个月"
  76. should_match: true
  77. - input: "1.5年"
  78. should_match: true
  79. - input: "12个工作日"
  80. should_match: true
  81. - input: "无时长信息"
  82. should_match: false
  83. - id: service_ym
  84. description: 年月格式(无日),用于 extract_serviceTime() pattern3 fallback
  85. pattern: '\d{4}[年\-./]\d{1,2}月?'
  86. method: search
  87. golden_examples:
  88. - input: "2024年8月"
  89. should_match: true
  90. - input: "2024-08"
  91. should_match: true
  92. - input: "2024年08月15日"
  93. should_match: true
  94. - input: "无日期"
  95. should_match: false
  96. - id: service_duration_rev
  97. description: 倒序时长(单位在前 + 数字),用于 extract_serviceTime() pattern4 fallback
  98. pattern: '(?:日|天|周年|年|月|周|日历[天日]|工作[天日]|星期)[^\d]{1,3}\d+(?:\.\d+)?'
  99. method: search
  100. golden_examples:
  101. - input: "星期约3"
  102. should_match: true
  103. - input: "天计30"
  104. should_match: true
  105. - input: "月约6个"
  106. should_match: true
  107. - input: "30天"
  108. should_match: false