Skip to content
Toggle navigation
P
Projects
G
Groups
S
Snippets
Help
lichenggang
/
bom_identify
This project
Loading...
Sign in
Toggle navigation
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Snippets
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit
b63dcce9
authored
Dec 01, 2020
by
lichenggang
Browse files
Options
_('Browse Files')
Download
Email Patches
Plain Diff
新增品牌异常检测服务
parent
ae700280
Show whitespace changes
Inline
Side-by-side
Showing
3 changed files
with
79 additions
and
0 deletions
config.py
utils/redis_cli.py
valid_server.py
config.py
View file @
b63dcce9
...
...
@@ -11,3 +11,5 @@ if ENVIRONMENT == 'test':
model_config
[
'modextr_path'
]
=
project_path
+
r'/'
+
'models_and_extractors/'
else
:
model_config
[
'modextr_path'
]
=
project_path
+
r'/'
+
'models_and_extractors/'
redis_config
=
{
'host'
:
'192.168.1.235'
,
'port'
:
6379
,
'decode_responses'
:
True
,
'password'
:
'icDb29mLy2s'
}
utils/redis_cli.py
0 → 100644
View file @
b63dcce9
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import
redis
from
config
import
redis_config
redis_cli
=
redis
.
Redis
(
**
redis_config
)
valid_server.py
0 → 100644
View file @
b63dcce9
#!/usr/bin/env python
# -*- coding:utf-8 -*-
import
json
from
urllib.parse
import
unquote
import
tornado.web
import
tornado.ioloop
from
utils.redis_cli
import
redis_cli
from
predict.kw_predict
import
KwPredict
from
utils.status
import
code2msg
class
BrandKwHandler
(
tornado
.
web
.
RequestHandler
):
def
__init__
(
self
,
*
args
,
**
kwargs
):
super
()
.
__init__
(
*
args
,
**
kwargs
)
self
.
predic
=
KwPredict
(
'validSingle'
)
self
.
redis_cli
=
redis_cli
async
def
get
(
self
):
target
=
unquote
(
self
.
get_argument
(
'keyword'
,
''
))
brand_set
=
redis_cli
.
smembers
(
'brand_set'
)
if
not
target
:
code
=
'100001'
res
=
code2msg
(
code
)
else
:
code
=
1
res
=
{}
if
len
(
target
)
==
1
or
target
.
isdigit
()
or
len
(
target
)
>=
50
:
score
=
0
elif
target
in
brand_set
:
score
=
1
else
:
resp1
=
self
.
predic
.
predict
(
target
,
'all'
)
resp2
=
self
.
predic
.
predict
(
target
,
'brand'
)
if
resp1
[
'result'
]
==
'品牌'
and
resp2
[
'result'
]:
score
=
0.9
elif
resp1
[
'result'
]
!=
'品牌'
and
resp2
[
'result'
]:
score
=
0.7
elif
resp1
[
'result'
]
==
'品牌'
and
not
resp2
[
'result'
]:
score
=
0.7
else
:
score
=
0.1
res
[
'status'
]
=
code
res
[
'score'
]
=
score
self
.
write
(
res
)
async
def
post
(
self
):
target
=
self
.
request
.
body
list_data
=
json
.
loads
(
self
.
request
.
body
)
def
gen_app
():
return
tornado
.
web
.
Application
(
handlers
=
[(
k
,
v
)
for
k
,
v
in
register_tornado_handlers
.
items
()])
register_tornado_handlers
=
{
'/brandkw'
:
BrandKwHandler
}
def
http_server
(
port
):
app
=
gen_app
()
app
.
listen
(
port
)
tornado
.
ioloop
.
IOLoop
.
current
()
.
start
()
if
__name__
==
'__main__'
:
port
=
50053
http_server
(
port
)
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment