-
Notifications
You must be signed in to change notification settings - Fork 43
2294-2 #261
base: master
Are you sure you want to change the base?
2294-2 #261
Conversation
2294/2/top_bad_battlers.rb
Outdated
puts table | ||
end | ||
|
||
def bad_words_searching(text) |
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.
UtilityFunction: TopBattlers#bad_words_searching doesn't depend on instance state (maybe move it to another class?). More info.
2294/2/pluralize.rb
Outdated
@@ -0,0 +1,7 @@ | |||
def pluralize(count, words) |
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.
UtilityFunction: pluralize doesn't depend on instance state (maybe move it to another class?). More info.
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.
remove this file
2294/2/functional.rb
Outdated
words.last | ||
end | ||
|
||
def row |
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.
Metrics/AbcSize: Assignment Branch Condition size for row is too high. [18/15]
2294/2/functional.rb
Outdated
words.size / rounds | ||
end | ||
|
||
def pluralize(count, words) |
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.
UtilityFunction: Analyze#pluralize doesn't depend on instance state (maybe move it to another class?). More info.
2294/2/functional.rb
Outdated
# Analyze text of current artist | ||
|
||
class Analyze | ||
WORD_SETTING = [%w[слово слова слов], %w[нецензурное нецензурных нецензурных], %w[батл батла батлов]].freeze |
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.
move to yml.
2294/2/functional.rb
Outdated
end | ||
|
||
def rounds | ||
battles_count * 3 |
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.
magic number
2294/2/pluralize.rb
Outdated
@@ -0,0 +1,7 @@ | |||
def pluralize(count, words) |
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.
remove this file
2294/2/top_bad_battlers.rb
Outdated
|
||
def bad_words_searching(text) | ||
count = 0 | ||
RussianObscenity.find(text).each do |bad| |
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
2294/2/top_words.rb
Outdated
|
||
def clean_text(name) | ||
@hash[name].join(' ').split(' ').delete_if do |word| | ||
word.length <= 2 || JUNK_WORDS.include?(word) |
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.
magic number
2294/2/top_battlers.rb
Outdated
|
||
private | ||
|
||
|
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/EmptyLines: Extra blank line detected.
2294/2/top_battlers.rb
Outdated
@rapers = FileParser.new.read_files | ||
@result = [] | ||
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/TrailingWhitespace: Trailing whitespace detected.
why it doesn't match the task requirements? |
2294/2/top_battlers.rb
Outdated
|
||
RussianObscenity.dictionary = [:default, 'dictionary.yml'] | ||
# Form the table of top battlers with the biggest count of foul words | ||
# :reek:UtilityFunction |
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.
why the whole class?
2294/2/analyze.rb
Outdated
end | ||
|
||
def row | ||
[column_one, column_two, column_three, column_four, column_five] |
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.
strange naming...
2294/2/analyze.rb
Outdated
RussianObscenity.dictionary = [:default, 'dictionary.yml'] | ||
|
||
# Analyze text of current artist | ||
# :reek:UtilityFunction |
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.
remove this.
2294/2/analyze.rb
Outdated
|
||
def bad_count | ||
count = 0 | ||
RussianObscenity.find(text).each do |bad| |
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.
try inject
2294/2/analyze.rb
Outdated
end | ||
|
||
def column_three | ||
"#{bad_count} #{pluralize(bad_count, WORD_SETTING['two'])} #{pluralize(bad_count, WORD_SETTING['one'])}" |
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.
these one/two/three - are unreadable
2294/2/top_battlers.rb
Outdated
def sort_list | ||
@rapers.sort_by do |_key, value| | ||
bad_words_searching(value.join(' ')) | ||
end.reverse |
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.
reverse! is faster.
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.
daee490
to
25a8d8c
Compare
2294/2/top_words.rb
Outdated
|
||
def warning_about_wrong_name(name) | ||
return if @hash.key?(name) | ||
rapers_exampels = @hash.keys.sample |
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.
typo, please avoid typos in variable/method names - use spellcheckers
2294/2/top_words.rb
Outdated
end | ||
|
||
def clean_text(name) | ||
@hash[name].join(' ').split(' ').delete_if do |word| |
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.
what is the sense to join and then split back?
2294/2/app.rb
Outdated
require_relative './top_battlers.rb' | ||
require_relative './top_words.rb' | ||
require_relative './parameters_parser.rb' | ||
|
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.
why do you need this file? I thought that we agreed that it could be removed.
2294/2/file_parser.rb
Outdated
end | ||
|
||
def parse(file) | ||
File.open("./rap-battles/#{file}") do |file_name| |
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.
you can put your folder name to constant
2294/2/analyze.rb
Outdated
battles_count * DEFAULT_BATTLES | ||
end | ||
|
||
def bad_count |
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.
you should read about memoization: http://gavinmiller.io/2013/basics-of-ruby-memoization/
2294/2/file_parser.rb
Outdated
@name = file.split(/против|aka|vs\b/i).first.strip | ||
parse(file) | ||
end | ||
@rapers |
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.
this return is really unexpected
2294/2/top_battlers.rb
Outdated
|
||
def sort_list | ||
@rapers.sort_by do |_key, value| | ||
@text = value.join(' ') |
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.
avoid using instance variables for such cases, were you need just pass reek.
2294/2/file_parser.rb
Outdated
end | ||
end | ||
|
||
def read_files |
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.
leave only this method as public
Номер
2294
Номер задания
2
Ссылка на видео с демо
https://youtu.be/tfh_3mSzRe8
Комментарии
Переписал "простыню"