Commit 97921baa authored by sanlu's avatar sanlu

添加了0507模型,自动解析参数部署服务器上传至数据库功能

parent ab232b33
This source diff could not be displayed because it is too large. You can view the blob instead.
174426^Thinkpad联想笔记本电脑X250-20CLA4D3CD/i5-5200U/4G/500G-7200/12.5/Win10;
1222366^Thinkpad L580 02CD I5-8250U 4GB 500GB 2GB独显 WIN10HB 笔记本(计价单位:台);
\ No newline at end of file
174426^Thinkpad联想笔记本电脑X250-20CLA4D3CD/[@i5-5200U#CPU型号*]/[@4G#内存容量*]/[@500G#硬盘容量*]-7200/12.5/[@Win10#操作系统*];
1222366^Thinkpad L580 02CD [@I5-8250U#CPU型号*] [$4G#内存容量*]B [$500G#硬盘容量*]B [@2GB独显#显存容量*] [@WIN10HB#操作系统*] 笔记本(计价单位:台)
\ No newline at end of file
#!/bin/bash
#date:20191216
#explain:监控目录是否发生变化
#by:Satan
CHECKDIR="/root/program/tagdata/data" #监控目录路径
LOG="/root/program/tagdata/tagdata.log" #日志存放路径
PYTHON="/root/program/tagdata/test.py" #调用的
function CheckDir {
inotifywait -mrq --timefmt '%y-%m-%d %H:%M' --format '%T %f %e' -e 'create,delete,modify,moved_to' $CHECKDIR|while read event
do
INO_TIME=$(echo $event | awk '{print $1,$2}') # 把inotify输出切割 把时间部分赋值给INO_TIME
INO_FILE=$(echo $event | awk '{print $3}') # 把inotify输出切割 把文件路径部分赋值给INO_FILE
INO_EVENT=$(echo $event | awk '{print $4}') # 把inotify输出切割 把事件类型部分赋值给INO_EVENT
if [[ $INO_EVENT = 'CREATE' ]] && [[ $INO_FILE != .* ]];then # 判断事件类型(create)
echo "`date '+%Y-%m-%d %H:%M'` create file: $INO_FILE" >> $LOG
/root/anaconda3/bin/python $PYTHON create "上传了一个标注文件:${INO_FILE}" $INO_TIME
fi
#elif [[ $INO_EVENT = 'CREATE,ISDIR' ]];then
# echo "`date '+%Y-%m-%d %H:%M'` create dir: $INO_FILE" >> $LOG
# /root/anaconda3/envs/py36/bin/python3 $PYTHON create "创建了一个目录:${INO_FILE},详情见附件" $LOG
#fi
if [[ $INO_EVENT = 'DELETE' ]] && [[ $INO_FILE != .* ]];then # 判断事件类型(delete)
echo "`date '+%Y-%m-%d %H:%M'` delete file: $INO_FILE" >> $LOG
# /root/anaconda3/envs/py36/bin/python3 $PYTHON delete "删除了一个文件:${INO_FILE},详情见附件" $LOG
#elif [[ $INO_EVENT = 'DELETE,ISDIR' ]];then
# echo "`date '+%Y-%m-%d %H:%M'` delete dir: $INO_FILE" >> $LOG
# /root/anaconda3/envs/py36/bin/python3 $PYTHON delete "删除了一个目录:${INO_FILE},详情见附件" $LOG
fi
#if [[ $INO_EVENT = 'MODIFY' ]] && [[ $INO_FILE != .* ]];then # 判断事件类型(modify)
# echo "`date '+%Y-%m-%d %H:%M'` modify file: $INO_FILE" >> $LOG
# /root/anaconda3/envs/py36/bin/python3 $PYTHON delete "修改了一个文件:${INO_FILE},详情见附件" $LOG
#fi
done
}
CheckDir
\ No newline at end of file
# -*- coding:utf-8 -*-
# Date:2019-12-16
import sys
import pandas as pd
import pymssql
import re
from sqlalchemy import create_engine
import time
class sql_find():
def __init__ (self, database='ZI_DataBase', localhost=True):
if localhost:
self.conn = pymssql.connect(host='localhost', user='zgc',password='1234',database=database,autocommit=True)
self.engine = create_engine(f'mssql+pymssql://zgc:1234@localhost/{database}')
else:
self.conn = pymssql.connect(host='123.56.115.207', user='zgcprice3311',password='admin@2018@)!*',database=database,autocommit=True)
self.engine = create_engine(f'mssql+pymssql://zgcprice3311:admin@2018@)!*@123.56.115.207/{database}')
self.cursor = self.conn.cursor()
def jiexi(filename):
f = open(filename,'r',encoding='utf-8')
entityRe = r'\[\@.*?\#.*?\*\](?!\#)'
recommendRe = r'\[\$.*?\#.*?\*\](?!\#)'
product_data_dict = {}
for data in f:
str = data.split('^')
sku = str[0]
product_data_dict[sku] = {}
for word in re.findall(entityRe,str[1]):
product_data_dict[sku][word.strip('[@*]').rsplit('#')[1]] = word.strip('[@*]').rsplit('#')[0]
for word in re.findall(recommendRe,str[1]):
product_data_dict[sku][word.strip('[$*]').rsplit('#')[1]] = word.strip('[$*]').rsplit('#')[0]
return product_data_dict
def param_upload(filename):
now_time = time.strftime("%Y-%m-%d", time.localtime())
#filename = 'LXWL_2019-12-12_0101.txt.ann'
sql_ZIdatabase = sql_find('ZI_DataBase', False)
source = filename.split('/')[-1].split('.txt')[0].split('_')[0]
batch = filename.split('/')[-1].split('.txt')[0].split('_')[1]
subcategorycode = filename.split('/')[-1].split('.')[0].split('_')[2]
param_data_dict = jiexi(filename)
update_table = {
'batch':[],
'source':[],
'productId':[],
'productName':[],
'param':[],
'paramAttributeImportant':[],
'paramAttributeMatch':[],
'paramAttributeStandard':[],
'value':[],
'paramSource':[],
'state':[],
'subcategorycode':[]
}
for productid in param_data_dict.keys():
sql_ZIdatabase.cursor.execute(f"select productName,paramAttributeImportant,paramAttributeMatch,paramAttributeStandard from Product_Parameter_Process where batch='{batch}' and source='{source}' and productId='{productid}'")
product_name_data = sql_ZIdatabase.cursor.fetchone()
for productparam in param_data_dict[productid].keys():
update_table['batch'].append(batch)
update_table['source'].append(source)
update_table['productId'].append(productid)
update_table['productName'].append(product_name_data[0])
update_table['param'].append(productparam)
update_table['paramAttributeImportant'].append(product_name_data[1])
update_table['paramAttributeMatch'].append(product_name_data[2])
update_table['paramAttributeStandard'].append(product_name_data[3])
update_table['value'].append(param_data_dict[productid][productparam])
update_table['paramSource'].append('名称提取参数项')
update_table['state'].append('1')
update_table['subcategorycode'].append(subcategorycode)
update_table_df = pd.DataFrame.from_dict(update_table)
#update_table_df.to_excel(f'update_data_{now_time}.xlsx')
update_table_df.to_sql('Product_Parameter_Process', sql_ZIdatabase.engine, if_exists='append', index=False)
\ No newline at end of file
# -*- coding:utf-8 -*-
# Date:2019-12-16
import sys
from param_load_func import *
subject = sys.argv[1] # 文件动作
msg = sys.argv[2] # 文件信息
date = str(sys.argv[3]) # 日期
time = str(sys.argv[4]) # 时间
param_upload('data/'+msg.split(':')[-1])
This source diff could not be displayed because it is too large. You can view the blob instead.
...@@ -154,7 +154,7 @@ class LSTMNER: ...@@ -154,7 +154,7 @@ class LSTMNER:
return param_dict return param_dict
if __name__ == '__main__': if __name__ == '__main__':
ner = LSTMNER('0810') ner = LSTMNER('0507')
while 1: while 1:
a = input('请输入产品名称:') a = input('请输入产品名称:')
#print(ner.class_dict) #print(ner.class_dict)
......
...@@ -209,5 +209,5 @@ class LSTMNER: ...@@ -209,5 +209,5 @@ class LSTMNER:
f.close() f.close()
if __name__ == '__main__': if __name__ == '__main__':
ner = LSTMNER('0810') ner = LSTMNER('0507')
ner.train_model() ner.train_model()
\ No newline at end of file
This source diff could not be displayed because it is too large. You can view the blob instead.
T
)
N
K
2
(
E
n
便
8
b
1
D
d
V
使
F
-
t
u
6
o
UNK
Z
h
;
Q
J
 
W
j
I
k
w
c
4
9
7
*
s
e
5
i
×
O
X
U
x
0
B
M
P
S
3
C
Y
v
g
H
z
A
l
+
p
r
f
m
R
稿
.
y
线
a
:
L
G
/
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment