Edward J. Schwartz commited on
Commit
c164530
1 Parent(s): df293aa

Add bylibrarydedupall

Browse files
Files changed (1) hide show
  1. oo-method-test-split.py +16 -3
oo-method-test-split.py CHANGED
@@ -41,9 +41,15 @@ class OOMethodTestDataset(datasets.ArrowBasedBuilder):
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
  ]
48
 
49
  def __init__(self, *args, **kwargs):
@@ -123,11 +129,11 @@ class OOMethodTestDataset(datasets.ArrowBasedBuilder):
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)
130
- testcount = set(zip(ds['Name'], ds['Exename']))
131
 
132
  # sorted pairs by function name
133
  testcount = sorted(testcount, key=lambda x: x[0])
@@ -138,7 +144,12 @@ class OOMethodTestDataset(datasets.ArrowBasedBuilder):
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
@@ -146,6 +157,8 @@ class OOMethodTestDataset(datasets.ArrowBasedBuilder):
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
 
 
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 per program.",
45
+ ),
46
+ datasets.BuilderConfig(
47
+ name="bylibrarydedupall",
48
+ version=datasets.Version("1.0.0"),
49
  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.",
50
  )
51
 
52
+
53
  ]
54
 
55
  def __init__(self, *args, **kwargs):
 
129
 
130
  ]
131
 
132
+ elif self.config.name in ["bylibrary", "bylibrarydedup", "bylibrarydedupall"]:
133
  # A function (name) is a library function if it appears in more than one Exename
134
 
135
  # this is (('func', 'oo.exe'): 123)
136
+ testcount = set(zip(ds['Name'], zip(ds['Binary'], ds['Exename'])))
137
 
138
  # sorted pairs by function name
139
  testcount = sorted(testcount, key=lambda x: x[0])
 
144
  grouped = {k: [b for _,b in g] for k, g in grouped}
145
 
146
  library_func_names = {f for f, exes in grouped.items() if len(exes) > 1}
147
+ # Exename
148
+ # v
149
+ library_func_names_dedup = {(f, exes[0][1]) for f, exes in grouped.items() if len(exes) > 1}
150
+ # Binary
151
+ # v
152
+ library_func_names_dedup_all = {(f, exes[0][0]) for f, exes in grouped.items() if len(exes) > 1}
153
  nonlibrary_func_names = {f for f, exes in grouped.items() if len(exes) == 1}
154
 
155
  train_filter_fun = None
 
157
  train_filter_fun = lambda r: r['Name'] in library_func_names
158
  elif self.config.name == "bylibrarydedup":
159
  train_filter_fun = lambda r: (r['Name'], r['Exename']) in library_func_names_dedup
160
+ elif self.config.name == "bylibrarydedupall":
161
+ train_filter_fun = lambda r: (r['Name'], r['Binary']) in library_func_names_dedup_all
162
  else:
163
  assert False, "Invalid configuration"
164