Edward J. Schwartz
commited on
Commit
•
08c3539
1
Parent(s):
de399e6
Add bylibrarydedup
Browse files- oo-method-test-split.py +16 -2
oo-method-test-split.py
CHANGED
@@ -37,6 +37,11 @@ class OOMethodTestDataset(datasets.ArrowBasedBuilder):
|
|
37 |
name="bylibrary",
|
38 |
version=datasets.Version("1.0.0"),
|
39 |
description="Split so that library functions (those appearing in >1 exe) are used for training, and non-library functions are used for testing",
|
|
|
|
|
|
|
|
|
|
|
40 |
)
|
41 |
|
42 |
]
|
@@ -118,7 +123,7 @@ class OOMethodTestDataset(datasets.ArrowBasedBuilder):
|
|
118 |
|
119 |
]
|
120 |
|
121 |
-
elif self.config.name
|
122 |
# A function (name) is a library function if it appears in more than one Exename
|
123 |
|
124 |
# this is (('func', 'oo.exe'): 123)
|
@@ -133,13 +138,22 @@ class OOMethodTestDataset(datasets.ArrowBasedBuilder):
|
|
133 |
grouped = {k: [b for _,b in g] for k, g in grouped}
|
134 |
|
135 |
library_func_names = {f for f, exes in grouped.items() if len(exes) > 1}
|
|
|
136 |
nonlibrary_func_names = {f for f, exes in grouped.items() if len(exes) == 1}
|
137 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
138 |
return [
|
139 |
datasets.SplitGenerator(
|
140 |
name="train",
|
141 |
gen_kwargs={
|
142 |
-
"ds": ds.filter(
|
143 |
},
|
144 |
),
|
145 |
datasets.SplitGenerator(
|
|
|
37 |
name="bylibrary",
|
38 |
version=datasets.Version("1.0.0"),
|
39 |
description="Split so that library functions (those appearing in >1 exe) are used for training, and non-library functions are used for testing",
|
40 |
+
),
|
41 |
+
datasets.BuilderConfig(
|
42 |
+
name="bylibrarydedup",
|
43 |
+
version=datasets.Version("1.0.0"),
|
44 |
+
description="Split so that library functions (those appearing in >1 exe) are used for training, and non-library functions are used for testing. Only one example per function name is retained.",
|
45 |
)
|
46 |
|
47 |
]
|
|
|
123 |
|
124 |
]
|
125 |
|
126 |
+
elif self.config.name in ["bylibrary", "bylibrarydedup"]:
|
127 |
# A function (name) is a library function if it appears in more than one Exename
|
128 |
|
129 |
# this is (('func', 'oo.exe'): 123)
|
|
|
138 |
grouped = {k: [b for _,b in g] for k, g in grouped}
|
139 |
|
140 |
library_func_names = {f for f, exes in grouped.items() if len(exes) > 1}
|
141 |
+
library_func_names_dedup = {(f, exes[0]) for f, exes in grouped.items() if len(exes) > 1}
|
142 |
nonlibrary_func_names = {f for f, exes in grouped.items() if len(exes) == 1}
|
143 |
|
144 |
+
train_filter_fun = None
|
145 |
+
if self.config.name == "bylibrary":
|
146 |
+
train_filter_fun = lambda r: r['Name'] in library_func_names
|
147 |
+
elif self.config.name == "bylibrarydedup":
|
148 |
+
train_filter_fun = lambda r: (r['Name'], r['Exename']) in library_func_names_dedup
|
149 |
+
else:
|
150 |
+
assert False, "Invalid configuration"
|
151 |
+
|
152 |
return [
|
153 |
datasets.SplitGenerator(
|
154 |
name="train",
|
155 |
gen_kwargs={
|
156 |
+
"ds": ds.filter(train_filter_fun),
|
157 |
},
|
158 |
),
|
159 |
datasets.SplitGenerator(
|