у меня какая-то ошибка в питоне, проблема в ключевой ошибке - PullRequest
0 голосов
/ 01 февраля 2019
def get_sent_score(TFISF_scores, text_sents, doc_info):
    """
    This function prints out the summary and return the score of arch sentence in a list.

    the score of a sentence is calculated by adding the TFIDF scores of the words that make up sentence.
    """
    sentence_info=[]
    for doc in doc_info:
        """
        This loops through each document (sentence) and calculate their 'sent_score'
        """
        sent_score=0
        for i in range (0, len(TFISF_scores)):
            temp_dict = TFISF_scores[i]
            if doc ['doc_id']==temp_dict['doc_id']:
                sent_score += temp_dict['TFISF_score']
                temp={'doc_id':doc['doc_id'],
                      'sent_score':sent_score,
                      'sentence':text_sents[doc['doc_id']-1]}
                sentence_info.append(temp)
    return sentence_info
sentence_info = get_sent_score(TFISF_scores, text_sents, doc_info)
print(sentence_info)

Копировать комментарий: сообщение об ошибке

sent_score += temp_dict['TFISF_score'] KeyError: 'TFISF_score' 
Добро пожаловать на сайт PullRequest, где вы можете задавать вопросы и получать ответы от других членов сообщества.
...