Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
chinese-obfs
Manage
Activity
Members
Labels
Plan
Issues
0
Issue boards
Milestones
Wiki
Code
Merge requests
0
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Recolic
chinese-obfs
Commits
c09827aa
There was an error fetching the commit references. Please try again later.
Commit
c09827aa
authored
3 years ago
by
Bensong Liu
Browse files
Options
Downloads
Patches
Plain Diff
prepare for encoding
parent
1c7c1fb6
No related branches found
No related tags found
No related merge requests found
Changes
2
Expand all
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
bullshit.py
+23
-14
23 additions, 14 deletions
bullshit.py
data.json
+140
-140
140 additions, 140 deletions
data.json
with
163 additions
and
154 deletions
bullshit.py
+
23
−
14
View file @
c09827aa
...
...
@@ -12,10 +12,10 @@ def loadJson(fileName):
return
json
.
loads
(
file
.
read
())
data
=
loadJson
(
"
data.json
"
)
famous_data
=
list
(
data
[
'
famous
'
])
# a 代表prefix_data,b代表postfix_data
prefix_data
=
list
(
data
[
'
before
'
])
# 在famous_data前面弄点nonsense_data
postfix_data
=
list
(
data
[
'
after
'
])
# 在famous_data后面弄点nonsense_data
nonsense_data
=
list
(
data
[
'
bosh
'
])
# 代表文章主要nonsense_data来源
famous_data
=
list
(
data
[
'
famous
'
])
# a 代表prefix_data,b代表postfix_data
prefix_data
=
list
(
data
[
'
prefixes
'
])
# 在famous_data前面弄点nonsense_data
postfix_data
=
list
(
data
[
'
postfixes
'
])
# 在famous_data后面弄点nonsense_data
nonsense_data
=
list
(
data
[
'
shits
'
])
# 代表文章主要nonsense_data来源
print
(
"
debug: len=
"
,
[
len
(
l
)
for
l
in
[
famous_data
,
prefix_data
,
postfix_data
,
nonsense_data
]])
...
...
@@ -35,23 +35,32 @@ famous_generator = randomized_yield(famous_data)
def
new_famous
():
global
famous_generator
famous
=
next
(
famous_generator
)
famous
=
famous
.
replace
(
"
a
"
,
random
.
choice
(
prefix_data
)
)
famous
=
famous
.
replace
(
"
b
"
,
random
.
choice
(
postfix_data
)
)
famous
=
famous
.
replace
(
"
$prefix
"
,
random
.
choice
(
prefix_data
)
)
famous
=
famous
.
replace
(
"
$postfix
"
,
random
.
choice
(
postfix_data
)
)
return
famous
def
new_paragraph
():
return
"
.
\r\n
"
def
paragraph_tail
():
return
"
\r\n
"
def
paragraph_is_valid
(
text
):
if
len
(
text
)
<
16
:
return
False
if
text
[
-
1
]
==
'
,
'
or
text
[
-
1
]
==
'
:
'
:
return
False
return
True
if
__name__
==
"
__main__
"
:
topic
=
input
(
"
请输入文章主题:
"
)
result
=
str
()
result
=
'
'
curr_paragraph
=
''
while
(
len
(
result
)
<
6000
)
:
randsrc
=
random
.
randint
(
0
,
100
)
if
randsrc
<
5
:
result
+=
new_paragraph
()
if
randsrc
<
5
and
paragraph_is_valid
(
curr_paragraph
):
result
+=
curr_paragraph
+
paragraph_tail
()
curr_paragraph
=
''
elif
randsrc
<
20
:
result
+=
new_famous
()
curr_paragraph
+=
new_famous
()
else
:
result
+=
next
(
nonsense_generator
)
result
=
result
.
replace
(
"
x
"
,
topic
)
curr_paragraph
+=
next
(
nonsense_generator
)
result
=
result
.
replace
(
"
$topic
"
,
topic
)
print
(
result
)
This diff is collapsed.
Click to expand it.
data.json
+
140
−
140
View file @
c09827aa
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment