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
bfc6c7da
Commit
bfc6c7da
authored
Aug 15, 2017
by
Vasyl Bodnaruk
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
Add documentations for pipeline
parent
68235128
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
21 additions
and
0 deletions
+21
-0
pipelines.py
exa/exa/pipelines.py
+21
-0
No files found.
exa/exa/pipelines.py
View file @
bfc6c7da
...
...
@@ -18,6 +18,12 @@ db = get_project_settings().get('DB')
class
ExaPipeline
(
object
):
def
__init__
(
self
):
'''
This pipeline make
conect to DB,
create classifier for making tags
make Redis buffer for collect all news from DB
'''
self
.
db
=
Database
(
**
db
)
self
.
classifier
=
Classifier
()
self
.
classifier
.
teach_model
()
...
...
@@ -58,6 +64,11 @@ class ExaPipeline(object):
self
.
add_url_to_block
(
item
[
'url'
])
def
check_url
(
self
,
url
):
'''
Function check url in redis buffer
:param url: url from item
:return: True if url already exist in buffer
'''
if
bool
(
self
.
buffer
.
get
(
url
)):
print
(
"IN REDIS"
)
return
True
...
...
@@ -68,12 +79,22 @@ class ExaPipeline(object):
self
.
buffer
.
set
(
url
,
True
)
def
get_article
(
self
,
url
):
'''
Function take text from url for processing
:param url:
:return: text from url
'''
article
=
Article
(
url
)
article
.
download
()
article
.
parse
()
return
article
.
text
def
get_tags
(
self
,
text
):
'''
Function for make tags use ML algorithm
:param text: Text for searching tags
:return: json object with tags that are relevant for text
'''
self
.
classifier
.
classify
(
text
)
tags
=
list
()
for
i
in
self
.
classifier
.
teg_accordance
:
...
...
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