init.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582
  1. package main
  2. import (
  3. "log"
  4. "math"
  5. mu "mfw/util"
  6. "qfw/util"
  7. "reflect"
  8. "regexp"
  9. "sort"
  10. "strings"
  11. "sync"
  12. "go.mongodb.org/mongo-driver/bson/primitive"
  13. )
  14. var (
  15. Sysconfig map[string]interface{} //读取配置文件
  16. MongoTool, MgoBidding, MgoSpider *MongodbSim //mongodb连接
  17. ExtractColl, ProjectColl, BackupColl, SiteColl string //抽取表、项目表、项目快照表、站点表
  18. ExtractColl1 string
  19. Thread int //配置项线程数
  20. BlackList []interface{}
  21. BlaskListMap map[string]bool
  22. )
  23. var (
  24. //判断是日期
  25. _datereg = regexp.MustCompile("20[0-2][0-9][年-][0-9]{1,2}[月-][0-9]{1,2}[日-]([0-9]{1,2}时[0-9]{0,2})?")
  26. _numreg1 = regexp.MustCompile("^[0-9-]{1,8}$")
  27. _zimureg1 = regexp.MustCompile("^[a-zA-Z-]{1,7}$")
  28. _nzreg = regexp.MustCompile("^[0-9a-zA-Z-]+$")
  29. _hanreg = regexp.MustCompile(`^[\p{Han}::【】\\[\\]()()--、]+$`)
  30. replaceStr = regexp.MustCompile("(工程|采购|项目|[?!、【】()—()--]|栏标价|中标候选人|招标代理)")
  31. //判断带有分包、等特定词的
  32. pStr = regexp.MustCompile("(勘察|监理|施工|设计|验收|标段|分包|子包|[0-9A-Z]包|[一二三四五六七八九十0-9]批)")
  33. //判断包含数值
  34. nreg1 = regexp.MustCompile("[0-9]{2,}")
  35. //判断包含字母
  36. zreg1 = regexp.MustCompile("[a-zA-Z]{1,}")
  37. //判断包含汉字
  38. hreg1 = regexp.MustCompile(`[\p{Han}]+`)
  39. //判断项目编号是在10以内的纯数字结构
  40. numCheckPc = regexp.MustCompile("^[0-9-]{1,10}$")
  41. //仅初始化使用
  42. compareNoPass = map[string]bool{}
  43. compareAB = map[string]bool{}
  44. compareAB2D = map[string]bool{}
  45. compareABD = map[string]bool{}
  46. compareAB2CD = map[string]bool{}
  47. compareABCD = map[string]bool{}
  48. )
  49. func init() {
  50. util.ReadConfig(&Sysconfig)
  51. MongoTool = &MongodbSim{
  52. MongodbAddr: Sysconfig["mongodbServers"].(string),
  53. Size: util.IntAll(Sysconfig["mongodbPoolSize"]),
  54. DbName: Sysconfig["mongodbName"].(string),
  55. }
  56. MongoTool.InitPool()
  57. bidding, _ := Sysconfig["bidding"].(map[string]interface{})
  58. MgoBidding = &MongodbSim{
  59. MongodbAddr: bidding["addr"].(string),
  60. Size: util.IntAll(bidding["dbsize"]),
  61. DbName: bidding["dbname"].(string),
  62. //UserName: bidding["uname"].(string),
  63. //Password: bidding["upwd"].(string),
  64. }
  65. MgoBidding.InitPool()
  66. spider, _ := Sysconfig["spider"].(map[string]interface{})
  67. MgoSpider = &MongodbSim{
  68. MongodbAddr: spider["addr"].(string),
  69. Size: util.IntAll(spider["dbsize"]),
  70. DbName: spider["dbname"].(string),
  71. }
  72. MgoSpider.InitPool()
  73. ExtractColl = Sysconfig["extractColl"].(string)
  74. ExtractColl1 = Sysconfig["extractColl1"].(string)
  75. ProjectColl = Sysconfig["projectColl"].(string)
  76. BackupColl = Sysconfig["projectColl"].(string) + "_back"
  77. SiteColl = Sysconfig["siteColl"].(string)
  78. Thread = util.IntAll(Sysconfig["thread"])
  79. //NextNode = Sysconfig["nextNode"].([]interface{})
  80. udpport, _ := Sysconfig["udpport"].(string)
  81. udpclient = mu.UdpClient{Local: udpport, BufSize: 1024}
  82. udpclient.Listen(processUdpMsg)
  83. log.Println("Udp服务监听", udpport)
  84. BlackList = Sysconfig["rp_blacklist"].([]interface{})
  85. BlaskListMap = make(map[string]bool)
  86. for _, v := range BlackList {
  87. BlaskListMap[util.ObjToString(v)] = true
  88. }
  89. initWinnerRegexp()
  90. initBuyerRegexp()
  91. initAgencyRegexp()
  92. //加载项目数据
  93. //---不能通过
  94. vm := []string{"C", "D"}
  95. for i := 0; i < 2; i++ {
  96. for j := 0; j < 2; j++ {
  97. for k := 0; k < 2; k++ {
  98. key := vm[i] + vm[j] + vm[k]
  99. compareNoPass[key] = true
  100. //fmt.Println(key)
  101. }
  102. }
  103. }
  104. //fmt.Println("-------------------")
  105. //三个元素一致 [AB][AB][AB],分值最高
  106. vm = []string{"A", "B"}
  107. for i := 0; i < 2; i++ {
  108. for j := 0; j < 2; j++ {
  109. for k := 0; k < 2; k++ {
  110. key := vm[i] + vm[j] + vm[k]
  111. compareAB[key] = true
  112. //fmt.Println(key)
  113. }
  114. }
  115. }
  116. //fmt.Println("-------------------", len(compareAB))
  117. //---至少两个一致,其他可能不存在
  118. //[AB][AB][ABD]
  119. //[AB][ABD][AB]
  120. vm = []string{"A", "B"}
  121. vm2 := []string{"A", "B", "D"}
  122. for i := 0; i < 2; i++ {
  123. for j := 0; j < 2; j++ {
  124. for k := 0; k < 3; k++ {
  125. key := vm[i] + vm[j] + vm2[k]
  126. if !compareAB[key] {
  127. compareAB2D[key] = true
  128. //fmt.Println(key)
  129. }
  130. }
  131. }
  132. }
  133. for i := 0; i < 2; i++ {
  134. for j := 0; j < 3; j++ {
  135. for k := 0; k < 2; k++ {
  136. key := vm[i] + vm2[j] + vm[k]
  137. if !compareAB[key] {
  138. compareAB2D[key] = true
  139. //fmt.Println(key)
  140. }
  141. }
  142. }
  143. }
  144. //fmt.Println("-------------------", len(compareAB2D))
  145. //---至少一个一致,其他可能不存在
  146. //[ABD][ABD][ABD] //已经删除DDD
  147. vm = []string{"A", "B", "D"}
  148. for i := 0; i < 3; i++ {
  149. for j := 0; j < 3; j++ {
  150. for k := 0; k < 3; k++ {
  151. key := vm[i] + vm[j] + vm[k]
  152. if !compareAB[key] && !compareAB2D[key] && !compareNoPass[key] {
  153. compareABD[key] = true
  154. //fmt.Println(key)
  155. }
  156. }
  157. }
  158. }
  159. //fmt.Println("-------------------", len(compareABD))
  160. //[AB][ABCD][AB]
  161. //[AB][AB][ABCD]
  162. vm = []string{"A", "B"}
  163. vm2 = []string{"A", "B", "C", "D"}
  164. for i := 0; i < 2; i++ {
  165. for j := 0; j < 4; j++ {
  166. for k := 0; k < 2; k++ {
  167. key := vm[i] + vm2[j] + vm[k]
  168. if !compareAB[key] && !compareAB2D[key] && !compareNoPass[key] && !compareABD[key] {
  169. compareAB2CD[key] = true
  170. //fmt.Println(key)
  171. }
  172. }
  173. }
  174. }
  175. for i := 0; i < 2; i++ {
  176. for j := 0; j < 2; j++ {
  177. for k := 0; k < 4; k++ {
  178. key := vm[i] + vm[j] + vm2[k]
  179. if !compareAB[key] && !compareAB2D[key] && !compareNoPass[key] && !compareABD[key] {
  180. compareAB2CD[key] = true
  181. //fmt.Println(key)
  182. }
  183. }
  184. }
  185. }
  186. //fmt.Println("-------------------", len(compareAB2CD))
  187. //[ABECD][ABECD][ABECD] //已经删除[CD][CD][CD] //这个要重点讨论
  188. vm = []string{"A", "B", "C", "D"}
  189. for i := 0; i < 4; i++ {
  190. for j := 0; j < 4; j++ {
  191. for k := 0; k < 4; k++ {
  192. key := vm[i] + vm[j] + vm[k]
  193. if !compareAB[key] && !compareAB2D[key] && !compareABD[key] && !compareNoPass[key] && !compareAB2CD[key] {
  194. compareABCD[key] = true
  195. //fmt.Println(key)
  196. }
  197. }
  198. }
  199. }
  200. }
  201. func CheckHanAndNum(str string) (b bool) {
  202. return nreg1.MatchString(str) && hreg1.MatchString(str)
  203. }
  204. func CheckZimuAndNum(str string) (b bool) {
  205. return zreg1.MatchString(str) && nreg1.MatchString(str)
  206. }
  207. type KeyMap struct {
  208. Lock sync.Mutex
  209. Map map[string]*Key
  210. }
  211. type ID struct {
  212. Id string
  213. Lock sync.Mutex
  214. P *ProjectInfo
  215. }
  216. type Key struct {
  217. Arr []string
  218. Lock sync.Mutex
  219. }
  220. type IdAndLock struct {
  221. Id string
  222. Lock sync.Mutex
  223. }
  224. func NewKeyMap() *KeyMap {
  225. return &KeyMap{
  226. Map: map[string]*Key{},
  227. Lock: sync.Mutex{},
  228. }
  229. }
  230. //招标信息实体类
  231. type Info struct {
  232. Id string `json:"_id"`
  233. Href string `json:"href"` //源地址
  234. Publishtime int64 `json:"publishtime"`
  235. Comeintime int64 `json:"comeintime"`
  236. Title string `json:"title"`
  237. TopType string `json:"toptype"`
  238. SubType string `json:"subtype"`
  239. ProjectName string `json:"projectname"`
  240. ProjectCode string `json:"projectcode"`
  241. ProjectScope string `json:"projectscope"`
  242. ContractCode string `json:"contractcode"`
  243. Buyer string `json:"buyer"`
  244. Buyerperson string `json:"buyerperson"`
  245. Buyertel string `json:"buyertel"`
  246. Agency string `json:"agency"`
  247. Area string `json:"area"`
  248. City string `json:"city"`
  249. District string `json:"district"`
  250. Infoformat int `json:"infoformat"`
  251. ReviewExperts []string `json:"review_experts"`
  252. Purchasing string `json:"purchasing"`
  253. WinnerOrder []map[string]interface{} `json:"winnerorder"`
  254. ProjectScale string `json:"project_scale"`
  255. ProjectDuration int `json:"project_duration"`
  256. ProjectTimeUnit string `json:"project_timeunit"`
  257. ProjectStartDate int64 `json:"project_startdate"`
  258. ProjectCompleteDate int64 `json:"project_completedate"`
  259. Payway string `json:"payway"`
  260. ContractGuarantee bool `json:"contract_guarantee"`
  261. BidGuarantee bool `json:"bid_guarantee"`
  262. Qualifies []map[string]interface{} `json:"qualifies"`
  263. EntIdList []string `json:"entidlist"`
  264. HasPackage bool // `json:"haspackage"`
  265. Package map[string]interface{} `json:"package"`
  266. Topscopeclass []string `json:"topscopeclass"`
  267. Subscopeclass []string `json:"subscopeclass"`
  268. Buyerclass string `json:"buyerclass"`
  269. Bidopentime int64 `json:"bidopentime"`
  270. Budget float64 `json:"budget"`
  271. Bidamount float64 `json:"bidamount"`
  272. Winners []string
  273. dealtype int
  274. PTC string //从标题中抽的项目编号
  275. pnbval int //项目名称、编号、采购单位存在的个数
  276. LenPC int //项目编号长度
  277. LenPN int //项目名称长度
  278. LenPTC int //标题抽的项目编号长度
  279. //以下三个元素做对比,计算包含时候使用
  280. PNBH int //0初始,+包含,-被包含
  281. PCBH int
  282. PTCBH int
  283. }
  284. //项目实体类
  285. type ProjectInfo struct {
  286. Id primitive.ObjectID `json:"_id"`
  287. FirstTime int64 `json:"firsttime,omitempty"` //项目的最早时间
  288. LastTime int64 `json:"lasttime,omitempty"` //项目的最后时间
  289. Ids []string `json:"ids,omitempty"`
  290. Topscopeclass []string `json:"topscopeclass,omitempty"`
  291. Subscopeclass []string `json:"subscopeclass,omitempty"` //子行业分类
  292. Winners []string `json:"s_winner,omitempty"` //中标人
  293. ProjectName string `json:"projectname,omitempty"` //项目名称
  294. ProjectCode string `json:"projectcode,omitempty"` //项目代码唯一(纯数字的权重低)
  295. ContractCode string `json:"contractcode,omitempty"` //项目编号
  296. Buyer string `json:"buyer,omitempty"` //采购单位唯一
  297. MPN []string `json:"mpn,omitempty"` //合并后多余的项目名称
  298. MPC []string `json:"mpc,omitempty"` //合并后多余的项目编号
  299. Buyerperson string `json:"buyerperson"` //采购联系人
  300. Buyertel string `json:"buyertel"` //采购联系人电话
  301. Agency string `json:"agency"` //代理机构
  302. Area string `json:"area"` //地区
  303. City string `json:"city"` //地市
  304. District string `json:"district"` //区县
  305. Bidstatus string `json:"bidstatus"` //
  306. Bidtype string `json:"bidtype"` //
  307. ReviewExperts []string `json:"review_experts"` // 项目评审专家
  308. Purchasing string `json:"purchasing"` // 标的物
  309. Package map[string]interface{} `json:"package,omitempty"` //分包的对比对象
  310. Buyerclass string `json:"buyerclass"` //采购单位分类
  311. Bidopentime int64 `json:"bidopentime,omitempty"` //开标时间
  312. Jgtime int64 `json:"jgtime"` //结果中标时间
  313. Zbtime int64 `json:"zbtime"` //招标时间
  314. Bidamount float64 `json:"bidamount,omitempty"` //中标金额
  315. Budget float64 `json:"budget,omitempty"` //预算
  316. Winnerorder []string `json:"winnerorder"` //中标候选人
  317. ProjectScale string `json:"project_scale"` //项目规模
  318. ProjectDuration int `json:"project_duration"` //工期时长
  319. ProjectTimeunit string `json:"project_timeunit"` //工期时长单位
  320. ProjectStartDate int64 `json:"project_startdate"` //开工日期
  321. ProjctCompleteDate int64 `json:"projct_completedate"` //竣工日期
  322. Payway string `json:"payway"` //付款方式
  323. ContractGuarantee bool `json:"contract_guarantee"` //履约保证金 是否支持包含
  324. BidGuarantee bool `json:"bid_guarantee"` //投标保证金 是否支持包含
  325. Qualifies string `json:"qualifies"` //资质条件
  326. EntIdList []string `json:"entidlist"` //企业id
  327. score int
  328. comStr string
  329. resVal, pjVal int
  330. InfoFiled map[string]InfoField `json:"infofield"` //逻辑处理需要的info字段
  331. Budgettag int `json:"budgettag"` //预算是否有效标记
  332. Bidamounttag int `json:"bidamounttag"` //中标金额是否有效标记
  333. }
  334. //存储部分招标信息字段,业务逻辑处理需要
  335. type InfoField struct {
  336. Budget float64 `json:"budget"`
  337. Bidamount float64 `json:"bidamount"`
  338. ContractCode string `json:"contractcode"`
  339. ProjectName string `json:"projectname"`
  340. ProjectCode string `json:"projectcode"`
  341. Bidstatus string `json:"bidstatus"`
  342. }
  343. //站点信息
  344. type Site struct {
  345. Id string `json:"_id"`
  346. Site string `json:"site"` //站点名字
  347. Area string `json:"area"` //省
  348. City string `json:"city"` //市
  349. District string `json:"district"` //区、县
  350. Domain string `json:"domain"` //地址
  351. Status int `json:"status"` //
  352. }
  353. //二分字符串查找
  354. func BinarySearch(s []string, k string) int {
  355. sort.Strings(s)
  356. lo, hi := 0, len(s)-1
  357. for lo <= hi {
  358. m := (lo + hi) >> 1
  359. if s[m] < k {
  360. lo = m + 1
  361. } else if s[m] > k {
  362. hi = m - 1
  363. } else {
  364. return m
  365. }
  366. }
  367. return -1
  368. }
  369. func Duplicate(a interface{}) (ret []interface{}) {
  370. va := reflect.ValueOf(a)
  371. for i := 0; i < va.Len(); i++ {
  372. if i > 0 && reflect.DeepEqual(va.Index(i-1).Interface(), va.Index(i).Interface()) {
  373. continue
  374. }
  375. ret = append(ret, va.Index(i).Interface())
  376. }
  377. return ret
  378. }
  379. //计算文本相似度
  380. func CosineSimilar(srcWords1, dstWords1 string) float64 {
  381. srcWords, dstWords := strings.Split(srcWords1, ""), strings.Split(dstWords1, "")
  382. // get all words
  383. allWordsMap := make(map[string]int, 0)
  384. for _, word := range srcWords {
  385. if _, found := allWordsMap[word]; !found {
  386. allWordsMap[word] = 1
  387. } else {
  388. allWordsMap[word] += 1
  389. }
  390. }
  391. for _, word := range dstWords {
  392. if _, found := allWordsMap[word]; !found {
  393. allWordsMap[word] = 1
  394. } else {
  395. allWordsMap[word] += 1
  396. }
  397. }
  398. // stable the sort
  399. allWordsSlice := make([]string, 0)
  400. for word, _ := range allWordsMap {
  401. allWordsSlice = append(allWordsSlice, word)
  402. }
  403. // assemble vector
  404. srcVector := make([]int, len(allWordsSlice))
  405. dstVector := make([]int, len(allWordsSlice))
  406. for _, word := range srcWords {
  407. if index := BinarySearch(allWordsSlice, word); index != -1 {
  408. srcVector[index] += 1
  409. }
  410. }
  411. for _, word := range dstWords {
  412. if index := BinarySearch(allWordsSlice, word); index != -1 {
  413. dstVector[index] += 1
  414. }
  415. }
  416. // calc cos
  417. numerator := float64(0)
  418. srcSq := 0
  419. dstSq := 0
  420. for i, srcCount := range srcVector {
  421. dstCount := dstVector[i]
  422. numerator += float64(srcCount * dstCount)
  423. srcSq += srcCount * srcCount
  424. dstSq += dstCount * dstCount
  425. }
  426. denominator := math.Sqrt(float64(srcSq * dstSq))
  427. v1 := numerator / denominator
  428. // if v1 > 0.6 {
  429. // log.Println(v1, srcWords1, dstWords1)
  430. // }
  431. return v1
  432. }
  433. func initWinnerRegexp() {
  434. winRegMap := Sysconfig["winner"].(map[string]interface{})
  435. preRegexps := winRegMap["pre_regexp"].([]interface{})
  436. backRegexps := winRegMap["back_regexp"].([]interface{})
  437. backRepRegexps := winRegMap["back_rep_regexp"].([]interface{})
  438. backBlack := winRegMap["blacklist"].([]interface{})
  439. var winPreRegexps []*regexp.Regexp
  440. for _, v := range preRegexps {
  441. reg := regexp.MustCompile("^" + v.(string))
  442. winPreRegexps = append(winPreRegexps, reg)
  443. }
  444. PreRegexp["winner"] = winPreRegexps
  445. var winBackRegexps []*regexp.Regexp
  446. for _, v := range backRegexps {
  447. reg := regexp.MustCompile(v.(string))
  448. winBackRegexps = append(winBackRegexps, reg)
  449. }
  450. BackRegexp["winner"] = winBackRegexps
  451. var winBackRepRegexps []RegexpInfo
  452. for _, v := range backRepRegexps {
  453. reps := strings.Split(v.(string), "#")
  454. if len(reps) > 1 {
  455. reg := RegexpInfo{
  456. regs: regexp.MustCompile(reps[0]),
  457. repstr: reps[1],
  458. }
  459. winBackRepRegexps = append(winBackRepRegexps, reg)
  460. }
  461. }
  462. BackRepRegexp["winner"] = winBackRepRegexps
  463. var winBlackRegexps []*regexp.Regexp
  464. for _, v := range backBlack {
  465. reg := regexp.MustCompile(v.(string))
  466. winBlackRegexps = append(winBlackRegexps, reg)
  467. }
  468. BlackRegexp["winner"] = winBlackRegexps
  469. }
  470. func initBuyerRegexp() {
  471. buyRegMap := Sysconfig["buyer"].(map[string]interface{})
  472. preRegexps := buyRegMap["pre_regexp"].([]interface{})
  473. backRegexps := buyRegMap["back_regexp"].([]interface{})
  474. backRepRegexps := buyRegMap["back_rep_regexp"].([]interface{})
  475. backBlack := buyRegMap["blacklist"].([]interface{})
  476. var winPreRegexps []*regexp.Regexp
  477. for _, v := range preRegexps {
  478. reg := regexp.MustCompile("^" + v.(string))
  479. winPreRegexps = append(winPreRegexps, reg)
  480. }
  481. PreRegexp["buyer"] = winPreRegexps
  482. var winBackRegexps []*regexp.Regexp
  483. for _, v := range backRegexps {
  484. reg := regexp.MustCompile(v.(string))
  485. winBackRegexps = append(winBackRegexps, reg)
  486. }
  487. BackRegexp["buyer"] = winBackRegexps
  488. var winBackRepRegexps []RegexpInfo
  489. for _, v := range backRepRegexps {
  490. reps := strings.Split(v.(string), "#")
  491. if len(reps) > 1 {
  492. reg := RegexpInfo{
  493. regs: regexp.MustCompile(reps[0]),
  494. repstr: reps[1],
  495. }
  496. winBackRepRegexps = append(winBackRepRegexps, reg)
  497. }
  498. }
  499. BackRepRegexp["buyer"] = winBackRepRegexps
  500. var winBlackRegexps []*regexp.Regexp
  501. for _, v := range backBlack {
  502. reg := regexp.MustCompile(v.(string))
  503. winBlackRegexps = append(winBlackRegexps, reg)
  504. }
  505. BlackRegexp["buyer"] = winBlackRegexps
  506. }
  507. func initAgencyRegexp() {
  508. buyRegMap := Sysconfig["agency"].(map[string]interface{})
  509. preRegexps := buyRegMap["pre_regexp"].([]interface{})
  510. backRegexps := buyRegMap["back_regexp"].([]interface{})
  511. backRepRegexps := buyRegMap["back_rep_regexp"].([]interface{})
  512. backBlack := buyRegMap["blacklist"].([]interface{})
  513. var winPreRegexps []*regexp.Regexp
  514. for _, v := range preRegexps {
  515. reg := regexp.MustCompile("^" + v.(string))
  516. winPreRegexps = append(winPreRegexps, reg)
  517. }
  518. PreRegexp["agency"] = winPreRegexps
  519. var winBackRegexps []*regexp.Regexp
  520. for _, v := range backRegexps {
  521. reg := regexp.MustCompile(v.(string))
  522. winBackRegexps = append(winBackRegexps, reg)
  523. }
  524. BackRegexp["agency"] = winBackRegexps
  525. var winBackRepRegexps []RegexpInfo
  526. for _, v := range backRepRegexps {
  527. reps := strings.Split(v.(string), "#")
  528. if len(reps) > 1 {
  529. reg := RegexpInfo{
  530. regs: regexp.MustCompile(reps[0]),
  531. repstr: reps[1],
  532. }
  533. winBackRepRegexps = append(winBackRepRegexps, reg)
  534. }
  535. }
  536. BackRepRegexp["agency"] = winBackRepRegexps
  537. var winBlackRegexps []*regexp.Regexp
  538. for _, v := range backBlack {
  539. reg := regexp.MustCompile(v.(string))
  540. winBlackRegexps = append(winBlackRegexps, reg)
  541. }
  542. BlackRegexp["agency"] = winBlackRegexps
  543. }