This repository has been archived by the owner on Jan 15, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 538
[website] Add a demo page for the Website #1180
Open
chenw23
wants to merge
14
commits into
dmlc:v0.x
Choose a base branch
from
chenw23:patch-1
base: v0.x
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Changes from all commits
Commits
Show all changes
14 commits
Select commit
Hold shift + click to select a range
5685daa
Create a new demo page from docs index
64496bd
Add a new demo web page into Git
515a1bc
Refactor on the demo folder
5ba9be7
Correct the accuracy; Enhance styles
f41a6bf
Add to the styles of the sentiment analysis page.
c734e00
Add select input event listener for textbox
b5de608
Change the http method to GET
9afb58c
Add ajax function into the web page:
a9cf247
Change from element selector to id selector
213a4ce
Update sample sentences
3798985
Update a new default sentence
7f9717c
Change prediction IP to a Elastic IP
a253397
Merge remote-tracking branch 'upstream/master' into patch-1
38b5ebd
Merge remote-tracking branch 'upstream/master' into patch-1
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
Demos | ||
===== | ||
|
||
.. toctree:: | ||
:maxdepth: 2 | ||
|
||
sentiment |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,73 @@ | ||
Sentiment Analysis | ||
================== | ||
|
||
Introduction | ||
------------ | ||
|
||
Sentiment Analysis predicts whether an input is positive or negative. The model is based on BERT base, and are trained on the binary classification setting of the Stanford Sentiment Treebank. It achieves about 93.4% accuracy on the dev set. | ||
|
||
Demo | ||
---- | ||
|
||
You can either input a sentence into the textbox or select one sample from the select control. | ||
|
||
.. raw:: html | ||
|
||
<label for="select">Enter text or </label> | ||
<select id="select" name="octane" style=" | ||
display: block; | ||
font-size: 14px; | ||
font-family: sans-serif; | ||
font-weight: 700; | ||
color: #444; | ||
line-height: 1.3; | ||
padding: .6em 1.4em .5em .8em; | ||
width: 100%; | ||
max-width: 100%; | ||
box-sizing: border-box; | ||
margin: 0; | ||
border: 2px solid rgba(23, 141, 201, 0.66); | ||
box-shadow: 1px 1px 1px 1px rgba(0,0,0,.05); | ||
border-radius: 1em; | ||
-moz-appearance: none; | ||
-webkit-appearance: none; | ||
appearance: none; | ||
background-image: url('data:image/svg+xml;charset=US-ASCII,%3Csvg%20xmlns%3D%22http%3A%2F%2Fwww.w3.org%2F2000%2Fsvg%22%20width%3D%22292.4%22%20height%3D%22292.4%22%3E%3Cpath%20fill%3D%22%23007CB2%22%20d%3D%22M287%2069.4a17.6%2017.6%200%200%200-13-5.4H18.4c-5%200-9.3%201.8-12.9%205.4A17.6%2017.6%200%200%200%200%2082.2c0%205%201.8%209.3%205.4%2012.9l128%20127.9c3.6%203.6%207.8%205.4%2012.8%205.4s9.2-1.8%2012.8-5.4L287%2095c3.5-3.5%205.4-7.8%205.4-12.8%200-5-1.9-9.2-5.5-12.8z%22%2F%3E%3C%2Fsvg%3E'), | ||
linear-gradient(to bottom, #ffffff 0%,#ffffff 100%); | ||
background-repeat: no-repeat, repeat; | ||
background-position: right .7em top 50%, 0 0; | ||
background-size: .65em auto, 100%;"> | ||
<option>Choose an example...</option> | ||
<option value="Happy New Year!">Happy New Year!</option> | ||
<option value="That person seems to be in anger now.">That person seems to be in anger now.</option> | ||
</select> | ||
|
||
<div class="mdl-textfield mdl-js-textfield" style="width: 90%"> | ||
<input class="mdl-textfield__input" type="text" | ||
id="input" name="data" value="Input a sentence..." | ||
style="border-bottom:1px solid rgba(23, 141, 201, 0.9);"> | ||
</div> | ||
<input type="button" value="Try" class="mdl-button mdl-js-button mdl-button--raised mdl-js-ripple-effect" | ||
style="color: rgba(23, 141, 201, 1);"> | ||
<div id="result"> | ||
Result will appear here. | ||
</div> | ||
|
||
<script type="text/javascript"> | ||
$("#select").change(function () { | ||
let sentence = $(this).val(); | ||
$("#input").val(sentence) | ||
}); | ||
|
||
$("select+div+input").click(function () { | ||
let request_url = 'http://52.12.156.84:8888/bert_sst/predict?data=["' + | ||
$("#input").val() + '"]'; | ||
$.ajax({ | ||
url: request_url, success: function (result) { | ||
if (result[4] === '0') | ||
$("#result").html("Negative Sentiment"); | ||
else $("#result").html("Positive Sentiment"); | ||
} | ||
}); | ||
}); | ||
</script> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
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.
Currently we're giving an existence proof of "it's possible to have some web application to do sentiment analysis". But to be really useful to the end users, we need to teach them how to build it (not only show it's possible).
To make things simple, such instructions should be based on https://aws.amazon.com/serverless/ and https://aws.amazon.com/sagemaker/