coOccurenceGraph method

Map<String, List<int>> coOccurenceGraph(
  1. List<String> terms
)

Builds a co-occurrency graph for the ordered list of terms from the elements (keywords) of the collection.

Implementation

Map<String, List<int>> coOccurenceGraph(List<String> terms) {
  final Map<String, List<int>> retVal = {};
  for (final rowKey in terms) {
    final row = List<int>.filled(terms.length, 0);
    var x = 0;
    for (final term in terms) {
      final tF = where(
              (element) => element.contains(rowKey) && element.contains(term))
          .length;
      row[x] = tF;
      x++;
    }
    retVal[rowKey] = row;
  }

  return retVal;
}