constructor()

in src/models/SentenTreeModel.js [189:238]


  constructor(tokenizedData, options = {}) {
    // extract options
    const {
      termWeights = {},
      // minimum support is the max of
      // minSupportCount
      // and size * minSupportRatio
      minSupportCount = 2,
      minSupportRatio = 0.001,
      maxSupportRatio = 0.75,
    } = options;

    this.options = options;

    const { itemset, entries } = tokenizedData;
    this.tokenizedData = tokenizedData;
    this.terms = tokenizedData.encodeTermWeights(termWeights);
    const size = tokenizedData.computeSize();

    this.supportRange = [
      Math.max(size * minSupportRatio, minSupportCount),
      size * maxSupportRatio,
    ];
    const [minSupport, maxSupport] = this.supportRange;

    this.rootSeq = {
      words: [],
      newWord: null,
      graph: null,
      size,
      DBs: entries,
    };

    const graphs = [];
    const visibleGroups = expandSeqTree(
      this.rootSeq,
      graphs,
      DEFAULT_NODE_COUNT,
      minSupport,
      maxSupport,
      this.terms,
      itemset
    );

    this.graphs = graphs
      .filter(g => g.nodes.length > 2)
      .slice(0, 10);

    updateNodesEdges(this.graphs, visibleGroups);
  }