MCPcopy Create free account
hub / github.com/PKU-ASAL/Simulated-Data / extract_process_vec

Function extract_process_vec

src/Sysdig/caculate-weight.py:104–163  ·  view source on GitHub ↗
(file_path,tfidf, w2v, c2v)

Source from the content-addressed store, hash-verified

102# return process_vec
103
104def extract_process_vec(file_path,tfidf, w2v, c2v):
105 process_map = {}
106 f = open(file_path,'r')
107 print('start graph')
108 process_vec = defaultdict(list)
109 id = 0
110 mean_s = np.mean(list(tfidf.values()))
111 max_s = np.max(list(tfidf.values()))
112 isprocess_file = True
113 tmp_process_vec = []
114 ground_truth = {}
115 new_cmd = ''
116 while True:
117 line = f.readline()
118 if line == '\n':
119 process_vec[new_cmd].append(np.mean(tmp_process_vec,axis=0).tolist())
120 id += 1
121 tmp_process_vec = []
122 isprocess_file = True
123 continue
124 if not line:
125 break
126
127 filepath = line.strip().lower()
128 if filepath.endswith('$$$true'):
129 filepath = filepath.replace('$$$true','')
130 ground_truth[id] = filepath
131 else:
132 filepath = filepath.replace('$$$false','')
133 split_path = sanitize_string(filepath)
134 if len(split_path) == 0:
135 continue
136 if isprocess_file:
137 # print(id)
138 # print(filepath)
139 # print(split_path)
140 new_cmd = '/'.join(split_path)
141 process_map[id] = new_cmd
142 isprocess_file = False
143 tmp = []
144 for l,i in enumerate(split_path):
145 tmp += [c2v.wv[i]]
146 r = np.mean(tmp,axis=0)
147 # if not (process_map[id] in stability):
148 r = r * mean_s
149
150 else:
151 tmp = []
152 for l,i in enumerate(split_path):
153 tmp += [w2v.wv[i]]
154 r = np.mean(tmp,axis=0)
155 newname = '/'.join(split_path)
156 if newname in tfidf:
157 s = tfidf[newname]
158 else:
159 s = mean_s
160 r = r * s
161

Callers 1

caculate-weight.pyFile · 0.70

Calls 1

sanitize_stringFunction · 0.90

Tested by

no test coverage detected