Skip to content
GitLab
Menu
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Mateusz Pawlik
ted-datasets
Commits
3a6c0e07
Commit
3a6c0e07
authored
Jun 14, 2018
by
Thomas Huetter
Browse files
fixed bugs in python asts; still not working
parent
4c05cc9d
Changes
2
Show whitespace changes
Inline
Side-by-side
python_ast/parse_json.py
View file @
3a6c0e07
...
...
@@ -14,7 +14,7 @@ import json
def
print_tree
(
json_tree
,
index
):
print
(
'{'
+
json_tree
[
index
][
'type'
],
end
=
''
)
if
'value'
in
json_tree
[
index
]:
print
(
'{'
+
json_tree
[
index
][
'value'
].
replace
(
'
\r
'
,
''
).
replace
(
'
\n
'
,
''
).
strip
().
translate
(
str
.
maketrans
({
"{"
:
r
"\{"
,
print
(
'{'
+
json_tree
[
index
][
'value'
].
replace
(
'
\r
'
,
''
).
replace
(
'
\n
'
,
''
).
replace
(
'
\t
'
,
''
).
strip
().
translate
(
str
.
maketrans
({
"{"
:
r
"\{"
,
"}"
:
r
"\}"
,
"
\\
"
:
r
"\\"
}))
+
'}'
,
end
=
''
)
...
...
python_ast/sort_dataset.sh
View file @
3a6c0e07
#!/bin/bash
# | sort by number of nodes (equivalent to number of "{")
cat
$1
|
awk
'
{
print
gsub("{","{"), $0}
'
|
sort
-n
|
cut
-d
' '
-f2-
>
"
${
1
%.bracket
}
_sorted.bracket"
# | sort by number of nodes (equivalent to number of "{")
, remove duplicates
cat
$1
|
perl
-F
{
-lane
'print
"$#F $_"
'
|
sort
-n
|
cut
-d
' '
-f2-
>
"
${
1
%.bracket
}
_sorted.bracket"
Write
Preview
Supports
Markdown
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