浏览代码

抽取逻辑--lua扩展

zhangjinkun 6 年之前
父节点
当前提交
696e46a869

+ 59 - 34
src/jy/extract/extract.go

@@ -53,8 +53,7 @@ func RunExtractTestTask(ext *ExtractTask, startId, num string) bool {
 	n, _ := strconv.Atoi(num)
 	id := IdTrans(startId)
 	if id.Valid() {
-		query := bson.M{"_id": bson.M{"$gt": bson.ObjectIdHex(startId)}}
-		//list, _ := ext.TaskInfo.DB.Find(ext.TaskInfo.FromColl, query, nil, Fields, false, -1, -1)
+		query := bson.M{"_id": bson.M{"$gte": bson.ObjectIdHex(startId)}}
 		list, _ := ext.TaskInfo.DB.Find(ext.TaskInfo.FromColl, query, nil, Fields, false, 0, n)
 		for _, v := range *list {
 			j := PreInfo(v)
@@ -106,7 +105,7 @@ func RunExtractTask(ext *ExtractTask) {
 	if !ext.IsRun {
 		return
 	}
-	query := bson.M{"_id": bson.M{"$gt": bson.ObjectIdHex(ext.TaskInfo.LastExtId)}}
+	query := bson.M{"_id": bson.M{"$gte": bson.ObjectIdHex(ext.TaskInfo.LastExtId)}}
 	list, _ := ext.TaskInfo.DB.Find(ext.TaskInfo.FromColl, query, nil, Fields, false, -1, -1)
 	for _, v := range *list {
 		if !ext.IsRun {
@@ -260,7 +259,7 @@ func ExtRegCore(extfrom string, doc map[string]interface{}, j *ju.Job, in *RegLu
 	if in.IsLua {
 		lua := ju.LuaScript{Code: in.Code, Name: in.Name, Doc: doc, Script: in.RuleText}
 		if in.IsHasFields { //lua脚本配置有属性字段
-			lua.KvMap = getKvByLuaFields(j, in, et.Tag)
+			lua.KvMap = getKvByLuaFields(extfrom, j, in, et.Tag)
 		} else {
 			lua.KvMap = map[string][]map[string]interface{}{}
 		}
@@ -273,7 +272,7 @@ func ExtRegCore(extfrom string, doc map[string]interface{}, j *ju.Job, in *RegLu
 			if tmps, ok := v.([]map[string]interface{}); ok {
 				for _, tmp := range tmps {
 					j.Result[k] = append(j.Result[k],
-						&ju.ExtField{k, qu.ObjToString(tmp["key"]), qu.ObjToString(tmp["type"]), qu.ObjToString(tmp["matchtype"]), extfrom, tmp["value"]})
+						&ju.ExtField{k, qu.ObjToString(tmp["code"]), qu.ObjToString(tmp["code"]), qu.ObjToString(tmp["type"]), qu.ObjToString(tmp["matchtype"]), extfrom, tmp["value"]})
 				}
 			}
 		}
@@ -293,7 +292,7 @@ func ExtRegCore(extfrom string, doc map[string]interface{}, j *ju.Job, in *RegLu
 }
 
 //lua脚本根据属性设置提取kv值
-func getKvByLuaFields(j *ju.Job, in *RegLuaInfo, t map[string][]*Tag) map[string][]map[string]interface{} {
+func getKvByLuaFields(extfrom string, j *ju.Job, in *RegLuaInfo, t map[string][]*Tag) map[string][]map[string]interface{} {
 	kvmap := map[string][]map[string]interface{}{}
 	for _, vv := range in.LFields {
 		field := qu.ObjToString(vv)
@@ -310,10 +309,12 @@ func getKvByLuaFields(j *ju.Job, in *RegLuaInfo, t map[string][]*Tag) map[string
 								text := ju.TrimLRSpace(kv.Value, "")
 								if text != "" {
 									kvmap[field] = append(kvmap[field], map[string]interface{}{
+										"field":     field,
+										"code":      in.Code,
+										"ruletext":  tag.Key,
+										"extfrom":   extfrom,
 										"value":     text,
 										"type":      "colon1",
-										"field":     field,
-										"key":       tag.Key,
 										"matchtype": "tag_string",
 									})
 								}
@@ -324,10 +325,12 @@ func getKvByLuaFields(j *ju.Job, in *RegLuaInfo, t map[string][]*Tag) map[string
 								text := ju.TrimLRSpace(kv.Value, "")
 								if text != "" {
 									kvmap[field] = append(kvmap[field], map[string]interface{}{
+										"field":     field,
+										"code":      in.Code,
+										"ruletext":  tag.Key,
+										"extfrom":   extfrom,
 										"value":     text,
 										"type":      "colon1",
-										"field":     field,
-										"key":       tag.Key,
 										"matchtype": "tag_regexp",
 									})
 								}
@@ -341,10 +344,12 @@ func getKvByLuaFields(j *ju.Job, in *RegLuaInfo, t map[string][]*Tag) map[string
 								text := ju.TrimLRSpace(kv.Value, "")
 								if text != "" {
 									kvmap[field] = append(kvmap[field], map[string]interface{}{
+										"field":     field,
+										"code":      in.Code,
+										"ruletext":  tag.Key,
+										"extfrom":   extfrom,
 										"value":     text,
 										"type":      "colon2",
-										"field":     field,
-										"key":       tag.Key,
 										"matchtype": "tag_string",
 									})
 								}
@@ -355,10 +360,12 @@ func getKvByLuaFields(j *ju.Job, in *RegLuaInfo, t map[string][]*Tag) map[string
 								text := ju.TrimLRSpace(kv.Value, "")
 								if text != "" {
 									kvmap[field] = append(kvmap[field], map[string]interface{}{
+										"field":     field,
+										"code":      in.Code,
+										"ruletext":  tag.Key,
+										"extfrom":   extfrom,
 										"value":     text,
 										"type":      "colon2",
-										"field":     field,
-										"key":       tag.Key,
 										"matchtype": "tag_regexp",
 									})
 								}
@@ -378,10 +385,12 @@ func getKvByLuaFields(j *ju.Job, in *RegLuaInfo, t map[string][]*Tag) map[string
 								text := ju.TrimLRSpace(kv.Value, "")
 								if text != "" {
 									kvmap[field] = append(kvmap[field], map[string]interface{}{
+										"field":     field,
+										"code":      in.Code,
+										"ruletext":  tag.Key,
+										"extfrom":   extfrom,
 										"value":     text,
 										"type":      "space",
-										"field":     field,
-										"key":       tag.Key,
 										"matchtype": "tag_string",
 									})
 								}
@@ -392,10 +401,12 @@ func getKvByLuaFields(j *ju.Job, in *RegLuaInfo, t map[string][]*Tag) map[string
 								text := ju.TrimLRSpace(kv.Value, "")
 								if text != "" {
 									kvmap[field] = append(kvmap[field], map[string]interface{}{
+										"field":     field,
+										"code":      in.Code,
+										"ruletext":  tag.Key,
+										"extfrom":   extfrom,
 										"value":     text,
 										"type":      "space",
-										"field":     field,
-										"key":       tag.Key,
 										"matchtype": "tag_regexp",
 									})
 								}
@@ -415,10 +426,12 @@ func getKvByLuaFields(j *ju.Job, in *RegLuaInfo, t map[string][]*Tag) map[string
 								text := ju.TrimLRSpace(val, "")
 								if text != "" {
 									kvmap[field] = append(kvmap[field], map[string]interface{}{
+										"field":     field,
+										"code":      in.Code,
+										"ruletext":  tag.Key,
+										"extfrom":   extfrom,
 										"value":     text,
 										"type":      "table",
-										"field":     field,
-										"key":       tag.Key,
 										"matchtype": "tag_string",
 									})
 								}
@@ -429,10 +442,12 @@ func getKvByLuaFields(j *ju.Job, in *RegLuaInfo, t map[string][]*Tag) map[string
 								text := ju.TrimLRSpace(val, "")
 								if text != "" {
 									kvmap[field] = append(kvmap[field], map[string]interface{}{
+										"field":     field,
+										"code":      in.Code,
+										"ruletext":  tag.Key,
+										"extfrom":   extfrom,
 										"value":     text,
 										"type":      "table",
-										"field":     field,
-										"key":       tag.Key,
 										"matchtype": "tag_regexp",
 									})
 								}
@@ -462,17 +477,18 @@ func extRegCoreToResult(extfrom, text string, j *ju.Job, v *RegLuaInfo) map[stri
 					val := text[pos[p]:pos[p+1]]
 					extinfo[k] = map[string]interface{}{
 						"field":     v.Field,
-						"key":       v.Code,
-						"type":      "regexp",
-						"matchtype": "regcontent",
+						"code":      v.Code,
+						"ruletext":  v.RuleText,
 						"extfrom":   extfrom,
 						"value":     val,
+						"type":      "regexp",
+						"matchtype": "regcontent",
 					}
 					if val != "" {
 						if j.Result[v.Field] == nil {
 							j.Result[k] = [](*ju.ExtField){}
 						}
-						j.Result[k] = append(j.Result[k], &ju.ExtField{k, v.Code, "regexp", "regcontent", extfrom, val})
+						j.Result[k] = append(j.Result[k], &ju.ExtField{k, v.Code, v.RuleText, "regexp", "regcontent", extfrom, val})
 					}
 				}
 			}
@@ -482,16 +498,17 @@ func extRegCoreToResult(extfrom, text string, j *ju.Job, v *RegLuaInfo) map[stri
 		if val != "" {
 			extinfo[v.Field] = map[string]interface{}{
 				"field":     v.Field,
-				"key":       v.Code,
-				"type":      "regexp",
-				"matchtype": "regcontent",
+				"code":      v.Code,
+				"ruletext":  v.RuleText,
 				"extfrom":   extfrom,
 				"value":     val,
+				"type":      "regexp",
+				"matchtype": "regcontent",
 			}
 			if j.Result[v.Field] == nil {
 				j.Result[v.Field] = [](*ju.ExtField){}
 			}
-			j.Result[v.Field] = append(j.Result[v.Field], &ju.ExtField{v.Field, v.Code, "regexp", "regcontent", extfrom, val})
+			j.Result[v.Field] = append(j.Result[v.Field], &ju.ExtField{v.Field, v.Code, v.RuleText, "regexp", "regcontent", extfrom, val})
 		}
 	}
 	return extinfo
@@ -510,7 +527,7 @@ func ExtRegBack(j *ju.Job, in *RegLuaInfo, t *TaskInfo) {
 			if tmps, ok := v.([]map[string]interface{}); ok {
 				j.Result[k] = [](*ju.ExtField){}
 				for _, tmp := range tmps {
-					j.Result[k] = append(j.Result[k], &ju.ExtField{k, qu.ObjToString(tmp["key"]), qu.ObjToString(tmp["type"]), qu.ObjToString(tmp["matchtype"]), qu.ObjToString(tmp["extfrom"]), tmp["value"]})
+					j.Result[k] = append(j.Result[k], &ju.ExtField{k, qu.ObjToString(tmp["code"]), qu.ObjToString(tmp["ruletext"]), qu.ObjToString(tmp["type"]), qu.ObjToString(tmp["matchtype"]), qu.ObjToString(tmp["extfrom"]), tmp["value"]})
 				}
 			}
 		}
@@ -530,7 +547,8 @@ func ExtRegBack(j *ju.Job, in *RegLuaInfo, t *TaskInfo) {
 				j.Result[in.Field][k].Value = text
 				exts = append(exts, map[string]interface{}{
 					"field":     v.Field,
-					"key":       v.Key,
+					"code":      v.Code,
+					"ruletext":  v.RuleText,
 					"type":      v.Type,
 					"matchtype": v.MatchType,
 					"extfrom":   v.ExtFrom,
@@ -552,7 +570,8 @@ func ExtRegBack(j *ju.Job, in *RegLuaInfo, t *TaskInfo) {
 					j.Result[key][k].Value = text
 					exts = append(exts, map[string]interface{}{
 						"field":     v.Field,
-						"key":       v.Key,
+						"code":      v.Code,
+						"ruletext":  v.RuleText,
 						"type":      v.Type,
 						"matchtype": v.MatchType,
 						"extfrom":   v.ExtFrom,
@@ -578,10 +597,11 @@ func getResultMapForLua(j *ju.Job) map[string][]map[string]interface{} {
 		for _, v := range val {
 			tmp := map[string]interface{}{
 				"field":     v.Field,
+				"code":      v.Code,
+				"ruletext":  v.RuleText,
 				"value":     v.Value,
 				"type":      v.Type,
 				"matchtype": v.MatchType,
-				"key":       v.Key,
 				"extfrom":   v.ExtFrom,
 			}
 			result[key] = append(result[key], tmp)
@@ -684,5 +704,10 @@ func AnalysisSaveResult(doc *map[string]interface{}, result map[string][]*ju.Ext
 	task.DB.Update(task.SaveColl, `{"_id":"`+_id+`"}`, map[string]interface{}{"$set": tmp}, true, false)
 	//保存抽取详情
 	tmp["result"] = result
+	for k, v := range *doc {
+		if tmp[k] == nil { //&& (k != "detail" || k != "contenthtml") {
+			tmp[k] = v
+		}
+	}
 	db.Mgo.Update("extract_result", `{"_id":"`+_id+`"}`, map[string]interface{}{"$set": tmp}, true, false)
 }

+ 2 - 1
src/jy/util/article.go

@@ -18,7 +18,8 @@ type Job struct {
 
 type ExtField struct {
 	Field     string      //属性
-	Key       string      //匹配标签(字符串、正则)、正则或lua代码
+	Code      string      //匹配标签(字符串、正则)、正则或lua代码
+	RuleText  string      //内容
 	Type      string      //kv(细类:colon1,colon2,space,table)、正则(regexp)
 	MatchType string      //匹配类型:1:标签库类型(tag_string,tag_regexp),2:全文正则regcontent
 	ExtFrom   string      //抽取来源(title,detail)

+ 71 - 60
src/jy/util/script.go

@@ -4,6 +4,8 @@ package util
 import (
 	"encoding/json"
 	"fmt"
+	"log"
+	qu "qfw/util"
 
 	ljson "github.com/yuin/gopher-json"
 	"github.com/yuin/gopher-lua"
@@ -21,74 +23,83 @@ type LuaScript struct {
 //stype per:前置,core:抽取,back:后置
 func (s *LuaScript) RunScript(stype string) map[string]interface{} {
 	data := map[string]interface{}{}
-	s.L = lua.NewState()
-	s.L.PreloadModule("json", ljson.Loader)
-	defer s.L.Close()
-	if err := s.L.DoString(s.Script); err != nil {
-		data["err"] = err.Error()
-	} else {
-		if stype == "pre" {
-			tab := MapToLuaTable(s.L, s.Doc)
-			if err := s.L.CallByParam(lua.P{
-				Fn:      s.L.GetGlobal("main"),
-				NRet:    1,
-				Protect: true,
-			}, tab); err != nil {
-				data["err"] = err.Error()
-			}
-		} else if stype == "core" {
-			tab := MapToLuaTable(s.L, s.Doc)
-			block, _ := json.Marshal(s.Block)
-			kvMap := MapToLuaTable2(s.L, s.KvMap)
-			if err := s.L.CallByParam(lua.P{
-				Fn:      s.L.GetGlobal("main"),
-				NRet:    1,
-				Protect: true,
-			}, tab, lua.LString(block), kvMap); err != nil {
-				data["err"] = err.Error()
+	qu.Try(func() {
+		s.L = lua.NewState()
+		s.L.PreloadModule("json", ljson.Loader)
+		defer s.L.Close()
+		if err := s.L.DoString(s.Script); err != nil {
+			data["err"] = err.Error()
+		} else {
+			if stype == "pre" {
+				tab := MapToLuaTable(s.L, s.Doc)
+				if err := s.L.CallByParam(lua.P{
+					Fn:      s.L.GetGlobal("main"),
+					NRet:    1,
+					Protect: true,
+				}, lua.LString(s.Code), tab); err != nil {
+					data["err"] = err.Error()
+				}
+			} else if stype == "core" {
+				tab := MapToLuaTable(s.L, s.Doc)
+				block, _ := json.Marshal(s.Block)
+				kvMap := MapToLuaTable2(s.L, s.KvMap)
+				if err := s.L.CallByParam(lua.P{
+					Fn:      s.L.GetGlobal("main"),
+					NRet:    1,
+					Protect: true,
+				}, lua.LString(s.Code), tab, lua.LString(block), kvMap); err != nil {
+					data["err"] = err.Error()
+				}
+			} else if stype == "back" {
+				result := MapToLuaTable2(s.L, s.Result)
+				if err := s.L.CallByParam(lua.P{
+					Fn:      s.L.GetGlobal("main"),
+					NRet:    1,
+					Protect: true,
+				}, lua.LString(s.Code), result); err != nil {
+					data["err"] = err.Error()
+				}
 			}
-		} else if stype == "back" {
-			result := MapToLuaTable2(s.L, s.Result)
-			if err := s.L.CallByParam(lua.P{
-				Fn:      s.L.GetGlobal("main"),
-				NRet:    1,
-				Protect: true,
-			}, result); err != nil {
-				data["err"] = err.Error()
+			ret := s.L.Get(-1)
+			s.L.Pop(1)
+			if tmp, ok := ret.(*lua.LTable); ok {
+				data = LuaTableToMap(tmp)
+			} else {
+				data["rep"] = ret
 			}
 		}
-		ret := s.L.Get(-1)
-		s.L.Pop(1)
-		if tmp, ok := ret.(*lua.LTable); ok {
-			data = LuaTableToMap(tmp)
-		} else {
-			data["rep"] = ret
-		}
-	}
+	}, func(err interface{}) {
+		log.Println("lua err:", data["err"])
+	})
 	return data
 }
 func Logic(str string, doc map[string]interface{}) bool {
-	L := lua.NewState()
-	L.PreloadModule("json", ljson.Loader)
-	defer L.Close()
 	b := false
-	if err := L.DoString(str); err != nil {
-		panic(err)
-	} else {
-		tab := MapToLuaTable(L, doc)
-		if err := L.CallByParam(lua.P{
-			Fn:      L.GetGlobal("logic"),
-			NRet:    1,
-			Protect: true,
-		}, tab); err != nil {
-			panic(err)
-		}
-		ret := L.Get(-1)
-		L.Pop(1)
-		if ret.String() == "true" {
-			b = true
+	var errs error
+	qu.Try(func() {
+		L := lua.NewState()
+		L.PreloadModule("json", ljson.Loader)
+		defer L.Close()
+		if err := L.DoString(str); err != nil {
+			errs = err
+		} else {
+			tab := MapToLuaTable(L, doc)
+			if err := L.CallByParam(lua.P{
+				Fn:      L.GetGlobal("logic"),
+				NRet:    1,
+				Protect: true,
+			}, tab); err != nil {
+				errs = err
+			}
+			ret := L.Get(-1)
+			L.Pop(1)
+			if ret.String() == "true" {
+				b = true
+			}
 		}
-	}
+	}, func(err interface{}) {
+		log.Println("lua err:", errs)
+	})
 	return b
 }
 

+ 104 - 0
src/lua/comm.lua

@@ -0,0 +1,104 @@
+--[[抽取脚本工具类]]
+
+common={}
+
+--根据field获取结果对象
+function common.getFieldObjects(result,field)
+	for key, val in pairs(result) do
+		if key==field then
+			return val
+		end
+	end
+	return nil
+end
+
+--抽取field新增结果赋值object(field,code,ruletext,extfrom,field,value,type,matchtype)
+function common.setFieldObjects(result,field,object)
+	local nofield=true
+	for key, val in pairs(result) do
+		if key==field then
+			nofield=false
+			table.insert(val, object)
+		end
+	end
+	if nofield then
+		result[field]={object}
+	end
+	return result
+end
+
+--输出
+function printf(obj)
+	print(dump(obj) )
+end
+function dump(obj)  
+    local getIndent, quoteStr, wrapKey, wrapVal, isArray, dumpObj  
+    getIndent = function(level)  
+        return string.rep("\t", level)  
+    end  
+    quoteStr = function(str)  
+        str = string.gsub(str, "[%c\\\"]", {  
+            ["\t"] = "\\t",  
+            ["\r"] = "\\r",  
+            ["\n"] = "\\n",  
+            ["\""] = "\\\"",  
+            ["\\"] = "\\\\",  
+        })  
+        return '"' .. str .. '"'  
+    end  
+    wrapKey = function(val)  
+        if type(val) == "number" then  
+            return "[" .. val .. "]"  
+        elseif type(val) == "string" then  
+            return "[" .. quoteStr(val) .. "]"  
+        else  
+            return "[" .. tostring(val) .. "]"  
+        end  
+    end  
+    wrapVal = function(val, level)  
+        if type(val) == "table" then  
+            return dumpObj(val, level)  
+        elseif type(val) == "number" then  
+            return val  
+        elseif type(val) == "string" then  
+            return quoteStr(val)  
+        else  
+            return tostring(val)  
+        end  
+    end  
+    local isArray = function(arr)  
+        local count = 0   
+        for k, v in pairs(arr) do  
+            count = count + 1   
+        end   
+        for i = 1, count do  
+            if arr[i] == nil then  
+                return false  
+            end   
+        end   
+        return true, count  
+    end  
+    dumpObj = function(obj, level)  
+        if type(obj) ~= "table" then  
+            return wrapVal(obj)  
+        end  
+        level = level + 1  
+        local tokens = {}  
+        tokens[#tokens + 1] = "{"  
+        local ret, count = isArray(obj)  
+        if ret then  
+            for i = 1, count do  
+                tokens[#tokens + 1] = getIndent(level) .. wrapVal(obj[i], level) .. ","  
+            end  
+        else  
+            for k, v in pairs(obj) do  
+                tokens[#tokens + 1] = getIndent(level) .. wrapKey(k) .. " = " .. wrapVal(v, level) .. ","  
+            end  
+        end  
+        tokens[#tokens + 1] = getIndent(level - 1) .. "}"  
+        return table.concat(tokens, "\n")  
+    end  
+    return dumpObj(obj, 0)  
+end 
+--通用方法结束
+return common;

+ 11 - 0
src/main_test.go

@@ -3,6 +3,8 @@ package main
 import (
 	"jy/extract"
 	. "jy/mongodbutil"
+	"log"
+	"regexp"
 	"testing"
 	"time"
 )
@@ -12,3 +14,12 @@ func Test_task(t *testing.T) {
 	extract.StartExtractTaskId("5b8f804025e29a290415aee1")
 	time.Sleep(15 * time.Second)
 }
+func Test_reg(t *testing.T) {
+	context := ` 项目名称:   新碶街道2018年美女姜河、向家村河、塘湾河①河道清淤工程招标公告`
+	str := `[\s\\u3000\\u2003\\u00a0a-z0-9.、一二三]*项目名称[::][\n\s\\u3000\\u2003\\u00a0]*([^,,。;;::\n]{4,40})`
+	reg := regexp.MustCompile(str)
+	tmp := reg.FindAllStringSubmatch(context, -1)
+	for k, v := range tmp {
+		log.Println(k, v[1])
+	}
+}

+ 1 - 1
src/web/res/js/dialog.js

@@ -69,7 +69,7 @@ function OpenDialog(obj,data,callback){
 	}
 	if(obj.lua){	
 		setTimeout(function(){
-			com.initMirror(150)
+			com.initMirror(280)
 			editor_1.refresh()
 		},200)
 	}

+ 1 - 1
src/web/templates/admin/rule_backlist.html

@@ -125,7 +125,7 @@ $(function () {
 					_tit="新增规则"
 					if(n=="newlua"){
 						_tit="新增脚本"
-						obj={"s_luascript":"--result 抽取结果,过滤后返回result,对象结构不可改变\nfunction main(result)\n\t--过滤操作\n\treturn result\nend","s_version":"{{.version}}","s_type":"1"}
+						obj={"s_luascript":"--code脚本代码,result 抽取结果,过滤后返回result,对象结构不可改变\nfunction main(code,result)\n\t--过滤操作\n\treturn result\nend","s_version":"{{.version}}","s_type":"1"}
 						tag = com.pushArry(tag,luatag)
 						tag = com.pushArry(tag,hiddentag)
 						islua=true

+ 1 - 1
src/web/templates/admin/rule_logicbacklist.html

@@ -125,7 +125,7 @@ $(function () {
 					_tit="新增规则"
 					if(n=="newlua"){
 						_tit="新增脚本"
-						obj={"s_luascript":"--result 抽取结果,过滤后返回result,对象结构不可改变\nfunction main(result)\n\t--过滤操作\n\treturn result\nend","sid":"{{.sid}}","s_type":"1","s_version":"{{.version}}"}
+						obj={"s_luascript":"--code脚本代码,result 抽取结果,过滤后返回result,对象结构不可改变\nfunction main(code,result)\n\t--过滤操作\n\treturn result\nend","sid":"{{.sid}}","s_type":"1","s_version":"{{.version}}"}
 						tag = com.pushArry(tag,luatag)
 						tag = com.pushArry(tag,hiddentag)
 						islua=true

+ 1 - 1
src/web/templates/admin/rule_logicore.html

@@ -139,7 +139,7 @@ $(function () {
 					_tit="新增规则"
 					if(n=="newlua"){
 						_tit="新增脚本"
-						obj={"s_luascript":"--doc数据源,block块对象,kvs抽取kv对象,返回kvs对象,kvs结构不可改变\nfunction main(doc,block,kvs)\n\t--自定义抽取\n\treturn kvs\nend","sid":"{{.sid}}","s_type":"1","s_version":"{{.version}}"}
+						obj={"s_luascript":"--code脚本代码,doc数据源,block块对象,kvs抽取kv对象,返回kvs对象,kvs结构不可改变\nfunction main(code,doc,block,kvs)\n\t--自定义抽取\n\treturn kvs\nend","sid":"{{.sid}}","s_type":"1","s_version":"{{.version}}"}
 						tag = com.pushArry(tag,luatag)
 						tag = com.pushArry(tag,hiddentag)
 						islua=true

+ 1 - 1
src/web/templates/admin/rule_logicprelist.html

@@ -125,7 +125,7 @@ $(function () {
 					_tit="新增规则"
 					if(n=="newlua"){
 						_tit="新增脚本"
-						obj={"s_luascript":"--doc数据源,过滤后返回doc对象\nfunction main(doc)\n\t--过滤操作\n\treturn doc\nend","sid":"{{.sid}}","s_type":"1","s_version":"{{.version}}"}
+						obj={"s_luascript":"--code脚本代码,doc数据源,过滤后返回doc对象\nfunction main(code,doc)\n\t--过滤操作\n\treturn doc\nend","sid":"{{.sid}}","s_type":"1","s_version":"{{.version}}"}
 						tag = com.pushArry(tag,luatag)
 						tag = com.pushArry(tag,hiddentag)
 						islua=true

+ 1 - 1
src/web/templates/admin/rule_prelist.html

@@ -125,7 +125,7 @@ $(function () {
 					_tit="新增规则"
 					if(n=="newlua"){
 						_tit="新增脚本"
-						obj={"s_luascript":"--doc数据源,过滤后返回doc对象\nfunction main(doc)\n\t--过滤操作\n\treturn doc\nend","s_version":"{{.version}}","s_type":"1"}
+						obj={"s_luascript":"--code脚本代码,doc数据源,过滤后返回doc对象\nfunction main(code,doc)\n\t--过滤操作\n\treturn doc\nend","s_version":"{{.version}}","s_type":"1"}
 						tag = com.pushArry(tag,luatag)
 						tag = com.pushArry(tag,hiddentag)
 						islua=true