Skip to content
Projects
Groups
Snippets
Help
Loading...
Help
Contribute to GitLab
Sign in / Register
Toggle navigation
E
exa_news_classificator
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
Vasyl Bodnaruk
exa_news_classificator
Commits
5a945d1a
Commit
5a945d1a
authored
Aug 03, 2017
by
Tags
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
add text from table esi_news_accept for analysis
(but in main not in Class)
parent
00ddc741
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
45 additions
and
39 deletions
+45
-39
news_classify_tag.py
news_classify_tag.py
+45
-39
No files found.
news_classify_tag.py
View file @
5a945d1a
...
...
@@ -254,47 +254,53 @@ if __name__ == "__main__":
tags_classif
.
save
()
# exit(0)
sql1
=
'''SELECT rez.news_id , rez.title, rez.description
FROM(
SELECT wp_esi_tag_news.news_id, wp_esi_news.title, wp_esi_news.description
FROM wp_esi_news, wp_esi_tag_news WHERE wp_esi_tag_news.news_id=wp_esi_news.id
ORDER BY wp_esi_tag_news.tag_id ) AS rez
ORDER BY rand() LIMIT 15'''
tags_classif
.
db
.
query
(
sql1
)
news_results
=
tags_classif
.
db
.
store_result
()
news_results
=
news_results
.
fetch_row
(
maxrows
=
0
)
data
=
list
()
for
i
,(
id_news
,
title
,
description
)
in
enumerate
(
news_results
):
text_for_analis
=
title
.
decode
(
'ascii'
,
'ignore'
)
+
'
\n
'
+
description
.
decode
(
'ascii'
,
'ignore'
)
# print("\n#", str(i))
print
(
"
\n
News title: "
+
title
.
decode
(
'ascii'
,
'ignore'
))
tags_classif
.
classify
(
text_for_analis
)
print
(
"Model calculated Accordance(#tag,
%-
accordance, tag_description): "
,
end
=
" "
)
print
(
tags_classif
.
teg_accordance
)
sql
=
" SELECT tag_id FROM wp_esi_tag_news WHERE news_id ="
+
str
(
id_news
)
# print(sql)
results
=
tags_classif
.
db
.
query
(
sql
)
tags
=
tags_classif
.
db
.
store_result
()
tags
=
tags
.
fetch_row
(
maxrows
=
0
)
# print(tags)
# print(tags_classif.tags)
print
(
"User classified tags for present news:"
)
for
(
tag
,)
in
tags
:
tag
=
int
(
tag
)
# print(tag)
print
(
str
(
tag
)
+
" "
+
tags_classif
.
tags
[
tag
-
1
][
1
]
.
decode
(
'ascii'
,
'ignore'
))
exit
(
0
)
tags_classif
.
db
.
query
(
"SELECT title, description
FROM wp_esi_news
ORDER BY RAND() LIMIT 25"
)
#
sql1 = '''SELECT rez.news_id , rez.title, rez.description
#
FROM(
#
SELECT wp_esi_tag_news.news_id, wp_esi_news.title, wp_esi_news.description
#
FROM wp_esi_news, wp_esi_tag_news WHERE wp_esi_tag_news.news_id=wp_esi_news.id
# ORDER BY wp_esi_tag_news.tag_id ) AS rez
#
ORDER BY rand() LIMIT 15'''
#
#
tags_classif.db.query(sql1)
#
news_results = tags_classif.db.store_result()
#
news_results = news_results.fetch_row(maxrows=0)
#
data = list()
#
for i,(id_news, title, description) in enumerate(news_results):
#
text_for_analis = title.decode('ascii', 'ignore') + '\n' + description.decode('ascii', 'ignore')
#
# print("\n#", str(i))
#
print("\nNews title: " + title.decode('ascii', 'ignore'))
#
tags_classif.classify(text_for_analis)
#
print("Model calculated Accordance(#tag, %-accordance, tag_description): ", end=" ")
#
print(tags_classif.teg_accordance)
#
sql = " SELECT tag_id FROM wp_esi_tag_news WHERE news_id =" + str(id_news)
#
# print(sql)
#
results = tags_classif.db.query(sql)
#
tags = tags_classif.db.store_result()
#
tags = tags.fetch_row(maxrows=0)
#
# print(tags)
#
# print(tags_classif.tags)
#
print("User classified tags for present news:")
#
for(tag,) in tags:
#
tag = int(tag)
#
# print(tag)
#
print(str(tag) + " " + tags_classif.tags[tag - 1][1].decode('ascii', 'ignore'))
#
#
exit(0)
tags_classif
.
db
.
query
(
"SELECT title, description
, text FROM wp_esi_news_accept
ORDER BY RAND() LIMIT 25"
)
result
=
tags_classif
.
db
.
store_result
()
for
i
,(
title
,
description
)
in
enumerate
(
result
.
fetch_row
(
maxrows
=
0
)):
text_for_analis
=
title
+
'
\n
'
+
description
# news analysis witt title + description + text
for
i
,
(
title
,
description
,
text
)
in
enumerate
(
result
.
fetch_row
(
maxrows
=
0
)):
text_for_analys
=
''
if
title
is
not
None
:
text_for_analys
+=
title
.
decode
(
"ascii"
,
'ignore'
)
+
'
\n
'
if
description
is
not
None
:
text_for_analys
+=
description
.
decode
(
'ascii'
,
'ignore'
)
+
" "
if
text
is
not
None
:
text_for_analys
+=
text
.
decode
(
"ascii"
,
'ignore'
)
print
(
"
\n
#"
,
str
(
i
))
print
(
text_for_analis
)
tags_results
=
tags_classif
.
classify
(
text_for_analis
)
# pprint(tags_results[:5])
print
(
'Title: '
,
title
.
decode
(
"ascii"
,
'ignore'
))
tags_results
=
tags_classif
.
classify
(
text_for_analys
)
# accordance %
print
(
"Accordance(#tag,
%-
accordance, tag_description): "
)
...
...
@@ -304,4 +310,4 @@ if __name__ == "__main__":
# if i > 10: break
# Graph presentation results
tags_classif
.
graph_results
()
#
tags_classif.graph_results()
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