(file_path,tfidf, w2v, c2v)
| 30 | from argparse import ArgumentParser |
| 31 | |
| 32 | def extract_process_feature(file_path,tfidf, w2v, c2v): |
| 33 | process_map = {} |
| 34 | f = open(file_path,'r') |
| 35 | print('start graph') |
| 36 | process_vec = defaultdict(list) |
| 37 | id = 0 |
| 38 | mean_s = np.mean(list(tfidf.values())) |
| 39 | max_s = np.max(list(tfidf.values())) |
| 40 | isprocess_file = True |
| 41 | tmp_process_vec = [] |
| 42 | cmdline_vec = np.array([]) |
| 43 | ground_truth = {} |
| 44 | while True: |
| 45 | line = f.readline() |
| 46 | if id == 543: |
| 47 | print(line) |
| 48 | if line == '\n': |
| 49 | process_vec[id] = np.mean(tmp_process_vec,axis=0).tolist() |
| 50 | id += 1 |
| 51 | tmp_process_vec = [] |
| 52 | cmdline_vec = [] |
| 53 | isprocess_file = True |
| 54 | continue |
| 55 | if not line: |
| 56 | break |
| 57 | filepath = line.strip().lower() |
| 58 | if filepath.endswith('$$$true'): |
| 59 | filepath = filepath.replace('$$$true','') |
| 60 | ground_truth[id] = filepath |
| 61 | else: |
| 62 | filepath = filepath.replace('$$$false','') |
| 63 | |
| 64 | split_path = sanitize_string(filepath) |
| 65 | if len(split_path) == 0: |
| 66 | continue |
| 67 | if isprocess_file: |
| 68 | if len(split_path) == 0: |
| 69 | process_map[id] = 'None' |
| 70 | else: |
| 71 | process_map[id] = '/'.join(split_path) |
| 72 | isprocess_file = False |
| 73 | tmp = [] |
| 74 | for l,i in enumerate(split_path): |
| 75 | tmp += [c2v.wv[i]] |
| 76 | r = np.mean(tmp,axis=0) |
| 77 | r = r * mean_s |
| 78 | else: |
| 79 | tmp = [] |
| 80 | for l,i in enumerate(split_path): |
| 81 | tmp += [w2v.wv[i]] |
| 82 | r = np.mean(tmp,axis=0) |
| 83 | newname = '/'.join(split_path) |
| 84 | if newname in tfidf: |
| 85 | s = tfidf[newname] |
| 86 | else: |
| 87 | s = mean_s |
| 88 | r = r * s |
| 89 |
no test coverage detected