This commit is contained in:
w-mj
2018-12-24 20:45:27 +08:00
parent c5b2ad675b
commit 45a607a934
20 changed files with 159 additions and 13956 deletions
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
-319
View File
@@ -1,319 +0,0 @@
/*!
* Bootstrap Reboot v4.2.1 (https://getbootstrap.com/)
* Copyright 2011-2018 The Bootstrap Authors
* Copyright 2011-2018 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/
*,
*::before,
*::after {
box-sizing: border-box;
}
html {
font-family: sans-serif;
line-height: 1.15;
-webkit-text-size-adjust: 100%;
-webkit-tap-highlight-color: rgba(0, 0, 0, 0);
}
article, aside, figcaption, figure, footer, header, hgroup, main, nav, section {
display: block;
}
body {
margin: 0;
font-family: -apple-system, BlinkMacSystemFont, "Segoe UI", Roboto, "Helvetica Neue", Arial, "Noto Sans", sans-serif, "Apple Color Emoji", "Segoe UI Emoji", "Segoe UI Symbol", "Noto Color Emoji";
font-size: 1rem;
font-weight: 400;
line-height: 1.5;
color: #212529;
text-align: left;
background-color: #fff;
}
[tabindex="-1"]:focus {
outline: 0 !important;
}
hr {
box-sizing: content-box;
height: 0;
overflow: visible;
}
h1, h2, h3, h4, h5, h6 {
margin-top: 0;
margin-bottom: 0.5rem;
}
p {
margin-top: 0;
margin-bottom: 1rem;
}
abbr[title],
abbr[data-original-title] {
text-decoration: underline;
-webkit-text-decoration: underline dotted;
text-decoration: underline dotted;
cursor: help;
border-bottom: 0;
text-decoration-skip-ink: none;
}
address {
margin-bottom: 1rem;
font-style: normal;
line-height: inherit;
}
ol,
ul,
dl {
margin-top: 0;
margin-bottom: 1rem;
}
ol ol,
ul ul,
ol ul,
ul ol {
margin-bottom: 0;
}
dt {
font-weight: 700;
}
dd {
margin-bottom: .5rem;
margin-left: 0;
}
blockquote {
margin: 0 0 1rem;
}
b,
strong {
font-weight: bolder;
}
small {
font-size: 80%;
}
sub,
sup {
position: relative;
font-size: 75%;
line-height: 0;
vertical-align: baseline;
}
sub {
bottom: -.25em;
}
sup {
top: -.5em;
}
a {
color: #007bff;
text-decoration: none;
background-color: transparent;
}
a:hover {
color: #0056b3;
text-decoration: underline;
}
a:not([href]):not([tabindex]) {
color: inherit;
text-decoration: none;
}
a:not([href]):not([tabindex]):hover, a:not([href]):not([tabindex]):focus {
color: inherit;
text-decoration: none;
}
a:not([href]):not([tabindex]):focus {
outline: 0;
}
pre,
code,
kbd,
samp {
font-family: SFMono-Regular, Menlo, Monaco, Consolas, "Liberation Mono", "Courier New", monospace;
font-size: 1em;
}
pre {
margin-top: 0;
margin-bottom: 1rem;
overflow: auto;
}
figure {
margin: 0 0 1rem;
}
img {
vertical-align: middle;
border-style: none;
}
svg {
overflow: hidden;
vertical-align: middle;
}
table {
border-collapse: collapse;
}
caption {
padding-top: 0.75rem;
padding-bottom: 0.75rem;
color: #6c757d;
text-align: left;
caption-side: bottom;
}
th {
text-align: inherit;
}
label {
display: inline-block;
margin-bottom: 0.5rem;
}
button {
border-radius: 0;
}
button:focus {
outline: 1px dotted;
outline: 5px auto -webkit-focus-ring-color;
}
input,
button,
select,
optgroup,
textarea {
margin: 0;
font-family: inherit;
font-size: inherit;
line-height: inherit;
}
button,
input {
overflow: visible;
}
button,
select {
text-transform: none;
}
button,
[type="button"],
[type="reset"],
[type="submit"] {
-webkit-appearance: button;
}
button::-moz-focus-inner,
[type="button"]::-moz-focus-inner,
[type="reset"]::-moz-focus-inner,
[type="submit"]::-moz-focus-inner {
padding: 0;
border-style: none;
}
input[type="radio"],
input[type="checkbox"] {
box-sizing: border-box;
padding: 0;
}
input[type="date"],
input[type="time"],
input[type="datetime-local"],
input[type="month"] {
-webkit-appearance: listbox;
}
textarea {
overflow: auto;
resize: vertical;
}
fieldset {
min-width: 0;
padding: 0;
margin: 0;
border: 0;
}
legend {
display: block;
width: 100%;
max-width: 100%;
padding: 0;
margin-bottom: .5rem;
font-size: 1.5rem;
line-height: inherit;
color: inherit;
white-space: normal;
}
progress {
vertical-align: baseline;
}
[type="number"]::-webkit-inner-spin-button,
[type="number"]::-webkit-outer-spin-button {
height: auto;
}
[type="search"] {
outline-offset: -2px;
-webkit-appearance: none;
}
[type="search"]::-webkit-search-decoration {
-webkit-appearance: none;
}
::-webkit-file-upload-button {
font: inherit;
-webkit-appearance: button;
}
output {
display: inline-block;
}
summary {
display: list-item;
cursor: pointer;
}
template {
display: none;
}
[hidden] {
display: none !important;
}
/*# sourceMappingURL=bootstrap-reboot.css.map */
File diff suppressed because one or more lines are too long
-8
View File
@@ -1,8 +0,0 @@
/*!
* Bootstrap Reboot v4.2.1 (https://getbootstrap.com/)
* Copyright 2011-2018 The Bootstrap Authors
* Copyright 2011-2018 Twitter, Inc.
* Licensed under MIT (https://github.com/twbs/bootstrap/blob/master/LICENSE)
* Forked from Normalize.css, licensed MIT (https://github.com/necolas/normalize.css/blob/master/LICENSE.md)
*/*,::after,::before{box-sizing:border-box}html{font-family:sans-serif;line-height:1.15;-webkit-text-size-adjust:100%;-webkit-tap-highlight-color:transparent}article,aside,figcaption,figure,footer,header,hgroup,main,nav,section{display:block}body{margin:0;font-family:-apple-system,BlinkMacSystemFont,"Segoe UI",Roboto,"Helvetica Neue",Arial,"Noto Sans",sans-serif,"Apple Color Emoji","Segoe UI Emoji","Segoe UI Symbol","Noto Color Emoji";font-size:1rem;font-weight:400;line-height:1.5;color:#212529;text-align:left;background-color:#fff}[tabindex="-1"]:focus{outline:0!important}hr{box-sizing:content-box;height:0;overflow:visible}h1,h2,h3,h4,h5,h6{margin-top:0;margin-bottom:.5rem}p{margin-top:0;margin-bottom:1rem}abbr[data-original-title],abbr[title]{text-decoration:underline;-webkit-text-decoration:underline dotted;text-decoration:underline dotted;cursor:help;border-bottom:0;text-decoration-skip-ink:none}address{margin-bottom:1rem;font-style:normal;line-height:inherit}dl,ol,ul{margin-top:0;margin-bottom:1rem}ol ol,ol ul,ul ol,ul ul{margin-bottom:0}dt{font-weight:700}dd{margin-bottom:.5rem;margin-left:0}blockquote{margin:0 0 1rem}b,strong{font-weight:bolder}small{font-size:80%}sub,sup{position:relative;font-size:75%;line-height:0;vertical-align:baseline}sub{bottom:-.25em}sup{top:-.5em}a{color:#007bff;text-decoration:none;background-color:transparent}a:hover{color:#0056b3;text-decoration:underline}a:not([href]):not([tabindex]){color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus,a:not([href]):not([tabindex]):hover{color:inherit;text-decoration:none}a:not([href]):not([tabindex]):focus{outline:0}code,kbd,pre,samp{font-family:SFMono-Regular,Menlo,Monaco,Consolas,"Liberation Mono","Courier New",monospace;font-size:1em}pre{margin-top:0;margin-bottom:1rem;overflow:auto}figure{margin:0 0 1rem}img{vertical-align:middle;border-style:none}svg{overflow:hidden;vertical-align:middle}table{border-collapse:collapse}caption{padding-top:.75rem;padding-bottom:.75rem;color:#6c757d;text-align:left;caption-side:bottom}th{text-align:inherit}label{display:inline-block;margin-bottom:.5rem}button{border-radius:0}button:focus{outline:1px dotted;outline:5px auto -webkit-focus-ring-color}button,input,optgroup,select,textarea{margin:0;font-family:inherit;font-size:inherit;line-height:inherit}button,input{overflow:visible}button,select{text-transform:none}[type=button],[type=reset],[type=submit],button{-webkit-appearance:button}[type=button]::-moz-focus-inner,[type=reset]::-moz-focus-inner,[type=submit]::-moz-focus-inner,button::-moz-focus-inner{padding:0;border-style:none}input[type=checkbox],input[type=radio]{box-sizing:border-box;padding:0}input[type=date],input[type=datetime-local],input[type=month],input[type=time]{-webkit-appearance:listbox}textarea{overflow:auto;resize:vertical}fieldset{min-width:0;padding:0;margin:0;border:0}legend{display:block;width:100%;max-width:100%;padding:0;margin-bottom:.5rem;font-size:1.5rem;line-height:inherit;color:inherit;white-space:normal}progress{vertical-align:baseline}[type=number]::-webkit-inner-spin-button,[type=number]::-webkit-outer-spin-button{height:auto}[type=search]{outline-offset:-2px;-webkit-appearance:none}[type=search]::-webkit-search-decoration{-webkit-appearance:none}::-webkit-file-upload-button{font:inherit;-webkit-appearance:button}output{display:inline-block}summary{display:list-item;cursor:pointer}template{display:none}[hidden]{display:none!important}
/*# sourceMappingURL=bootstrap-reboot.min.css.map */
File diff suppressed because one or more lines are too long
-9887
View File
File diff suppressed because it is too large Load Diff
File diff suppressed because one or more lines are too long
+45
View File
@@ -0,0 +1,45 @@
.message1,
.message2 {
float:right;
width: auto;
/*width: 200px;*/
/*height: 80px;*/
margin: 5px;
background-color: #aeff72;
border-bottom-color: #aeff72;
/*为了给after伪元素自动继承*/
font-size: 16px;
line-height: 18px;
padding: 5px 12px 5px 12px;
box-sizing: border-box;
border-radius: 6px;
position: relative;
word-break: break-all;
}
.message1::after {
content: '';
position: absolute;
top: 50%;
right: -5px;
width: 15px;
height: 15px;
margin-top: -10px;
background: inherit;
/*自动继承父元素的背景*/
transform: rotate(45deg);
}
.message2::before {
content: '';
position: absolute;
top: 50%;
left: -5px;
width: 15px;
height: 15px;
margin-top: -10px;
background: inherit;
/*自动继承父元素的背景*/
transform: rotate(45deg);
}
+4
View File
@@ -0,0 +1,4 @@
.row {
margin-bottom: 10px;
margin-top: 10px;
}
+22
View File
@@ -0,0 +1,22 @@
function sendMessage() {
let box = $("#input-box");
let text = box.val();
box.val('');
console.log("say: " + text);
$("#chat-box").append("<li class=\"list-group-item message1\">" + text + "</li>");
$.ajax({
url: 'http://127.0.0.1:8000/chat',
type: 'GET',
data: {tk:'1', text:text},
dataType: 'json',
success: function (response) {
$("#chat-box").append("<li class=\"list-group-item message2\">" + response.text + "</li>")
},
error: function (err) {
console.log("chat server error");
console.log(err);
}
});
}
File diff suppressed because one or more lines are too long
File diff suppressed because one or more lines are too long
+69 -7
View File
@@ -1,21 +1,83 @@
<!DOCTYPE html>
<html lang="en">
<html lang="zh-CN">
<head>
<meta charset="UTF-8">
<title>Chat Bot</title>
{% load staticfiles %}
<link type="text/css" href="{% static 'css/bootstrap.css' %}">
<script type="javascript" src="{% static 'js/bootstrap.js' %}"></script>
<script type="javascript" src="{% static 'js/jquery-3.3.1.min.js' %}"></script>
</head>
<body>
<div class="container">
<div class="row">
<div class="col-md-12">
<div class="h1">TEST BOOTSTRAP</div>
<div class="col-md-6 text-center">
<div class="h1">NLP TOOLS</div>
</div>
</div>
<div class="row">
<div class="col-md-12">
<ul class="nav nav-tabs nav-fill" id="myTab" role="tablist">
<li class="nav-item">
<a class="nav-link active" role="tab" data-toggle="tab"
href="#chat" id="chat-tab" aria-controls="chat" aria-selected="true">对话系统</a>
</li>
<li class="nav-item">
<a class="nav-link" role="tab" data-toggle="tab"
href="#separation" id="separation-tab" aria-controls="separation">分词工具</a>
</li>
<li class="nav-item">
<a class="nav-link" role="tab" data-toggle="tab"
href="#synonym" id="synonym-tab" aria-controls="synonym">近义词判断</a>
</li>
<li class="nav-item">
<a class="nav-link" role="tab" data-toggle="tab"
href="#sentiment" id="sentiment-tab" aria-controls="sentiment">情感判断</a>
</li>
</ul>
</div>
</div>
<div class="row">
<div class="col-md-3">&nbsp; </div>
<div class="tab-content col-md-6" id="navContent">
<!-- 聊天界面 -->
<div class="tab-pane fade show active" id="chat" role="tabpanel" aria-labelledby="chat-tab">
<!-- 对话列表 -->
<ul class="list-group" id="chat-box">
<li class="list-group-item message1">
Message1Message1Message1Message1Message1Message1Message1Message1
</li>
<li class="list-group-item message2">
Message2
</li>
</ul>
<!-- 输入框 -->
<div style="padding-top: 20px">
<div class="input-group mb-3">
<input type="text" class="form-control" placeholder="聊点什么吧" aria-label="Text" aria-describedby="send" id="input-box">
<div class="input-group-append">
<button class="btn btn-outline-secondary" type="button" id="send-button" onclick="sendMessage()">发送</button>
</div>
</div>
</div>
</div>
<div class="tab-pane fade" id="separation" role="tabpanel" aria-labelledby="separation-tab">分词</div>
<div class="tab-pane fade" id="synonym" role="tabpanel" aria-labelledby="synonym-tab">近义词</div>
<div class="tab-pane fade" id="sentiment" role="tabpanel" aria-labelledby="sentiment-tab">情感</div>
</div>
</div>
</div>
</body>
{% load staticfiles %}
<link rel="stylesheet" type="text/css" href="{% static 'css/bootstrap.min.css' %}"/>
<link rel="stylesheet" type="text/css" href="{% static 'css/message_bubble.css' %}"/>
<link rel="stylesheet" type="text/css" href="{% static 'css/style.css' %}"/>
<script type="text/javascript" src="{% static 'js/jquery-3.3.1.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/bootstrap.min.js' %}"></script>
<script type="text/javascript" src="{% static 'js/action.js' %}"></script>
</html>
+11 -1
View File
@@ -1,5 +1,15 @@
from django.shortcuts import render
from django.http import JsonResponse, HttpResponse
def chatbot_index(request):
def index(request):
return render(request, 'index.html')
def chat(request):
if request.method == 'GET':
token = request.GET.get("tk", default=0)
text = request.GET.get("text", default="")
if token != 0 and text:
return JsonResponse({"text": text})
return HttpResponse('error')
+4
View File
@@ -0,0 +1,4 @@
# MyWebsite
个人网站
## reference
+ [聊天气泡效果](https://www.jianshu.com/p/cf2d5c2f15fa)
+2 -1
View File
@@ -19,5 +19,6 @@ import chatbot.views
urlpatterns = [
path('admin/', admin.site.urls),
path('', chatbot.views.chatbot_index)
path('', chatbot.views.index),
path('chat', chatbot.views.chat)
]