Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
R
RL-Parsing
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package Registry
Container 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
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Franck Dary
RL-Parsing
Commits
24e86989
Commit
24e86989
authored
3 years ago
by
Franck Dary
Browse files
Options
Downloads
Patches
Plain Diff
Added artificial dataset to test backtrack
parent
6c8dcca4
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
data/artificial/generate.py
+33
-0
33 additions, 0 deletions
data/artificial/generate.py
with
33 additions
and
0 deletions
data/artificial/generate.py
0 → 100755
+
33
−
0
View file @
24e86989
#! /usr/bin/env python3
import
numpy
import
random
size
=
10000
probaB
=
0.10
sentSizeCenter
=
20
labels
=
[
"
zero
"
,
"
one
"
,
"
two
"
,
"
three
"
]
def
genSentSize
()
:
return
int
(
abs
(
numpy
.
random
.
normal
(
0.0
,
sentSizeCenter
,
1
)))
+
1
for
filename
in
[
"
train.conllu
"
,
"
dev.conllu
"
,
"
test.conllu
"
]
:
with
open
(
filename
,
"
w
"
)
as
out
:
print
(
"
# global.columns = ID FORM UPOS
"
,
file
=
out
)
totalSize
=
0
sentId
=
0
while
totalSize
<
size
:
sentSize
=
genSentSize
()
totalSize
+=
sentSize
sentId
+=
1
sentence
=
[[
ID
+
1
,
"
a
"
if
random
.
randint
(
0
,
10000
)
>
10000
*
probaB
else
"
b
"
,
len
(
labels
)
-
1
]
for
ID
in
range
(
sentSize
)]
for
i
in
[
i
for
i
in
range
(
len
(
sentence
))]
+
[
i
for
i
in
range
(
len
(
sentence
))][::
-
1
]
:
if
sentence
[
i
][
1
]
==
"
b
"
:
sentence
[
i
][
2
]
=
0
else
:
sentence
[
i
][
2
]
=
min
(
sentence
[
i
-
1
][
2
]
+
1
if
i
>
0
else
len
(
labels
)
-
1
,
len
(
labels
)
-
1
,
sentence
[
i
+
1
][
2
]
+
1
if
i
<
len
(
sentence
)
-
1
else
len
(
labels
)
-
1
)
print
(
"
# sent_id = %d
"
%
sentId
,
file
=
out
)
for
elem
in
sentence
:
elem
[
2
]
=
labels
[
elem
[
2
]]
print
(
"
\t
"
.
join
(
map
(
str
,
elem
)),
file
=
out
)
print
(
""
,
file
=
out
)
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