fixed bug in simil info

pull/202/head
ggrieco-tob 6 years ago
parent 0158705616
commit 92a0ca0e22
  1. 11
      utils/similarity/info.py

@ -1,5 +1,6 @@
import logging import logging
import sys import sys
import os.path
import traceback import traceback
from fastText import load_model from fastText import load_model
@ -11,8 +12,13 @@ logger = logging.getLogger("Slither-simil")
def info(args): def info(args):
try: try:
model = args.model model = args.model
if os.path.isfile(model):
model = load_model(model) model = load_model(model)
else:
model = None
filename = args.filename filename = args.filename
contract = args.contract contract = args.contract
solc = args.solc solc = args.solc
@ -31,12 +37,13 @@ def info(args):
if len(irs) == 0: if len(irs) == 0:
sys.exit(-1) sys.exit(-1)
x = "-".join([filename,contract,fname]) x = (filename,contract,fname)
y = " ".join(irs[x]) y = " ".join(irs[x])
fvector = model.get_sentence_vector(y)
print("Function {} in contract {} is encoded as:".format(fname, contract)) print("Function {} in contract {} is encoded as:".format(fname, contract))
print(y) print(y)
if model is not None:
fvector = model.get_sentence_vector(y)
print(fvector) print(fvector)
except Exception: except Exception:

Loading…
Cancel
Save