class_docstr: LexRank: Graph-based Centrality as Salience in Text Summarization
  Source: http://tangra.si.umich.edu/~radev/lexrank/lexrank.pdf
class_docstr_tok: ["LexRank",":","Graph-based","Centrality","as","Salience","in","Text","Summarization","Source",":","http",":","\/\/tangra.si.umich.edu\/~radev\/lexrank\/lexrank.pdf"]
docstr: We compute idf-modified-cosine(sentence1, sentence2) here.
  It's cosine similarity of these two sentences (vectors) A, B computed as cos(x, y) = A . B / (|A| . |B|)
  Sentences are represented as vector TF*IDF metrics.
  
  :param sentence1:
      Iterable object where every item represents word of 1st sentence.
  :param sentence2:
      Iterable object where every item represents word of 2nd sentence.
  :type tf1: dict
  :param tf1:
      Term frequencies of words from 1st sentence.
  :type tf2: dict
  :param tf2:
      Term frequencies of words from 2nd sentence
  :type idf_metrics: dict
  :param idf_metrics:
      Inverted document metrics of the sentences. Every sentence is treated as document for this algorithm.
  :rtype: float
  :return:
      Returns -1.0 for opposite similarity, 1.0 for the same sentence and zero for no similarity between sentences.
docstr_tok: ["We","compute","idf-modified-cosine","(","sentence1",",","sentence2",")","here",".","It","'s","cosine","similarity","of","these","two","sentences","(","vectors",")","A",",","B","computed","as","cos","(","x",",","y",")","=","A",".","B","\/","(","|A|",".","|B|",")","Sentences","are","represented","as","vector","TF","*","IDF","metrics",".",":","param","sentence1",":","Iterable","object","where","every","item","represents","word","of","1st","sentence",".",":","param","sentence2",":","Iterable","object","where","every","item","represents","word","of","2nd","sentence",".",":","type","tf1",":","dict",":","param","tf1",":","Term","frequencies","of","words","from","1st","sentence",".",":","type","tf2",":","dict",":","param","tf2",":","Term","frequencies","of","words","from","2nd","sentence",":","type","idf_metrics",":","dict",":","param","idf_metrics",":","Inverted","document","metrics","of","the","sentences",".","Every","sentence","is","treated","as","document","for","this","algorithm",".",":","rtype",":","float",":","return",":","Returns","-1.0","for","opposite","similarity",",","1.0","for","the","same","sentence","and","zero","for","no","similarity","between","sentences","."]
code: def cosine_similarity(sentence1, sentence2, tf1, tf2, idf_metrics):
      """
      We compute idf-modified-cosine(sentence1, sentence2) here.
      It's cosine similarity of these two sentences (vectors) A, B computed as cos(x, y) = A . B / (|A| . |B|)
      Sentences are represented as vector TF*IDF metrics.
  
      :param sentence1:
          Iterable object where every item represents word of 1st sentence.
      :param sentence2:
          Iterable object where every item represents word of 2nd sentence.
      :type tf1: dict
      :param tf1:
          Term frequencies of words from 1st sentence.
      :type tf2: dict
      :param tf2:
          Term frequencies of words from 2nd sentence
      :type idf_metrics: dict
      :param idf_metrics:
          Inverted document metrics of the sentences. Every sentence is treated as document for this algorithm.
      :rtype: float
      :return:
          Returns -1.0 for opposite similarity, 1.0 for the same sentence and zero for no similarity between sentences.
      """
      unique_words1 = frozenset(sentence1)
      unique_words2 = frozenset(sentence2)
      common_words = unique_words1 & unique_words2
  
      numerator = 0.0
      for term in common_words:
          numerator += tf1[term] * tf2[term] * idf_metrics[term] ** 2
  
      denominator1 = sum(
          (tf1[t] * idf_metrics[t]) ** 2 for t in unique_words1
      )
      denominator2 = sum(
          (tf2[t] * idf_metrics[t]) ** 2 for t in unique_words2
      )
  
      if denominator1 > 0 and denominator2 > 0:
          return numerator / (
              math.sqrt(denominator1) * math.sqrt(denominator2)
          )
      else:
          return 0.0
  
file_path: sumy/sumy/summarizers/lex_rank.py
imports: from __future__ import absolute_import
  from __future__ import division, print_function, unicode_literals
  import math
  from collections import Counter
  from ._summarizer import AbstractSummarizer
label_desc: Use image node_id 10 for calling the LexRankSummarizer obj's underlying member method code with example usage: obj.cosine_similarity(sentence1, sentence2, tf1, tf2, idf_metrics) and returns: unknown, int