init.go 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584
  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. //FirstCooperation []string `json:"first_cooperation"` //first_cooperation
  328. score int
  329. comStr string
  330. resVal, pjVal int
  331. InfoFiled map[string]InfoField `json:"infofield"` //逻辑处理需要的info字段
  332. Budgettag int `json:"budgettag"` //预算是否有效标记
  333. Bidamounttag int `json:"bidamounttag"` //中标金额是否有效标记
  334. }
  335. //存储部分招标信息字段,业务逻辑处理需要
  336. type InfoField struct {
  337. Budget float64 `json:"budget"`
  338. Bidamount float64 `json:"bidamount"`
  339. ContractCode string `json:"contractcode"`
  340. ProjectName string `json:"projectname"`
  341. ProjectCode string `json:"projectcode"`
  342. Bidstatus string `json:"bidstatus"`
  343. }
  344. //站点信息
  345. type Site struct {
  346. Id string `json:"_id"`
  347. Site string `json:"site"` //站点名字
  348. Area string `json:"area"` //省
  349. City string `json:"city"` //市
  350. District string `json:"district"` //区、县
  351. Domain string `json:"domain"` //地址
  352. Status int `json:"status"` //
  353. }
  354. //二分字符串查找
  355. func BinarySearch(s []string, k string) int {
  356. sort.Strings(s)
  357. lo, hi := 0, len(s)-1
  358. for lo <= hi {
  359. m := (lo + hi) >> 1
  360. if s[m] < k {
  361. lo = m + 1
  362. } else if s[m] > k {
  363. hi = m - 1
  364. } else {
  365. return m
  366. }
  367. }
  368. return -1
  369. }
  370. func Duplicate(a interface{}) (ret []interface{}) {
  371. va := reflect.ValueOf(a)
  372. for i := 0; i < va.Len(); i++ {
  373. if i > 0 && reflect.DeepEqual(va.Index(i-1).Interface(), va.Index(i).Interface()) {
  374. continue
  375. }
  376. ret = append(ret, va.Index(i).Interface())
  377. }
  378. return ret
  379. }
  380. //计算文本相似度
  381. func CosineSimilar(srcWords1, dstWords1 string) float64 {
  382. srcWords, dstWords := strings.Split(srcWords1, ""), strings.Split(dstWords1, "")
  383. // get all words
  384. allWordsMap := make(map[string]int, 0)
  385. for _, word := range srcWords {
  386. if _, found := allWordsMap[word]; !found {
  387. allWordsMap[word] = 1
  388. } else {
  389. allWordsMap[word] += 1
  390. }
  391. }
  392. for _, word := range dstWords {
  393. if _, found := allWordsMap[word]; !found {
  394. allWordsMap[word] = 1
  395. } else {
  396. allWordsMap[word] += 1
  397. }
  398. }
  399. // stable the sort
  400. allWordsSlice := make([]string, 0)
  401. for word, _ := range allWordsMap {
  402. allWordsSlice = append(allWordsSlice, word)
  403. }
  404. // assemble vector
  405. srcVector := make([]int, len(allWordsSlice))
  406. dstVector := make([]int, len(allWordsSlice))
  407. for _, word := range srcWords {
  408. if index := BinarySearch(allWordsSlice, word); index != -1 {
  409. srcVector[index] += 1
  410. }
  411. }
  412. for _, word := range dstWords {
  413. if index := BinarySearch(allWordsSlice, word); index != -1 {
  414. dstVector[index] += 1
  415. }
  416. }
  417. // calc cos
  418. numerator := float64(0)
  419. srcSq := 0
  420. dstSq := 0
  421. for i, srcCount := range srcVector {
  422. dstCount := dstVector[i]
  423. numerator += float64(srcCount * dstCount)
  424. srcSq += srcCount * srcCount
  425. dstSq += dstCount * dstCount
  426. }
  427. denominator := math.Sqrt(float64(srcSq * dstSq))
  428. v1 := numerator / denominator
  429. // if v1 > 0.6 {
  430. // log.Println(v1, srcWords1, dstWords1)
  431. // }
  432. return v1
  433. }
  434. func initWinnerRegexp() {
  435. winRegMap := Sysconfig["winner"].(map[string]interface{})
  436. //preRegexps := winRegMap["pre_regexp"].([]interface{})
  437. //backRegexps := winRegMap["back_regexp"].([]interface{})
  438. //backRepRegexps := winRegMap["back_rep_regexp"].([]interface{})
  439. backBlack := winRegMap["blacklist"].([]interface{})
  440. //var winPreRegexps []*regexp.Regexp
  441. //for _, v := range preRegexps {
  442. // reg := regexp.MustCompile("^" + v.(string))
  443. // winPreRegexps = append(winPreRegexps, reg)
  444. //}
  445. //PreRegexp["winner"] = winPreRegexps
  446. //var winBackRegexps []*regexp.Regexp
  447. //for _, v := range backRegexps {
  448. // reg := regexp.MustCompile(v.(string))
  449. // winBackRegexps = append(winBackRegexps, reg)
  450. //}
  451. //BackRegexp["winner"] = winBackRegexps
  452. //var winBackRepRegexps []RegexpInfo
  453. //for _, v := range backRepRegexps {
  454. // reps := strings.Split(v.(string), "#")
  455. // if len(reps) > 1 {
  456. // reg := RegexpInfo{
  457. // regs: regexp.MustCompile(reps[0]),
  458. // repstr: reps[1],
  459. // }
  460. // winBackRepRegexps = append(winBackRepRegexps, reg)
  461. // }
  462. //}
  463. //BackRepRegexp["winner"] = winBackRepRegexps
  464. var winBlackRegexps []*regexp.Regexp
  465. for _, v := range backBlack {
  466. reg := regexp.MustCompile(v.(string))
  467. winBlackRegexps = append(winBlackRegexps, reg)
  468. }
  469. BlackRegexp["winner"] = winBlackRegexps
  470. }
  471. func initBuyerRegexp() {
  472. buyRegMap := Sysconfig["buyer"].(map[string]interface{})
  473. //preRegexps := buyRegMap["pre_regexp"].([]interface{})
  474. //backRegexps := buyRegMap["back_regexp"].([]interface{})
  475. //backRepRegexps := buyRegMap["back_rep_regexp"].([]interface{})
  476. backBlack := buyRegMap["blacklist"].([]interface{})
  477. //var winPreRegexps []*regexp.Regexp
  478. //for _, v := range preRegexps {
  479. // reg := regexp.MustCompile("^" + v.(string))
  480. // winPreRegexps = append(winPreRegexps, reg)
  481. //}
  482. //PreRegexp["buyer"] = winPreRegexps
  483. //var winBackRegexps []*regexp.Regexp
  484. //for _, v := range backRegexps {
  485. // reg := regexp.MustCompile(v.(string))
  486. // winBackRegexps = append(winBackRegexps, reg)
  487. //}
  488. //BackRegexp["buyer"] = winBackRegexps
  489. //var winBackRepRegexps []RegexpInfo
  490. //for _, v := range backRepRegexps {
  491. // reps := strings.Split(v.(string), "#")
  492. // if len(reps) > 1 {
  493. // reg := RegexpInfo{
  494. // regs: regexp.MustCompile(reps[0]),
  495. // repstr: reps[1],
  496. // }
  497. // winBackRepRegexps = append(winBackRepRegexps, reg)
  498. // }
  499. //}
  500. //BackRepRegexp["buyer"] = winBackRepRegexps
  501. var winBlackRegexps []*regexp.Regexp
  502. for _, v := range backBlack {
  503. reg := regexp.MustCompile(v.(string))
  504. winBlackRegexps = append(winBlackRegexps, reg)
  505. }
  506. BlackRegexp["buyer"] = winBlackRegexps
  507. }
  508. func initAgencyRegexp() {
  509. buyRegMap := Sysconfig["agency"].(map[string]interface{})
  510. //preRegexps := buyRegMap["pre_regexp"].([]interface{})
  511. //backRegexps := buyRegMap["back_regexp"].([]interface{})
  512. //backRepRegexps := buyRegMap["back_rep_regexp"].([]interface{})
  513. backBlack := buyRegMap["blacklist"].([]interface{})
  514. //var winPreRegexps []*regexp.Regexp
  515. //for _, v := range preRegexps {
  516. // reg := regexp.MustCompile("^" + v.(string))
  517. // winPreRegexps = append(winPreRegexps, reg)
  518. //}
  519. //PreRegexp["agency"] = winPreRegexps
  520. //var winBackRegexps []*regexp.Regexp
  521. //for _, v := range backRegexps {
  522. // reg := regexp.MustCompile(v.(string))
  523. // winBackRegexps = append(winBackRegexps, reg)
  524. //}
  525. //BackRegexp["agency"] = winBackRegexps
  526. //var winBackRepRegexps []RegexpInfo
  527. //for _, v := range backRepRegexps {
  528. // reps := strings.Split(v.(string), "#")
  529. // if len(reps) > 1 {
  530. // reg := RegexpInfo{
  531. // regs: regexp.MustCompile(reps[0]),
  532. // repstr: reps[1],
  533. // }
  534. // winBackRepRegexps = append(winBackRepRegexps, reg)
  535. // }
  536. //}
  537. //BackRepRegexp["agency"] = winBackRepRegexps
  538. var winBlackRegexps []*regexp.Regexp
  539. for _, v := range backBlack {
  540. reg := regexp.MustCompile(v.(string))
  541. winBlackRegexps = append(winBlackRegexps, reg)
  542. }
  543. BlackRegexp["agency"] = winBlackRegexps
  544. }