-
Notifications
You must be signed in to change notification settings - Fork 9
rorybot warning analytics test script [WIP] #17
Conversation
df74327
to
04fc49b
Compare
04fc49b
to
163d013
Compare
frequency = Hash.new(0) | ||
|
||
puts "Counting warning messages" | ||
input_file.read.scan(warning_message) 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.
input_file.read.scan(warning_message).map { |w| frequency[w] + 1 }
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.
Cool!
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.
I can't get this to add to frequency (even taking out read
). If I try to print frequency it gives me {}
If I put it back to
input_file.scan(warning_message) do |word|
frequency[word] = frequency[word] + 1
it does work, however.
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.
Ah, I think I misread this. That said, frequency[word] = frequency[word] + 1
should work as frequency[word] += 1
|
||
input_file = File.open('rorybot_output.txt', 'r') | ||
output_file = File.open('frequency.csv', 'w+') | ||
warning_message = /(?:warning\s{2,}?)(.+?)(?=\s{2,})/ |
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 is a pretty nasty regex, what is it intending to match? I dont really wanna take the time to figure it out lol
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.
Ha, yeah, there's got to be a better way. I'm trying to match this:
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.
^.*warning (.*)$
^
denotes the beginning of the line..*
matches everything up towarning
warning
matcheswarning
\s+
)(.*)$
creates a capture group for the rest of the line because$
means "end of line"
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.
Got it. Waaaaaay cleaner. I don't know what I was thinking.
Looks like my comments got suppressed. Can you go through all the outdated ones and comment on them? |
Will do!
|
@jules2689 I'm running into an error now on my most recent commit, on line 26: input_file.scan(warning_message).map { |w| frequency[w] + 1 } Any ideas? |
Regarding my error above, I did change your suggestion to - input_file.read.scan(warning_message).map { |w| frequency[w] + 1 }
+ input_file.scan(warning_message).map { |w| frequency[w] + 1 } because of the suggestion to change |
Okay, so
TIL. Change the |
e0af82e
to
ad4d7c3
Compare
No longer required. |
At the moment this script asks you what file type you want to analyze, recursively runs Rorybot on every file of that type in your current directory, and outputs the frequency of each warning to a CSV file that you can manipulate further with Google Sheets.
Closes #4