mirror of
https://github.com/indentlabs/notebook.git
synced 2025-10-26 11:19:22 +00:00
emotional range on entities
This commit is contained in:
parent
95775a2a56
commit
52d712ea21
@ -5,15 +5,17 @@ module Documents
|
||||
analysis = DocumentAnalysis.find(analysis_id)
|
||||
document = analysis.document
|
||||
|
||||
analysis.noun_count = document.nouns.count
|
||||
analysis.adjective_count = document.adjectives.count
|
||||
analysis.verb_count = document.verbs.count
|
||||
analysis.pronoun_count = document.pronouns.count
|
||||
analysis.noun_count = document.nouns.count
|
||||
analysis.adjective_count = document.adjectives.count
|
||||
analysis.verb_count = document.verbs.count
|
||||
analysis.pronoun_count = document.pronouns.count
|
||||
# analysis.preposition_count = document.prepositions.count
|
||||
analysis.conjunction_count = document.conjunctions.count
|
||||
analysis.adverb_count = document.adverbs.count
|
||||
analysis.conjunction_count = document.conjunctions.count
|
||||
analysis.adverb_count = document.adverbs.count
|
||||
# analysis.determiner_count = document.determiners.count
|
||||
|
||||
analysis.interrogative_count = document.interrogatives.count
|
||||
|
||||
# TODO other POS counters:
|
||||
# - numbers
|
||||
# - stop words
|
||||
|
||||
@ -2,15 +2,30 @@
|
||||
<div class="row">
|
||||
<% analysis.document_entities.order('entity_type').each do |entity| %>
|
||||
<% entity_class = entity.entity_type.constantize %>
|
||||
<div class="col s12 m4">
|
||||
<div class="col s12 m6">
|
||||
<div class="card">
|
||||
<div class="card-content <%= entity_class.color %> lighten-3">
|
||||
<div class="card-title">
|
||||
<i class="material-icons"><%= entity_class.icon %></i>
|
||||
<div class="card-image waves-effect waves-block waves-light">
|
||||
<%# todo page image if matched to a page + images exist %>
|
||||
<%= image_tag 'card-headers/' + entity_class.name.downcase.pluralize + '.jpg', class: 'activator' %>
|
||||
</div>
|
||||
<div class="card-content">
|
||||
<span class="card-title activator <%= entity_class.color %>-text">
|
||||
<i class="material-icons left"><%= entity_class.icon %></i>
|
||||
<%= entity.text %>
|
||||
</div>
|
||||
<ul>
|
||||
<li>Relevance: <%= entity.relevance %></li>
|
||||
<i class="material-icons right black-text">more_vert</i>
|
||||
</span>
|
||||
<p>
|
||||
Relevance: <%= entity.relevance %>
|
||||
</p>
|
||||
</div>
|
||||
<div class="card-reveal">
|
||||
<span class="card-title <%= entity_class.color %>-text">
|
||||
<i class="material-icons left"><%= entity_class.icon %></i>
|
||||
<%= entity.text %>
|
||||
<i class="material-icons right black-text">close</i>
|
||||
</span>
|
||||
<div id="graph-character-emotions-<%= entity.id %>"></div>
|
||||
<ul class="help-text">
|
||||
<li>Sentiment: <%= entity.sentiment_label %> (<%= entity.sentiment_score %>)</li>
|
||||
<li>Joy: <%= entity.joy_score %></li>
|
||||
<li>Sadness: <%= entity.sadness_score %></li>
|
||||
@ -19,11 +34,54 @@
|
||||
<li>Anger: <%= entity.anger_score %></li>
|
||||
</ul>
|
||||
</div>
|
||||
<div class="card-action <%= entity_class.color %> lighten-5">
|
||||
<div class="card-action">
|
||||
<a href="#" class="<%= entity_class.color %>-text">View Notebook.ai page</a>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
var emotions_chart = Highcharts.chart('graph-character-emotions-<%= entity.id %>', {
|
||||
chart: {
|
||||
polar: true,
|
||||
type: 'line'
|
||||
},
|
||||
title: {
|
||||
text: 'Emotional range'
|
||||
},
|
||||
xAxis: {
|
||||
categories: ['Joy', 'Sadness', 'Fear', 'Disgust', 'Anger'],
|
||||
tickmarkPlacement: 'on',
|
||||
lineWidth: 0
|
||||
},
|
||||
yAxis: {
|
||||
lineWidth: 0,
|
||||
min: 0,
|
||||
max: 100
|
||||
},
|
||||
legend: {
|
||||
enabled: false
|
||||
},
|
||||
series: [
|
||||
{
|
||||
name: '<%= entity.text %>',
|
||||
data: <%=
|
||||
[
|
||||
(100 * entity.joy_score).round(1),
|
||||
(100 * entity.sadness_score).round(1),
|
||||
(100 * entity.fear_score).round(1),
|
||||
(100 * entity.disgust_score).round(1),
|
||||
(100 * entity.anger_score).round(1)
|
||||
]
|
||||
%>,
|
||||
pointPlacement: 'on'
|
||||
}
|
||||
]
|
||||
});
|
||||
})
|
||||
</script>
|
||||
|
||||
<% end %>
|
||||
|
||||
<div class="col s12 m12">
|
||||
@ -35,17 +93,15 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
|
||||
<script type="text/javascript">
|
||||
$(document).ready(function () {
|
||||
|
||||
var emotions_chart = Highcharts.chart('graph-character-emotions', {
|
||||
chart: {
|
||||
polar: true,
|
||||
type: 'line'
|
||||
},
|
||||
title: {
|
||||
text: 'Character emotional range'
|
||||
text: 'Ensemble emotional range'
|
||||
},
|
||||
xAxis: {
|
||||
categories: ['Joy', 'Sadness', 'Fear', 'Disgust', 'Anger'],
|
||||
@ -53,7 +109,6 @@ $(document).ready(function () {
|
||||
lineWidth: 0
|
||||
},
|
||||
yAxis: {
|
||||
gridLineInterpolation: 'polygon',
|
||||
lineWidth: 0,
|
||||
min: 0,
|
||||
max: 100
|
||||
|
||||
@ -1,6 +1,6 @@
|
||||
<h5 class="grey-text">Ease of reading</h5>
|
||||
<div class="row">
|
||||
<div class="col s12 m6">
|
||||
<div class="col s12">
|
||||
<div class="green card">
|
||||
<div class="card-content">
|
||||
<div class="row">
|
||||
@ -8,7 +8,7 @@
|
||||
<h2><%= analysis.readability_score %></h2>
|
||||
READABILITY
|
||||
</div>
|
||||
<div class="col s12 m9">
|
||||
<div class="col s12 m9 white-text">
|
||||
<h4>
|
||||
<% Documents::Analysis::ReadabilityService.readability_score_category(analysis.readability_score) %>
|
||||
</h4>
|
||||
@ -48,16 +48,7 @@
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col s12 m6">
|
||||
<div class="green card lighten-3">
|
||||
<div class="card-content">
|
||||
<%# TODO: Tips from highest/lowest readability scores %>
|
||||
To increase your readability further, try using shorter sentences.
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
<div class="col s12">
|
||||
<div class="col s12 offset-m4 m6">
|
||||
<a href="#" class="hoverable btn btn-large teal lighten-1 white-text js-toggle-extended-readability-statistics">
|
||||
Show more readability statistics
|
||||
</a>
|
||||
|
||||
@ -1,5 +1,6 @@
|
||||
class AddMoreFieldsToDocuments < ActiveRecord::Migration[5.2]
|
||||
def change
|
||||
add_column :documents, :progress, :int
|
||||
add_column :document_analyses, :progress, :int
|
||||
add_column :document_analyses, :interrogative_count, :int
|
||||
end
|
||||
end
|
||||
|
||||
@ -10,7 +10,7 @@
|
||||
#
|
||||
# It's strongly recommended that you check this file into your version control system.
|
||||
|
||||
ActiveRecord::Schema.define(version: 2019_05_30_192249) do
|
||||
ActiveRecord::Schema.define(version: 2019_06_04_162744) do
|
||||
|
||||
create_table "api_keys", force: :cascade do |t|
|
||||
t.integer "user_id"
|
||||
@ -798,6 +798,8 @@ ActiveRecord::Schema.define(version: 2019_05_30_192249) do
|
||||
t.datetime "completed_at"
|
||||
t.datetime "created_at", null: false
|
||||
t.datetime "updated_at", null: false
|
||||
t.integer "progress"
|
||||
t.integer "interrogative_count"
|
||||
t.index ["document_id"], name: "index_document_analyses_on_document_id"
|
||||
end
|
||||
|
||||
@ -1170,9 +1172,8 @@ ActiveRecord::Schema.define(version: 2019_05_30_192249) do
|
||||
t.datetime "updated_at", null: false
|
||||
t.string "src_file_name"
|
||||
t.string "src_content_type"
|
||||
t.integer "src_file_size"
|
||||
t.bigint "src_file_size"
|
||||
t.datetime "src_updated_at"
|
||||
t.boolean "audited"
|
||||
t.index ["content_type", "content_id"], name: "index_image_uploads_on_content_type_and_content_id"
|
||||
t.index ["user_id"], name: "index_image_uploads_on_user_id"
|
||||
end
|
||||
@ -2519,13 +2520,11 @@ ActiveRecord::Schema.define(version: 2019_05_30_192249) do
|
||||
t.string "age"
|
||||
t.string "gender"
|
||||
t.string "interests"
|
||||
t.string "slug"
|
||||
t.index ["deleted_at", "username"], name: "index_users_on_deleted_at_and_username"
|
||||
t.index ["deleted_at"], name: "index_users_on_deleted_at"
|
||||
t.index ["email"], name: "index_users_on_email", unique: true
|
||||
t.index ["id", "deleted_at"], name: "index_users_on_id_and_deleted_at"
|
||||
t.index ["reset_password_token"], name: "index_users_on_reset_password_token", unique: true
|
||||
t.index ["slug"], name: "index_users_on_slug", unique: true
|
||||
t.index ["username"], name: "index_users_on_username", unique: true
|
||||
end
|
||||
|
||||
|
||||
Loading…
Reference in New Issue
Block a user