Skip to content

Instantly share code, notes, and snippets.

@AnkurVyas-BTC
Last active August 2, 2016 15:15
Show Gist options
  • Save AnkurVyas-BTC/d34cfde27496aa6d12b4156904fc089c to your computer and use it in GitHub Desktop.
Save AnkurVyas-BTC/d34cfde27496aa6d12b4156904fc089c to your computer and use it in GitHub Desktop.
Wordcounted gem index page view
<h1>Content</h1>
<p> <%= @sentence%></p>
<h1>Content Stats</h1>
<p><b>Total Words</b> = <%= @counter_with_stop_words.token_count %></p>
<p><b>Total Price</b> = $<%= @price %></p>
<p><b>Total Unique Words</b> = <%= @counter_with_stop_words.uniq_token_count %></p>
<p><b>Most Frequent Token</b> = <%= @counter.most_frequent_tokens.keys.first %></p>
<p><b>Longest Token</b> = <%= @counter.longest_tokens.keys.first %></p>
<p><b>Character count</b> = <%= @counter_with_stop_words.char_count %></p>
<p><b>Token Density</b></p>
<% @counter.token_density.first(5).each do |arr| %>
<%= arr[0]%> - <%= number_with_precision(arr[1]*100,precision: 1)%>%
<br>
<% end %>
<p><b>Counter Frequency </b></p>
<% @counter.token_frequency.first(5).each do |arr| %>
<%= arr[0]%> - <%= arr[1]%>
<br>
<% end %>
<p><b>Token Lengths</b></p>
<% @counter.token_lengths.first(5).each do |arr| %>
<%= arr[0]%> - <%= arr[1]%>
<br>
<% end %>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment