code: def _get_windows(content_lst: list, window_size: int):
      r"""
      滑动窗口处理文本，获取词频和共现词语的词频
      :param content_lst:
      :param window_size:
      :return: 词频，共现词频，窗口化后文本段的数量
      """
      word_window_freq = defaultdict(int)  # w(i)  单词在窗口单位内出现的次数
      word_pair_count = defaultdict(int)  # w(i, j)
      windows_len = 0
      task_id = f_rich_progress.add_task(
          description="Split by window", total=len(content_lst)
      )
      for words in content_lst:
          windows = list()
  
          if isinstance(words, str):
              words = words.split()
          length = len(words)
  
          if length <= window_size:
              windows.append(words)
          else:
              for j in range(length - window_size + 1):
                  window = words[j : j + window_size]
                  windows.append(list(set(window)))
  
          for window in windows:
              for word in window:
                  word_window_freq[word] += 1
  
              for word_pair in itertools.combinations(window, 2):
                  word_pair_count[word_pair] += 1
  
          windows_len += len(windows)
  
          f_rich_progress.update(task_id, advance=1)
      f_rich_progress.destroy_task(task_id)
      return word_window_freq, word_pair_count, windows_len
  
imports: from collections import defaultdict
  import itertools
  import math
  import numpy
  from ..data_bundle import DataBundle
  from ..loader.classification import MRLoader, OhsumedLoader, R52Loader, R8Loader, NG20Loader
  from fastNLP.core.utils import f_rich_progress
label_desc: Use image node_id 1 for calling a global function with example usage: _get_windows(content_lst, window_size) and returns: word_window_freq,  word_pair_count,  windows_len