コード例 #1
0
 def get_state_probs(self):
     """
     Returns the join probability of all next-calls and the number of
     probabilities counted.
     """
     js_events = sal.get_calls(seq=self.js)
     app = self.parent()
     for row in app.distribution_state_iter(self.spec, js_events, cache=app.cache):
         yield app.dist_adapter(row)
コード例 #2
0
def get_term_frequency(doc, nprocs, min_seq_len=1):
    result = State()
    with common.finish(
            concurrent.futures.ThreadPoolExecutor(max_workers=nprocs),
            accumulator=result) as executor:
        for pkg in sal.get_packages(doc=doc):
            for seq in sal.get_sequences(pkg=pkg):
                if len(sal.get_calls(seq=seq)) >= min_seq_len:
                    executor.submit(seq_term_frequency, seq)
    return result.get()
コード例 #3
0
 def filter_anomalies(self, seq):
     calls = sal.get_calls(seq=seq)
     for evt, call in zip(calls, get_state_probs(self.app, self.spec, calls)):
         for idx, st in get_anomalous_states(call, self.threshold):
             if not self.accept_state(st):
                 continue
             loc = sal.get_call_location(evt)
             cid = (loc, call.name, idx)
             if cid in self.visited:
                 continue
             self.visited.add(cid)
             yield loc, call.name, idx, st.name
コード例 #4
0
def seq_term_frequency(seq):
    c = Counter()
    for call in sal.get_calls(seq=seq):
        c[call['call']] += 1
    return c
コード例 #5
0
 def call_dist(self):
     js_events = sal.get_calls(seq=self.js)
     app = self.parent()
     return app.distribution_call_iter(self.spec,
                                       js_events,
                                       cache=app.cache)