// isextract.go
//标题、全文正则匹配，判断是否继续抽取
package extract

import (
	qu "qfw/util"
	"regexp"
)

var N_extractMap map[string][]string
var N_extract map[string][]*regexp.Regexp

func init() {
	qu.ReadConfig("./res/isextract.json", &N_extractMap)
	N_extract = map[string][]*regexp.Regexp{}
	for key, regs := range N_extractMap {
		for _, v := range regs {
			tmp, _ := regexp.Compile(v)
			N_extract[key] = append(N_extract[key], tmp)
		}
	}
}

func IsExtract(filed, title, content string) bool {
	defer qu.Catch()
	//临时的，抽取所有
	return true
	b := true
	if N_extract[filed] != nil {
		nregs := N_extract[filed]
		for _, v := range nregs { //标题
			rep := v.FindAllStringIndex(title, -1)
			if len(rep) > 0 {
				b = false
				break
			}
		}
		/*
			if b {
				for _, v := range N_extract["filter"] {
					content = v.ReplaceAllString(content, "")
				}
				for _, v := range nregs { //正文
					rep := v.FindAllStringIndex(content, -1)
					if len(rep) > 0 {
						b = false
						break
					}
				}
			}
		*/
	}
	return b
}
