-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathshow_workflow.py
34 lines (28 loc) · 1018 Bytes
/
show_workflow.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from similarity.text.document import AnalizedDocument
if __name__ == '__main__':
text = """
A hedgehog is any of the spiny mammals of the subfamily Erinaceinae,
which is in order Erinaceomorpha. There are seventeen species of
hedgehog in five genera, found through parts of Europe, Asia, Africa and New Zealand.
"""
ad = AnalizedDocument(text)
print ad.terms_quantity
for term in ad.terms_quantity:
print "Term:", term
for cat, items in sorted(
ad.terms_relevance.items(),
key=lambda x: x[1].get(term), reverse=True
):
relevance = items.get(term, 0)
if relevance:
print "\t", cat, ":", relevance
print '-'*100
ad.calculate_terms_membership()
print ad.terms_membership
print '-'*100
ad.calculate_membership_to_categories()
for cat, value in sorted(
ad.categories_membership.items(),
key=lambda x: x[1], reverse=True
):
print cat, ':', value