UNPKG

@eagleoutice/flowr

Version:

Static Dataflow Analyzer and Program Slicer for the R Programming Language

27 lines (26 loc) 1.69 kB
import { DefaultMap } from '../../../util/defaultmap'; import type { MergeableRecord } from '../../../util/objects'; import type { NodeId } from '../../../r-bridge/lang-4.x/ast/model/processing/node-id'; export type ContextsWithCount = DefaultMap<NodeId, number>; export type ClusterContextIdMap = DefaultMap<string | undefined, NodeId>; export type ClusterValueInfoMap = DefaultMap<string, ContextsWithCount>; /** Produced by {@link clusterStatisticsOutput} */ export interface ClusterReport extends MergeableRecord { /** The input file which has been clustered */ readonly filepath: string; /** Maps each context encountered (i.e., every file that contains something associated with the feature) to a unique id, used in the {@link ClusterReport#valueInfoMap|valueInfoMap}. */ contextIdMap: ClusterContextIdMap; /** * Counts which contexts contained which values of a feature. * For example, that `<-` occurred in files with ids `[12, 42, 19, 19]` (i.e., the context with the id 19 contained it twice). */ valueInfoMap: ClusterValueInfoMap; } /** * Takes a statistics file like `statistics-out/top-2023-01-01-00-00-00/Assignments/assignmentOperator.txt` and clusters the values by context * * @param filepath - Filepath of the statistics file * @param contextIdMap - The id map to use, can use an existing one to reuse ids for same contexts spreading over multiple input files. * `undefined` is used for unknown contexts. This map allows us to reference contexts with a way shorter identifier (vs. the full file path). */ export declare function clusterStatisticsOutput(filepath: string, contextIdMap?: ClusterContextIdMap): ClusterReport;