Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
E
esi-table-data
Project
Project
Details
Activity
Cycle Analytics
Repository
Repository
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Issues
0
Issues
0
List
Board
Labels
Milestones
Merge Requests
0
Merge Requests
0
CI / CD
CI / CD
Pipelines
Jobs
Schedules
Charts
Wiki
Wiki
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
esi-data-scrapping
esi-table-data
Commits
793b4a18
Commit
793b4a18
authored
Oct 06, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add functional for block teach model if it's not needed
parent
5d3bfe77
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
12 additions
and
2 deletions
+12
-2
pipelines.py
exa/exa/pipelines.py
+12
-2
No files found.
exa/exa/pipelines.py
View file @
793b4a18
...
...
@@ -25,9 +25,9 @@ class ExaPipeline(object):
create classifier for making tags
make Redis buffer for collect all news from DB
'''
self
.
teach
=
False
self
.
db
=
Database
(
**
db
)
self
.
classifier
=
Classifier
(
host
=
db
[
'host'
],
user
=
db
[
'user'
],
password
=
db
[
'pwd'
],
db
=
db
[
'database'
],
port
=
3306
)
self
.
classifier
.
teach_model
()
self
.
classifier
=
None
self
.
buffer
=
redis
.
StrictRedis
()
self
.
ml_data
=
MLDataMaker
(
self
.
db
)
for
i
in
self
.
db
.
select
(
'select url from wp_esi_news_accept'
):
...
...
@@ -37,6 +37,8 @@ class ExaPipeline(object):
def
open_spider
(
self
,
spider
):
spider
.
pipeline
=
self
self
.
teach
=
spider
.
teach
self
.
classifier
=
self
.
_create_classifier
()
def
process_item
(
self
,
item
,
spider
):
item
[
'title'
]
=
''
.
join
(
item
[
'title'
])
.
replace
(
'
\n
'
,
' '
)
...
...
@@ -125,3 +127,11 @@ class ExaPipeline(object):
for
i
in
data
:
self
.
db
.
insert
(
'INSERT INTO wp_esi_ml_data (news_id, tag_id) VALUES(
%
s,
%
s);'
,
(
i
.
news_id
,
i
.
tags_id
))
def
_create_classifier
(
self
):
if
self
.
teach
:
classifier
=
Classifier
(
host
=
db
[
'host'
],
user
=
db
[
'user'
],
password
=
db
[
'pwd'
],
db
=
db
[
'database'
],
port
=
3306
)
classifier
.
teach_model
()
return
classifier
else
:
return
None
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