pull/202/head
ggrieco-tob 6 years ago
parent ee706bf5a9
commit 802ab4edb2
  1. 3
      utils/similarity/encode.py
  2. 6
      utils/similarity/info.py
  3. 2
      utils/similarity/plot.py

@ -22,6 +22,9 @@ slither_logger = logging.getLogger("Slither")
slither_logger.setLevel(logging.CRITICAL) slither_logger.setLevel(logging.CRITICAL)
def parse_target(target): def parse_target(target):
if target is None:
return None, None
parts = target.split('.') parts = target.split('.')
if len(parts) == 1: if len(parts) == 1:
return None, parts[0] return None, parts[0]

@ -40,11 +40,11 @@ def info(args):
x = (filename,contract,fname) x = (filename,contract,fname)
y = " ".join(irs[x]) y = " ".join(irs[x])
print("Function {} in contract {} is encoded as:".format(fname, contract)) logger.info("Function {} in contract {} is encoded as:".format(fname, contract))
print(y) logger.info(y)
if model is not None: if model is not None:
fvector = model.get_sentence_vector(y) fvector = model.get_sentence_vector(y)
print(fvector) logger.info(fvector)
except Exception: except Exception:
logger.error('Error in %s' % args.filename) logger.error('Error in %s' % args.filename)

@ -61,7 +61,7 @@ def plot(args):
tdata = pca.fit_transform(data) tdata = pca.fit_transform(data)
logger.info('Plotting data..') logger.info('Plotting data..')
plt.figure() plt.figure(figsize=(20,10))
assert(len(tdata) == len(fs)) assert(len(tdata) == len(fs))
for ([x,y],l) in zip(tdata, fs): for ([x,y],l) in zip(tdata, fs):
x = random.gauss(0, 0.01) + x x = random.gauss(0, 0.01) + x

Loading…
Cancel
Save