Skip to content
Projects
Groups
Snippets
Help
This project
Loading...
Sign in / Register
Toggle navigation
E
edx-platform
Overview
Overview
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
Snippets
Snippets
Members
Members
Collapse sidebar
Close sidebar
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Open sidebar
edx
edx-platform
Commits
6e46dc54
Commit
6e46dc54
authored
Apr 29, 2013
by
Alexander Kryklia
Committed by
Vasyl Nakvasiuk
May 13, 2013
Browse files
Options
Browse Files
Download
Email Patches
Plain Diff
correct calculation of percents
parent
23802f87
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
14 additions
and
5 deletions
+14
-5
common/lib/xmodule/xmodule/word_cloud_module.py
+14
-5
No files found.
common/lib/xmodule/xmodule/word_cloud_module.py
View file @
6e46dc54
...
@@ -80,12 +80,21 @@ class WordCloudModule(WordCloudFields, XModule):
...
@@ -80,12 +80,21 @@ class WordCloudModule(WordCloudFields, XModule):
"""Convert raw word to suitable word."""
"""Convert raw word to suitable word."""
return
word
.
strip
()
.
lower
()
return
word
.
strip
()
.
lower
()
def
prepare_words
(
self
,
words
,
total_count
):
def
prepare_words
(
self
,
top_words
,
total_count
):
"""Convert words dictionary for client API."""
"""Convert words dictionary for client API."""
return
[
list_to_return
=
[]
{
'text'
:
word
,
'size'
:
count
,
'percent'
:
round
(
100
*
(
count
/
float
(
total_count
)))}
for
percents
=
0
word
,
count
in
words
.
iteritems
()
current_num_top_words
=
len
(
top_words
)
]
for
num
,
word_tuple
in
enumerate
(
top_words
.
iteritems
()):
if
num
==
current_num_top_words
-
1
:
percent
=
100
-
percents
else
:
percent
=
round
(
100.0
*
word_tuple
[
1
]
/
total_count
)
percents
+=
percent
list_to_return
.
append
({
'text'
:
word_tuple
[
0
]
,
'size'
:
word_tuple
[
1
],
'percent'
:
percent
})
return
list_to_return
def
top_dict
(
self
,
dict_obj
,
amount
):
def
top_dict
(
self
,
dict_obj
,
amount
):
"""Return new dict: top of dict using dict value."""
"""Return new dict: top of dict using dict value."""
...
...
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