我正在编写一个程序,该程序可以分析在线评论并根据其评分对其进行分类。评论存储在列表afterTextChanged(Editable s)
中,相应的评分存储在列表review_text
中为肯定(4& 5星)或负数(1、2和3星)。
尝试以下代码来添加每个评论的评论文本和评论标签信息,然后附加它,但没有成功。
review_label
我尝试了以下代码,但收到错误:
#Program starts here restaurant_urls=[] bar_urls=[] for i in restaurant_links: restaurant_urls.append('http://xxx/yyy/zzz/'+i) print('http://xxx/yyy/zzz/'+i) url_text=[] review_text = [] review_label = [] pd.DataFrame({"review_text": review_text, "review_label": review_label}) for j in restaurant_urls: print(j) html = requests.get(j).text article_soup = BeautifulSoup(html, "lxml") #url_text.append(article_soup) #print(url_text) for reviews in article_soup.find_all('div','review'): try: star_text = reviews.find('img').get('alt') if star_text in ['1-star','2-star','3-star']: review_label.append('Negative') elif star_text in ['4-star','5-star']: review_label.append('Positive') else: print('check') review_text.append(reviews.find('p','text').get_text())
预期输出的示例是:
File "<ipython-input-164-f1f62c16f272>", line 38
^
SyntaxError: unexpected EOF while parsingSyntaxError: unexpected EOF while parsing