Skip to content

Commit 6b66654

Browse files
committed
Added Support for Who is behind DBpedia Question
1 parent 8b68723 commit 6b66654

File tree

10 files changed

+53
-14
lines changed

10 files changed

+53
-14
lines changed

README.md

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -7,18 +7,18 @@
77
chatbot.fb.appSecret = <secret>
88
chatbot.fb.verifyToken = <token>
99
chatbot.fb.pageAccessToken = <access-token>
10-
10+
1111
cloudant.url = <couchdb-url>
1212
cloudant.username = <couchdb-username>
1313
cloudant.password = <couchdb-password>
1414
cloudant.chatDB = <couchdb-chatdb-name>
1515
cloudant.feedbackDB = <couchdb-feedbackdb-name>
1616
cloudant.explorerDB = <couchdb-explorerdb-name>
17-
17+
1818
tmdb.apiKey = <tmdb-api-key>
19-
20-
wolfram.apiKey = <wolfram-alpha-api-key>
21-
19+
20+
wolfram.apiKey = <wolfram-alpha-api-key>
21+
2222
logging.level.com.github.messenger4j=<log-level>
2323

2424
### Development Only Configurations
@@ -28,7 +28,8 @@
2828

2929
## Deployment
3030
mvn clean install
31-
java $JAVA_OPTS -Dserver.port=$PORT -jar target/*.jar // $PORT is the port number you want the server to run in for example 8080
32-
31+
java $JAVA_OPTS -Dserver.port=$PORT -jar target/*.jar // $PORT is the port number you want the server to run in for example 8080
32+
3333
## Development
34+
mvn spring-boot:run
3435
node/node node_modules/.bin/webpack --watch

app/src/js/components/chat/Message.jsx

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -82,7 +82,10 @@ class Message extends React.Component {
8282
{message.buttons.map((button, index) => {
8383
switch(button.buttonType) {
8484
case Constants.response.ResponseType.BUTTON_LINK:
85-
return <a key={index} href={button.uri} target="_blank" className="btn btn-block btn-raised btn-info">{button.title}</a>
85+
return <a key={index} href={button.uri} target="_blank" className="btn btn-block btn-raised btn-info">
86+
{button.title}
87+
<i className="material-icons">launch</i>
88+
</a>
8689
case Constants.response.ResponseType.BUTTON_PARAM:
8790
return <a key={index} href="#" data-param={button.uri} onClick={(event) => this.onParamButtonClick(event, button.uri, button.title)} className="btn btn-block btn-raised btn-info">{button.title}</a>
8891
}
@@ -152,7 +155,10 @@ class Message extends React.Component {
152155
{message.buttons.map((button, index) => {
153156
switch(button.buttonType) {
154157
case Constants.response.ResponseType.BUTTON_LINK:
155-
return <a key={index} href={button.uri} target="_blank" className="btn btn-block btn-primary">{button.title}</a>
158+
return <a key={index} href={button.uri} target="_blank" className="btn btn-block btn-primary">
159+
{button.title}
160+
<i className="material-icons">launch</i>
161+
</a>
156162
case Constants.response.ResponseType.BUTTON_PARAM:
157163
return <a key={index} href="#" onClick={(event) => this.onParamButtonClick(event, button.uri, button.title)} className="btn btn-block btn-primary">{button.title}</a>
158164
}

app/src/less/config/base.less

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,4 +58,10 @@ form {
5858

5959
h1,h2,h3,h4,h5,h6 {
6060
color: @brand-primary;
61+
}
62+
63+
.button-group .btn i {
64+
font-size: 20px;
65+
position: absolute;
66+
left: 90%;
6167
}

src/main/java/chatbot/lib/handlers/TemplateHandler.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public ResponseGenerator handleTemplateMessage() {
5858
// DBpedia Template Scenarios
5959
case TemplateType.DBPEDIA_ABOUT:
6060
case TemplateType.DBPEDIA_CONTRIBUTE:
61+
case TemplateType.DBPEDIA_ASSOCIATION:
6162
case TemplateType.DBPEDIA_FALLBACK:
6263
responseGenerator = new DBpediaTemplateHandler(request, payload, helper).handleTemplateMessage();
6364
break;
@@ -134,7 +135,7 @@ public ResponseGenerator handleTemplateMessage() {
134135
responseGenerator.addTextResponse(new ResponseData("Glad that you like it."));
135136
break;
136137
case TemplateType.NO:
137-
responseGenerator.addTextResponse(new ResponseData("Sorry, I will try better."));
138+
responseGenerator.addTextResponse(new ResponseData("Sorry, I will try to become better."));
138139
break;
139140
}
140141
responseGenerator.setShowFeedback(false);

src/main/java/chatbot/lib/handlers/templates/dbpedia/DBpediaTemplateHandler.java

Lines changed: 10 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ public ResponseGenerator handleTemplateMessage() {
2727
case TemplateType.DBPEDIA_ABOUT:
2828
responseGenerator.addTextResponse(new ResponseData("DBpedia is a crowd-sourced community effort to extract structured information from Wikipedia and make this information available on the Web."));
2929
responseGenerator.addButtonTextResponse(new ResponseData("You can find more information here:", new ArrayList<ResponseData.Button>(){{
30-
add(new ResponseData.Button("About DBpedia", ResponseType.BUTTON_LINK, "http://wiki.dbpedia.org/about"));
30+
add(new ResponseData.Button("Learn More", ResponseType.BUTTON_LINK, "http://wiki.dbpedia.org/about"));
3131
add(new ResponseData.Button("Getting Started", ResponseType.BUTTON_LINK, "http://wiki.dbpedia.org/get-involved"));
3232
add(new ResponseData.Button("Tutorial", ResponseType.BUTTON_LINK, "http://semanticweb.org/wiki/Getting_data_from_the_Semantic_Web.html"));
3333
}}));
@@ -40,6 +40,15 @@ public ResponseGenerator handleTemplateMessage() {
4040
add(new ResponseData.Button("Slack", ResponseType.BUTTON_LINK, "https://dbpedia.slack.com/"));
4141
}}));
4242
break;
43+
case TemplateType.DBPEDIA_ASSOCIATION:
44+
responseGenerator.addTextResponse(new ResponseData("The DBpedia Association was founded in 2014 to support DBpedia and the DBpedia Community."));
45+
responseGenerator.addTextResponse(new ResponseData("Since then we are making slow, but steady progress towards professionalizing DBpedia for its users and forming an effective network out of the loosely organised DBpedia community."));
46+
responseGenerator.addButtonTextResponse(new ResponseData("You can learn more about the DBpedia Association here:", new ArrayList<ResponseData.Button>(){{
47+
add(new ResponseData.Button("Learn More", ResponseType.BUTTON_LINK, "http://wiki.dbpedia.org/dbpedia-association"));
48+
add(new ResponseData.Button("About DBpedia", ResponseType.BUTTON_PARAM, TemplateType.DBPEDIA_ABOUT));
49+
add(new ResponseData.Button("Language Chapters", ResponseType.BUTTON_LINK, "http://wiki.dbpedia.org/about/language-chapters"));
50+
}}));
51+
break;
4352
case TemplateType.DBPEDIA_FALLBACK:
4453
String[] service = Constants.SERVICES.get(payload[1]);
4554
responseGenerator.addButtonTextResponse(new ResponseData("Sorry, I didn't completely understand your question about " + service[0] + ". Maybe someone in the Mailing List can help you better.", new ArrayList<ResponseData.Button>(){{

src/main/java/chatbot/lib/request/TemplateType.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ public interface TemplateType {
1111
String DBPEDIA_ABOUT = "dbpedia-about";
1212
String DBPEDIA_CONTRIBUTE = "dbpedia-contribute";
1313
String DBPEDIA_FALLBACK = "dbpedia-fallback";
14+
String DBPEDIA_ASSOCIATION = "dbpedia-association";
1415

1516
String DBPEDIA_DATASET = "dbpedia-dataset";
1617
String DBPEDIA_DATASET_NLP = "dbpedia-dataset-nlp";

src/main/resources/rivescript/dbpedia.rive

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,13 @@
3030
@ dbpedia contribute
3131

3232
+ how [*] to (help|contribute) [*] [project]
33+
@ dbpedia contribute
34+
35+
+ [*] dbpedia association
36+
- {"type": "template", "name": "dbpedia-association"}
37+
38+
+ [*] (who|what) is behind dbpedia
39+
@ dbpedia association
3340

3441
// Fallback
3542
+ * dbpedia *

src/main/resources/rivescript/scenario-text.rive

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,8 @@
3737
- Here are some links about <formal>:
3838

3939
+ dbpediafallbacktext
40-
- I'm sorry, DBpedia seems to be down right now. So I will be unable to answer factual questions temporarily.
40+
- I'm sorry, DBpedia seems to be {uppercase}(@statusdown){/uppercase} right now. So I will be unable to answer factual questions temporarily.
41+
- I'm sorry, DBpedia seems to be {uppercase}(@statusdown){/uppercase} right now. So I will be unable to answer factoid questions temporarily.
4142

4243
+ fallbacktext
4344
- I'm sorry, but I couldn’t understand your question. I'm still learning, and will get better.

src/main/resources/templates/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
<meta name="mobile-web-app-capable" content="yes" />
88

99
<!-- Material Design fonts -->
10-
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/css?family=Roboto:500" />
11-
<link rel="stylesheet" type="text/css" href="//fonts.googleapis.com/icon?family=Material+Icons" />
10+
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/css?family=Roboto:500" />
11+
<link rel="stylesheet" type="text/css" href="https://fonts.googleapis.com/icon?family=Material+Icons" />
1212

1313
<!-- Bootstrap -->
1414
<link rel="stylesheet" type="text/css" href="assets/bootstrap/dist/css/bootstrap.min.css" />

src/test/java/rivescript/dbpedia/TestDBpedia.java

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -25,4 +25,11 @@ public void testDBpediaContribute() {
2525
checkAnswers(testCases, expectedAnswer, true);
2626
}
2727

28+
@Test
29+
public void testDBpediaAssociation() {
30+
String[] testCases = new String[]{"Who is behind DBpedia"};
31+
String[] expectedAnswer = new String[]{"{\"type\": \"template\", \"name\": \"dbpedia-association\"}"};
32+
checkAnswers(testCases, expectedAnswer, true);
33+
}
34+
2835
}

0 commit comments

Comments
 (0)