Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 14 additions & 1 deletion dataset_builder/humaneval_to_pl.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,20 @@ def deep_equality(self, left: str, right: str) -> str:
== is the wrong operator for Java and OCaml.
"""
arr_prefix = f" " + " ".join(array_list)
if right == "0+0":
return (
arr_prefix
+ f" my $got = {left};\n"
+ " if(!$got) "
+ "{\n print \"ok!\" }else{\n exit 1;\n }"
)
return arr_prefix+f" if(eq_deeply({left},{right})) "+"{\n print \"ok!\" }else{\n exit 1;\n }"
return (
arr_prefix
+ f" my $got = {left};\n"
+ f" if({condition}) "
+ "{\n print \"ok!\" }else{\n exit 1;\n }"
)

def gen_literal(self, c: bool | str | int | float):
"""Translate a literal expression
Expand All @@ -55,7 +68,7 @@ def gen_literal(self, c: bool | str | int | float):
if c is True:
return 1
elif c is False:
return "\"\""
return "0+0"
elif type(c) == str:
return f'"{c}"'
elif c is None:
Expand Down