다른 소스에서이 코드를 재활용하려고하는데 두 번째 줄에 for
루프를 이해하는 데 문제가 있습니다. 누군가 정확히이 줄이 무엇인지 명확히 할 수 있습니까 title = [x for x in title if x not in stopWords]
은 무엇을하고 있습니까? stopWords
은 단어 목록입니다.다른 사람이이 코드를 파이썬에서 이해하도록 도울 수 있습니까?
def title_score(title, sentence):
title = [x for x in title if x not in stopWords]
count = 0.0
for word in sentence:
if (word not in stopWords and word in title):
count += 1.0
if len(title) == 0:
return 0.0
return count/len(title)