Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
G
GenVQA
Manage
Activity
Members
Code
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Deploy
Releases
Model registry
Analyze
Contributor 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
Vision
GenVQA
Commits
edb072c0
Commit
edb072c0
authored
8 years ago
by
tgupta6
Browse files
Options
Downloads
Patches
Plain Diff
parse questions and write to json file
parent
f79fea89
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
.gitignore
+3
-1
3 additions, 1 deletion
.gitignore
question_parser/ParseQuestions.class
+0
-0
0 additions, 0 deletions
question_parser/ParseQuestions.class
shapes_dataset/parse_all_questions.py
+59
-0
59 additions, 0 deletions
shapes_dataset/parse_all_questions.py
with
62 additions
and
1 deletion
.gitignore
+
3
−
1
View file @
edb072c0
...
...
@@ -2,4 +2,6 @@
*.pyc
shapes_dataset/images_old
shapes_dataset/images
shapes_dataset/*.json
\ No newline at end of file
shapes_dataset/*.json
shapes_dataset/*.txt
question_parser/stanford-parser-full-2015-12-09/*
\ No newline at end of file
This diff is collapsed.
Click to expand it.
question_parser/ParseQuestions.class
0 → 100644
+
0
−
0
View file @
edb072c0
File added
This diff is collapsed.
Click to expand it.
shapes_dataset/parse_all_questions.py
0 → 100644
+
59
−
0
View file @
edb072c0
import
collections
import
os
import
json
import
sys
import
pdb
if
__name__
==
'
__main__
'
:
anno_json_file
=
sys
.
argv
[
1
]
parsed_q_json_file
=
sys
.
argv
[
2
]
with
open
(
anno_json_file
,
'
r
'
)
as
file
:
anno_data
=
json
.
load
(
file
)
# write questions to a text file
q_txt_file
=
open
(
'
questions.txt
'
,
'
w
'
)
q_id_file
=
open
(
'
question_ids.txt
'
,
'
w
'
)
for
item
in
anno_data
:
# Get rid of last question mark while writing to file
q_txt_file
.
write
(
item
[
'
question
'
][:]
+
'
\n
'
)
q_id_file
.
write
(
str
(
item
[
'
question_id
'
])
+
'
\n
'
)
q_txt_file
.
close
()
q_id_file
.
close
()
os
.
system
(
'
wc -l questions.txt
'
)
os
.
chdir
(
'
../question_parser
'
)
os
.
system
(
"
java -mx1000m -cp
'
.:./stanford-parser-full-2015-12-09/*
'
\
ParseQuestions ./../shapes_dataset/questions.txt >
\
./../shapes_dataset/parsed_questions.txt
"
)
os
.
chdir
(
'
../shapes_dataset
'
)
parsed_q_file
=
open
(
'
parsed_questions.txt
'
,
'
r
'
)
parsed_q_id_file
=
open
(
'
question_ids.txt
'
,
'
r
'
)
parsed_questions
=
parsed_q_file
.
readlines
()
question_ids
=
parsed_q_id_file
.
readlines
()
parsed_q_file
.
close
()
parsed_q_id_file
.
close
()
parsed_q_json_data
=
[]
for
i
,
parsed_q
in
enumerate
(
parsed_questions
):
splitted_line
=
parsed_q
[
2
:
-
2
].
replace
(
'
?
'
,
''
).
split
(
'
|
'
)
parsed_q_json_data
.
append
({
'
question_id
'
:
int
(
question_ids
[
i
][:
-
1
]),
'
question_parse
'
:
{
'
bin0
'
:
splitted_line
[
0
].
rstrip
().
lstrip
().
split
(
'
'
),
'
bin1
'
:
splitted_line
[
1
].
rstrip
().
lstrip
().
split
(
'
'
),
'
bin2
'
:
splitted_line
[
2
].
rstrip
().
lstrip
().
split
(
'
'
),
'
bin3
'
:
splitted_line
[
3
].
rstrip
().
lstrip
().
split
(
'
'
),
}
})
with
open
(
parsed_q_json_file
,
'
w
'
)
as
file
:
json
.
dump
(
parsed_q_json_data
,
file
,
indent
=
4
)
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