def read_data(source):
"""
Reads the sentence data from the csv file, which is of the form (sentence, is_summary_sentence).
Args:
source = the data file to read the data from
Returns:
A list of tuples where each tuple is of the form (sentence, is_summary_sentence).
"""
sentences = []
count = 0
with open(source, "r") as csvfile:
reader = csv.reader(csvfile)
for row in reader:
sentence = row[0]
sentence = sentence.strip("\"")
sentence = sentence.strip("[")
sentence = sentence.strip("]")
sentence = sentence.replace("'", "")
sentence = sentence.replace(" ", "")
sentence = sentence.split(",")
sentences.append(sentence)
count += 1
return sentences
# ============================================
# ================ MAIN PROGRAM ==============
# Read in all of the papers into a list of lists. Each item in the list is a sentence, in the form of a list of words.
paper_word2vec.py 文件源码
python
阅读 22
收藏 0
点赞 0
评论 0
评论列表
文章目录