article.go 4.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111
  1. package util
  2. //
  3. type Job struct {
  4. SourceMid string //数据源的MongoId
  5. Category string //类别
  6. Content string //正文
  7. ContentFile string //附件文本堆一起(后期可以考虑,分开处理)
  8. Title string //标题
  9. SpiderCode string //爬虫代码
  10. Domain string //网站域名
  11. Href string //原文链接
  12. City string //城市
  13. Province string //省份
  14. Data *map[string]interface{} //数据库源数据
  15. Block []*Block //分块
  16. Result map[string][]*ExtField //结果
  17. BuyerAddr string //采购单位地址
  18. BlockPackage map[string]*BlockPackage //块中的分包
  19. Winnerorder []map[string]interface{} //中标候选人排序
  20. PackageInfo map[string]map[string]interface{} //分包信息
  21. BrandData [][]map[string]string //
  22. HasTable int //有table
  23. HasKey int //是否匹配到table中的标题
  24. HasBrand int //有品牌
  25. HasGoods int //有商品
  26. }
  27. type ExtField struct {
  28. Field string //属性
  29. Code string //匹配标签(字符串、正则)、正则或lua代码
  30. RuleText string //内容
  31. Type string //kv(细类:colon1,colon2,space,table)、正则(regexp)
  32. MatchType string //匹配类型:1:标签库类型(tag_string,tag_regexp),2:全文正则regcontent
  33. ExtFrom string //抽取来源(title,detail)
  34. Value interface{} //抽取结果
  35. Score int //得分
  36. }
  37. //块
  38. type Block struct {
  39. Tags []Tags //对块做的标签,可以作为数据抽取的依据
  40. Title string //块标题
  41. Index int //块索引
  42. Text string //块内容
  43. Start int //开始索引
  44. End int //结束索引
  45. ColonKV *JobKv //冒号kv (分出的对应的KV值)
  46. TableKV *JobKv //table kv (分出的对应的KV值)
  47. SpaceKV *JobKv //空格 kv (分出的对应的KV值)
  48. BPackage *BlockPackage //分包信息
  49. Tag map[string]bool //块标签
  50. Block []*Block //子块
  51. }
  52. //段落
  53. type Segment struct {
  54. Index int //段落索引
  55. Text string //段落内容
  56. }
  57. //包
  58. type BlockPackage struct {
  59. Index string //序号 (转换后编号,只有数字或字母)
  60. Origin string //包的原始值
  61. Type string //类型 (匹配后面的标段、包之类的词)
  62. Text string //包文 (包对应的正文)
  63. ColonKV *JobKv //冒号kv (分出的对应的KV值)
  64. TableKV *JobKv //table kv (分出的对应的KV值)
  65. SpaceKV *JobKv //空格 kv (分出的对应的KV值)
  66. BidStatus string //成交状态
  67. WinnerOrder []map[string]interface{} //中标人排序
  68. Accuracy bool //包里面抽取字段的准确性,如果能打上块标签的话,就不用中标候选人中的值覆盖包里面的值
  69. }
  70. //联系人
  71. type ContactFormat struct {
  72. Direction int
  73. IndexMap map[int]string
  74. MatchMap map[string]map[string]bool
  75. WeightMap map[string]map[string]interface{}
  76. }
  77. //kv
  78. type Kv struct {
  79. Key string
  80. Value string
  81. Line string
  82. PrevLine string
  83. NextLine string
  84. Title string
  85. }
  86. //最终放到job上的kv
  87. type JobKv struct {
  88. Kvs []*Kv //有序的冒号kv
  89. Kvs_2 []*Kv //有序的冒号kv
  90. Kv map[string]string //table kv (分出的对应的KV值)
  91. KvIndex map[string]int //kv_index(流程)
  92. KvTag map[string]*Tag //带权重的kv
  93. }
  94. func NewJobKv() *JobKv {
  95. return &JobKv{
  96. Kvs: []*Kv{},
  97. Kvs_2: []*Kv{},
  98. Kv: map[string]string{},
  99. KvTag: map[string]*Tag{},
  100. }
  101. }