unknown 6 лет назад
Родитель
Сommit
43c2c7d9f0

+ 36 - 31
src/jy/clear/specialsymbols.go

@@ -1,6 +1,7 @@
 package clear
 
 import (
+	"fmt"
 	qu "qfw/util"
 	"regexp"
 	"strings"
@@ -111,7 +112,7 @@ func RemoveStart(i int, text []rune) []rune {
 					lock.Lock()
 					fdSymbol := SymmetricMap[now]
 					lock.Unlock()
-					if fdSymbol != "" { //反向符号,找出对称的正向符号
+					if fdSymbol != "" && fdSymbol != now { //反向符号,找出对称的正向符号(fdSymbol != now:处理正反向符号是"或者')
 						tmp := symbolIndex[fdSymbol]
 						if len(tmp) == 0 { //多出来的反向符号,记录最大值
 							if index > surplusMax {
@@ -250,44 +251,48 @@ func AnotherRemoveStart(text []rune) []rune {
 					lock.Lock()
 					fdSymbol := SymmetricMap[now]
 					lock.Unlock()
-					if fdSymbol != "" { //去除第一个反符号
-						text = text[1:len(text)]
-					} else if len(now) > 0 { //第一个是正符号,记录索引位置
-						tmpArr := []int{index}
-						symbolIndex[now] = tmpArr
+					if fdSymbol != now { //(fdSymbol != now:处理正反向符号是"或者')
+						if fdSymbol != "" { //去除第一个反符号
+							text = text[1:len(text)]
+						} else if len(now) > 0 { //第一个是正符号,记录索引位置
+							tmpArr := []int{index}
+							symbolIndex[now] = tmpArr
+						}
 					}
 				} else {
 					lock.Lock()
 					fdSymbol := SymmetricMap[now]
 					lock.Unlock()
-					if fdSymbol != "" { //反向符号,找出对称的正向符号
-						tmp := symbolIndex[fdSymbol]
-						if len(tmp) == 0 { //多出来的反向符号,记录最大值
-							if index > surplusMax {
-								surplusMax = index
+					if fdSymbol != now { //(fdSymbol != now:处理正反向符号是"或者')
+						if fdSymbol != "" { //反向符号,找出对称的正向符号
+							tmp := symbolIndex[fdSymbol]
+							if len(tmp) == 0 { //多出来的反向符号,记录最大值
+								if index > surplusMax {
+									surplusMax = index
+								}
+							} else {
+								nowIndex := tmp[len(tmp)-1]              //索引位置
+								symbolIndex[fdSymbol] = tmp[:len(tmp)-1] //匹配索引位置后,删除之前的记录
+								if len(symbolIndex[fdSymbol]) == 0 {
+									delete(symbolIndex, fdSymbol)
+								}
+								//将成对的符号的index记录,
+								if index == length-1 {
+									pairedIndex[index] = nowIndex
+								}
+								pairedIndex[nowIndex] = index
+								tmpLength = tmpLength + len(text[nowIndex:index+1])
 							}
-						} else {
-							nowIndex := tmp[len(tmp)-1]              //索引位置
-							symbolIndex[fdSymbol] = tmp[:len(tmp)-1] //匹配索引位置后,删除之前的记录
-							if len(symbolIndex[fdSymbol]) == 0 {
-								delete(symbolIndex, fdSymbol)
+						} else { //正向符号,加入symbolIndex记录索引
+							tmpArr := []int{}
+							if len(symbolIndex[now]) > 0 { //有该符号的索引位置
+								tmpArr = symbolIndex[now]
+								tmpArr = append(tmpArr, index)
+							} else { //没有该符号的索引位置
+								tmpArr = []int{index}
 							}
-							//将成对的符号的index记录,
-							if index == length-1 {
-								pairedIndex[index] = nowIndex
-							}
-							pairedIndex[nowIndex] = index
-							tmpLength = tmpLength + len(text[nowIndex:index+1])
-						}
-					} else { //正向符号,加入symbolIndex记录索引
-						tmpArr := []int{}
-						if len(symbolIndex[now]) > 0 { //有该符号的索引位置
-							tmpArr = symbolIndex[now]
-							tmpArr = append(tmpArr, index)
-						} else { //没有该符号的索引位置
-							tmpArr = []int{index}
+							symbolIndex[now] = tmpArr
 						}
-						symbolIndex[now] = tmpArr
 					}
 				}
 			}

+ 7 - 9
src/jy/extract/extract.go

@@ -55,12 +55,8 @@ func StartExtractTestTask(taskId, startId, num, resultcoll, trackcoll string) bo
 	ext.InitAuditClass()
 	ext.InitAuditRecogField()
 
-	//品牌抽取
+	//品牌抽取是否开启
 	ju.IsBrandGoods = ju.Config["brandgoods"].(bool)
-	if ju.Config["brandgoods"].(bool) {
-		InitBrand()
-		InitGoods()
-	}
 	return RunExtractTestTask(ext, startId, num)
 }
 
@@ -123,10 +119,6 @@ func StartExtractTaskId(taskId string) bool {
 	ext.InitAuditClass()
 	ext.InitAuditRecogField()
 
-	//品牌抽取
-	InitBrand()
-	InitGoods()
-
 	ext.IsRun = true
 	go ext.ResultSave()
 	go ext.BidSave()
@@ -308,7 +300,13 @@ func (e *ExtractTask) ExtractProcess(j *ju.Job) {
 				if clear.AsyField[key] != nil || clear.SymField[key] != nil ||
 					clear.MesField[key] != nil {
 					text := qu.ObjToString(v.Value)
+					if key == "projectname" {
+						fmt.Println("1===========", text)
+					}
 					text = clear.OtherClean(key, text)
+					if key == "projectname" {
+						fmt.Println("2===========", text)
+					}
 					v.Value = text
 				}
 			}

+ 0 - 12
src/jy/extract/extractInit.go

@@ -912,15 +912,3 @@ func (c *ClearTask) InitClearLuas() {
 		}
 	}
 }
-
-//初始化商品
-func InitGoods() {
-	ju.GoodsGet = &ju.DFA{}
-	ju.GoodsGet.AddWord(ju.GoodsConfig...)
-}
-
-//初始化品牌
-func InitBrand() {
-	ju.BrandGet = &ju.DFA{}
-	ju.BrandGet.AddWord(ju.BrandConfig...)
-}

+ 12 - 0
src/jy/util/util.go

@@ -144,3 +144,15 @@ func (d *DFA) CheckSensitiveWord(src string) string {
 	}
 	return res
 }
+
+//初始化商品
+func InitGoods() {
+	GoodsGet = &DFA{}
+	GoodsGet.AddWord(GoodsConfig...)
+}
+
+//初始化品牌
+func InitBrand() {
+	BrandGet = &DFA{}
+	BrandGet.AddWord(BrandConfig...)
+}

+ 2 - 0
src/main.go

@@ -20,6 +20,8 @@ func init() {
 	qu.ReadConfig("./res/brandrule.json", &util.BrandRules)
 	qu.ReadConfig("./res/goods.json", &util.GoodsConfig)
 	qu.ReadConfig("./res/brand.json", &util.BrandConfig)
+	util.InitBrand()
+	util.InitGoods()
 	//初始化mongo连接
 	util.InitMgoPool()
 	//初始化redis

+ 2 - 2
src/web/templates/admin/task_clearlist.html

@@ -4,7 +4,7 @@
 <!-- Left side column. 权限菜单 -->
 {{template "memu"}}
 
-<div class="content-wrapper">
+<div class="content-wrapper" id="showbtn">
 	<section class="content-header">
 		<h1>
 			<small><a class="btn btn-primary opr" opr="new">新增清理任务</a></small>
@@ -72,7 +72,7 @@ $(function () {
        	]
 	});
 	ttable.on('init.dt', function () {
-		$("#dataTable").on('click','a.opr',function(){
+		$("#showbtn").on('click','a.opr',function(){
 			var n=$(this).attr("opr");
 			var taskid=$(this).attr("taskid");
 			var htmlObj={},obj,tag=[],bts=[];