# -*- coding: utf-8 -*-

from WordImportanceGenerator import max_idf_key
from logging import getLogger, StreamHandler, DEBUG
logger = getLogger(__name__)
handler = StreamHandler()
handler.setLevel(DEBUG)
logger.setLevel(DEBUG)
logger.addHandler(handler)

max_idf_param = 1.0

"""
The function calculate sentence importance with idf.
input : words list,idf map

Ex 
idf map = {
            "天気",0.7,
            "晴れ",0.3,
            :
            }

output:
    score

"""


def calculate_importance_score(words, idf_map):
    score = 0
    for word in words:
        if idf_map.has_key (word):
            score += float (idf_map[word])
        else:
            logger.warning("word(" + word + ") is not in the statistics data.")
            score += float (idf_map[max_idf_key]) * max_idf_param

    return score
