-
Notifications
You must be signed in to change notification settings - Fork 43
2269-3 #291
base: master
Are you sure you want to change the base?
2269-3 #291
Conversation
2269/3/helpers/comment_helper.rb
Outdated
request | ||
end | ||
end | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Layout/TrailingBlankLines: 1 trailing blank lines detected.
|
||
def retrieve_comments(path) | ||
article_id = @agent.get(path).css('.news_view_count').last.values[1] | ||
url = "https://comments.api.onliner.by/news/tech.post/#{article_id}/comments?limit=50&_=0.9841189675826583" |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
URL = 'https://comments.api.onliner.by/news/tech.post/%{article_id}/comments?limit=50&_=0.9841189675826583'.freeze
url = URL % { article_id: article_id }
url = "https://comments.api.onliner.by/news/tech.post/#{article_id}/comments?limit=50&_=0.9841189675826583" | ||
response = agent.get(url) | ||
comments = [] | ||
JSON.parse(response.body)['comments'].each { |elem| comments << elem['text'].tr("\n", ' ') } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
JSON.parse(response.body, symbolize_names: true)[:comments].inject([]) { |comment, comments| comments << comment[:text].tr("\n", ' ') }
article_id = @agent.get(path).css('.news_view_count').last.values[1] | ||
url = "https://comments.api.onliner.by/news/tech.post/#{article_id}/comments?limit=50&_=0.9841189675826583" | ||
response = agent.get(url) | ||
comments = [] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inject
response = agent.get(url) | ||
comments = [] | ||
JSON.parse(response.body)['comments'].each { |elem| comments << elem['text'].tr("\n", ' ') } | ||
comments |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
inject
def retrieve_rating(comments) | ||
@data = { documents: [] } | ||
comments.each_with_index do |comment, index| | ||
@data[:documents] << { 'id' => index.to_s, 'language' => 'ru', 'text' => comment } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
{ id: index.to_s, language: 'ru', text: comment }
May you use :ru instead of 'ru' ??
end | ||
|
||
def calculate_rating | ||
url = URI('https://westeurope.api.cognitive.microsoft.com/text/analytics/v2.0/sentiment') |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
constant
<% end %> | ||
</table> | ||
<br> | ||
<div align="center"><a href='/articles/new' class='btn btn-primary'>Add Article</a></div> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
new line?
<br> | ||
<div align="center"><a href='/articles' class='btn btn-primary'>Back</a></div> | ||
<br> | ||
<br> |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
?
Номер
2269
Номер задания
3
Ссылка на видео с демо
https://youtu.be/COpNSShZnDY
Комментарии
Готово