code: def sort_words(vertex_source, edge_source, window=2, pagerank_config={'alpha': 0.85, }):
      
      sorted_words = []
      word_index = {}
      index_word = {}
      _vertex_source = vertex_source
      _edge_source = edge_source
      words_number = 0
      for word_list in _vertex_source:
          for word in word_list:
              if not word in word_index:
                  word_index[word] = words_number
                  index_word[words_number] = word
                  words_number += 1
  
      graph = np.zeros((words_number, words_number))
  
      for word_list in _edge_source:
          for w1, w2 in combine(word_list, window):
              if w1 in word_index and w2 in word_index:
                  index1 = word_index[w1]
                  index2 = word_index[w2]
                  graph[index1][index2] = 1.0
                  graph[index2][index1] = 1.0
  
      nx_graph = nx.from_numpy_matrix(graph)
      scores = nx.pagerank(nx_graph, **pagerank_config)
      sorted_scores = sorted(scores.items(), key=lambda item: item[1], reverse=True)
      for index, score in sorted_scores:
          item = AttrDict(word=index_word[index], weight=score)
          sorted_words.append(item)
  
      return sorted_words
docs: 将单词按关键程度从大到小排序
  
      Keyword arguments:
      vertex_source   --  二维列表，子列表代表句子，子列表的元素是单词，这些单词用来构造pagerank中的节点
      edge_source     --  二维列表，子列表代表句子，子列表的元素是单词，根据单词位置关系构造pagerank中的边
      window          --  一个句子中相邻的window个单词，两两之间认为有边
      pagerank_config --  pagerank的设置