Skip to content
GitLab
Menu
Projects
Groups
Snippets
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
itminedu
okeanos-LoD
Commits
5b68fb19
Commit
5b68fb19
authored
Jun 23, 2015
by
efikalti
Browse files
LAM-19 changed tabs to spaces
parent
22705b47
Changes
1
Hide whitespace changes
Inline
Side-by-side
example/data-generator.py
View file @
5b68fb19
...
@@ -3,38 +3,38 @@ import random
...
@@ -3,38 +3,38 @@ import random
""" Create a random message with 20 words and 5 tags.
""" Create a random message with 20 words and 5 tags.
Create 2 lists, one for the message and one for the tags.
Create 2 lists, one for the message and one for the tags.
Select 25 random numbers in range 1 - #number of file lines.
Select 25 random numbers in range 1 - #number of file lines.
Read the file and for each line selected, add it to the appropriate list.
Read the file and for each line selected, add it to the appropriate list.
Finally print the message with the tags.
Finally print the message with the tags.
"""
"""
def
main
():
def
main
():
filename
=
'/usr/share/dict/american-english'
filename
=
'/usr/share/dict/american-english'
lines
=
list
()
lines
=
list
()
hashtags
=
list
()
hashtags
=
list
()
message
=
''
message
=
''
tags
=
''
tags
=
''
f
=
open
(
filename
)
f
=
open
(
filename
)
for
i
in
range
(
20
):
for
i
in
range
(
20
):
j
=
random
.
randrange
(
1
,
99171
)
j
=
random
.
randrange
(
1
,
99171
)
lines
.
append
(
j
)
lines
.
append
(
j
)
for
i
in
range
(
5
):
for
i
in
range
(
5
):
j
=
random
.
randrange
(
1
,
99171
)
j
=
random
.
randrange
(
1
,
99171
)
hashtags
.
append
(
j
)
hashtags
.
append
(
j
)
i
=
0
i
=
0
for
line
in
f
:
for
line
in
f
:
if
i
in
lines
:
if
i
in
lines
:
message
=
message
+
line
.
strip
()
+
' '
message
=
message
+
line
.
strip
()
+
' '
if
i
in
hashtags
:
if
i
in
hashtags
:
tags
=
tags
+
'#'
+
line
.
strip
()
+
' '
tags
=
tags
+
'#'
+
line
.
strip
()
+
' '
i
+=
1
i
+=
1
f
.
close
()
f
.
close
()
print
message
,
tags
print
message
,
tags
if
__name__
==
'__main__'
:
if
__name__
==
'__main__'
:
main
()
main
()
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