Skip to content

Commit d02d324

Browse files
committed
初始导入
0 parents  commit d02d324

File tree

103 files changed

+456350
-0
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

103 files changed

+456350
-0
lines changed

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
/target/
2+
/logs/
3+
/nb-configuration.xml

LICENSE.txt

Lines changed: 674 additions & 0 deletions
Large diffs are not rendered by default.

README.md

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
QuestionAnsweringSystem是一个Java实现的人机问答系统,能够自动分析问题并给出候选答案。
2+
3+
4+
使用说明:
5+
6+
1、初始化MySQL数据库:
7+
在MySQL命令行中执行QuestionAnsweringSystem\src\main\resources\mysql\questionanswer.sql文件中的脚本
8+
MySQL主机:127.0.0.1,端口:3306,数据库:questionanswer,用户名:root,密码:root
9+
10+
2、构建war文件并部署到tomcat:
11+
cd QuestionAnsweringSystem
12+
mvn install
13+
cp target\QuestionAnsweringSystem-1.0.war apache-tomcat-7.0.37/webapps/QuestionAnsweringSystem-1.0.war
14+
启动tomcat
15+
16+
3、打开浏览器访问:
17+
http://localhost:8080/QuestionAnsweringSystem-1.0/

pom.xml

Lines changed: 214 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,214 @@
1+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
2+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/xsd/maven-4.0.0.xsd">
3+
<modelVersion>4.0.0</modelVersion>
4+
5+
<groupId>org.apdplat</groupId>
6+
<artifactId>QuestionAnsweringSystem</artifactId>
7+
<version>1.0</version>
8+
<packaging>war</packaging>
9+
10+
<name>QuestionAnsweringSystem</name>
11+
<url>https://github.com/ysc/QuestionAnsweringSystem</url>
12+
<description>
13+
QuestionAnsweringSystem是一个Java实现的人机问答系统,能够自动分析问题并给出最佳答案。
14+
</description>
15+
<organization>
16+
<name>QuestionAnsweringSystem</name>
17+
<url>http://apdplat.org/</url>
18+
</organization>
19+
<licenses>
20+
<license>
21+
<name>GNU GENERAL PUBLIC LICENSE, Version 3</name>
22+
<url>http://www.gnu.org/licenses/gpl.html</url>
23+
</license>
24+
</licenses>
25+
<inceptionYear>2014</inceptionYear>
26+
<scm>
27+
<url>https://github.com/ysc/QuestionAnsweringSystem</url>
28+
<connection>scm:git:git://github.com/ysc/QuestionAnsweringSystem.git</connection>
29+
<developerConnection>scm:git:ssh://[email protected]/ysc/QuestionAnsweringSystem.git</developerConnection>
30+
<tag>HEAD</tag>
31+
</scm>
32+
<developers>
33+
<developer>
34+
<name>杨尚川</name>
35+
<email>[email protected]</email>
36+
<url>http://yangshangchuan.iteye.com</url>
37+
</developer>
38+
</developers>
39+
40+
<build>
41+
<plugins>
42+
<!-- 编译插件, 设定JDK版本 -->
43+
<plugin>
44+
<groupId>org.apache.maven.plugins</groupId>
45+
<artifactId>maven-compiler-plugin</artifactId>
46+
<version>${maven-compiler-plugin.version}</version>
47+
<configuration>
48+
<encoding>${project.build.sourceEncoding}</encoding>
49+
<source>${java.version}</source>
50+
<target>${java.version}</target>
51+
<showDeprecation>true</showDeprecation>
52+
<showWarnings>true</showWarnings>
53+
<debug>true</debug>
54+
</configuration>
55+
</plugin>
56+
<!-- 打包插件,排除语料库和语料库工具以及日志配置文件 -->
57+
<plugin>
58+
<groupId>org.apache.maven.plugins</groupId>
59+
<artifactId>maven-jar-plugin</artifactId>
60+
<version>${maven-jar-plugin.version}</version>
61+
</plugin>
62+
<!-- 单元测试插件 -->
63+
<plugin>
64+
<groupId>org.apache.maven.plugins</groupId>
65+
<artifactId>maven-surefire-plugin</artifactId>
66+
<version>${maven-surefire-plugin.version}</version>
67+
<configuration>
68+
<testFailureIgnore>true</testFailureIgnore>
69+
</configuration>
70+
</plugin>
71+
<!-- resource插件, 设定编码 -->
72+
<plugin>
73+
<groupId>org.apache.maven.plugins</groupId>
74+
<artifactId>maven-resources-plugin</artifactId>
75+
<version>${maven-resources-plugin.version}</version>
76+
<configuration>
77+
<encoding>${project.build.sourceEncoding}</encoding>
78+
</configuration>
79+
</plugin>
80+
<!-- source插件,打包源码 -->
81+
<plugin>
82+
<artifactId>maven-source-plugin</artifactId>
83+
<version>${maven-source-plugin.version}</version>
84+
<executions>
85+
<execution>
86+
<id>attach-sources</id>
87+
<goals>
88+
<goal>jar</goal>
89+
</goals>
90+
</execution>
91+
</executions>
92+
</plugin>
93+
<plugin>
94+
<groupId>org.mortbay.jetty</groupId>
95+
<artifactId>maven-jetty-plugin</artifactId>
96+
<version>${maven-jetty-plugin.version}</version>
97+
</plugin>
98+
<!-- 运行 mvn sonar:sonar 可将项目发布给质量管理平台-->
99+
<!-- 软件环境: jdk1.7.0_51 apache-maven-3.0.4 sonar-3.6 -->
100+
<plugin>
101+
<groupId>org.codehaus.sonar</groupId>
102+
<artifactId>sonar-maven3-plugin</artifactId>
103+
<version>${sonar-maven3-plugin.version}</version>
104+
</plugin>
105+
</plugins>
106+
</build>
107+
<properties>
108+
<java.version>1.7</java.version>
109+
<project.build.sourceEncoding>UTF-8</project.build.sourceEncoding>
110+
111+
<maven-compiler-plugin.version>3.0</maven-compiler-plugin.version>
112+
<maven-jar-plugin.version>2.4</maven-jar-plugin.version>
113+
<maven-surefire-plugin.version>2.14</maven-surefire-plugin.version>
114+
<maven-resources-plugin.version>2.6</maven-resources-plugin.version>
115+
<maven-source-plugin.version>2.2.1</maven-source-plugin.version>
116+
<maven-jetty-plugin.version>6.1.26</maven-jetty-plugin.version>
117+
<sonar-maven3-plugin.version>3.5</sonar-maven3-plugin.version>
118+
119+
<javaee-web-api.version>6.0</javaee-web-api.version>
120+
<junit.version>3.8.1</junit.version>
121+
<jsoup.version>1.7.2</jsoup.version>
122+
<slf4j-api.version>1.6.4</slf4j-api.version>
123+
<logback-classic.version>0.9.28</logback-classic.version>
124+
<httpclient.version>3.1</httpclient.version>
125+
<ansj.version>0.9</ansj.version>
126+
<json.version>chargebee-1.0</json.version>
127+
<nekohtml.version>1.9.19</nekohtml.version>
128+
<stanford-parser.version>3.3.1</stanford-parser.version>
129+
<jcl-over-slf4j.version>1.6.4</jcl-over-slf4j.version>
130+
<!-- 数据库驱动 -->
131+
<mysql.version>5.1.18</mysql.version>
132+
</properties>
133+
134+
<dependencies>
135+
<dependency>
136+
<groupId>javax</groupId>
137+
<artifactId>javaee-web-api</artifactId>
138+
<version>${javaee-web-api.version}</version>
139+
<scope>provided</scope>
140+
</dependency>
141+
<dependency>
142+
<groupId>junit</groupId>
143+
<artifactId>junit</artifactId>
144+
<version>${junit.version}</version>
145+
<scope>test</scope>
146+
</dependency>
147+
<dependency>
148+
<groupId>org.jsoup</groupId>
149+
<artifactId>jsoup</artifactId>
150+
<version>${jsoup.version}</version>
151+
</dependency>
152+
<!-- 日志开始-->
153+
<!-- 日志框架API -->
154+
<dependency>
155+
<groupId>org.slf4j</groupId>
156+
<artifactId>slf4j-api</artifactId>
157+
<version>${slf4j-api.version}</version>
158+
</dependency>
159+
<!-- 日志实现提供者 -->
160+
<dependency>
161+
<groupId>ch.qos.logback</groupId>
162+
<artifactId>logback-classic</artifactId>
163+
<version>${logback-classic.version}</version>
164+
<exclusions>
165+
<exclusion>
166+
<groupId>commons-logging</groupId>
167+
<artifactId>commons-logging</artifactId>
168+
</exclusion>
169+
</exclusions>
170+
</dependency>
171+
<dependency>
172+
<groupId>commons-httpclient</groupId>
173+
<artifactId>commons-httpclient</artifactId>
174+
<version>${httpclient.version}</version>
175+
<exclusions>
176+
<exclusion>
177+
<groupId>commons-logging</groupId>
178+
<artifactId>commons-logging</artifactId>
179+
</exclusion>
180+
</exclusions>
181+
</dependency>
182+
<dependency>
183+
<groupId>org.ansj</groupId>
184+
<artifactId>ansj_seg</artifactId>
185+
<version>${ansj.version}</version>
186+
</dependency>
187+
<dependency>
188+
<groupId>org.json</groupId>
189+
<artifactId>org.json</artifactId>
190+
<version>${json.version}</version>
191+
</dependency>
192+
<dependency>
193+
<groupId>net.sourceforge.nekohtml</groupId>
194+
<artifactId>nekohtml</artifactId>
195+
<version>${nekohtml.version}</version>
196+
</dependency>
197+
<dependency>
198+
<groupId>edu.stanford.nlp</groupId>
199+
<artifactId>stanford-parser</artifactId>
200+
<version>${stanford-parser.version}</version>
201+
</dependency>
202+
<!-- 拦截 apache commons logging -->
203+
<dependency>
204+
<groupId>org.slf4j</groupId>
205+
<artifactId>jcl-over-slf4j</artifactId>
206+
<version>${jcl-over-slf4j.version}</version>
207+
</dependency>
208+
<dependency>
209+
<groupId>mysql</groupId>
210+
<artifactId>mysql-connector-java</artifactId>
211+
<version>${mysql.version}</version>
212+
</dependency>
213+
</dependencies>
214+
</project>
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
*
3+
* APDPlat - Application Product Development Platform
4+
* Copyright (c) 2013, 杨尚川, [email protected]
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
*/
20+
21+
package org.apdplat.qa;
22+
23+
import java.util.ArrayList;
24+
import java.util.List;
25+
26+
import org.apdplat.qa.datasource.BaiduDataSource;
27+
import org.apdplat.qa.datasource.DataSource;
28+
import org.apdplat.qa.files.FilesConfig;
29+
import org.apdplat.qa.system.CommonQuestionAnsweringSystem;
30+
import org.apdplat.qa.system.QuestionAnsweringSystem;
31+
32+
/**
33+
* 从配置文件中读取问题 然后从baidu搜索证据 然后计算候选答案
34+
*
35+
* @author 杨尚川
36+
*/
37+
public class BaiduDemo {
38+
39+
/**
40+
* @param args
41+
*/
42+
public static void main(String[] args) {
43+
List<String> files = new ArrayList<>();
44+
files.add(FilesConfig.personNameQuestions);
45+
files.add(FilesConfig.locationNameQuestions);
46+
files.add(FilesConfig.organizationNameQuestions);
47+
files.add(FilesConfig.numberQuestions);
48+
files.add(FilesConfig.timeQuestions);
49+
DataSource dataSource = new BaiduDataSource(files);
50+
51+
QuestionAnsweringSystem questionAnsweringSystem = new CommonQuestionAnsweringSystem();
52+
questionAnsweringSystem.setDataSource(dataSource);
53+
questionAnsweringSystem.answerQuestions();
54+
questionAnsweringSystem.showPerfectQuestions();
55+
questionAnsweringSystem.showNotPerfectQuestions();
56+
questionAnsweringSystem.showWrongQuestions();
57+
questionAnsweringSystem.showUnknownTypeQuestions();
58+
}
59+
}
Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,59 @@
1+
/**
2+
*
3+
* APDPlat - Application Product Development Platform
4+
* Copyright (c) 2013, 杨尚川, [email protected]
5+
*
6+
* This program is free software: you can redistribute it and/or modify
7+
* it under the terms of the GNU General Public License as published by
8+
* the Free Software Foundation, either version 3 of the License, or
9+
* (at your option) any later version.
10+
*
11+
* This program is distributed in the hope that it will be useful,
12+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
13+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14+
* GNU General Public License for more details.
15+
*
16+
* You should have received a copy of the GNU General Public License
17+
* along with this program. If not, see <http://www.gnu.org/licenses/>.
18+
*
19+
*/
20+
21+
package org.apdplat.qa;
22+
23+
import org.apdplat.qa.datasource.ConsoleDataSource;
24+
import org.apdplat.qa.datasource.DataSource;
25+
import org.apdplat.qa.datasource.GoogleDataSource;
26+
import org.apdplat.qa.system.CommonQuestionAnsweringSystem;
27+
import org.apdplat.qa.system.QuestionAnsweringSystem;
28+
import org.slf4j.Logger;
29+
import org.slf4j.LoggerFactory;
30+
31+
/**
32+
* 在控制台输入问题 然后从google搜索证据 然后计算候选答案
33+
*
34+
* @author 杨尚川
35+
*/
36+
public class ConsoleDemo {
37+
38+
private static final Logger LOG = LoggerFactory.getLogger(ConsoleDemo.class);
39+
40+
public static void main(String[] args) {
41+
//Google数据源
42+
//DataSource dataSource = new GoogleDataSource();
43+
//Baidu数据源
44+
DataSource dataSource = new GoogleDataSource();
45+
//控制台数据源
46+
dataSource = new ConsoleDataSource(dataSource);
47+
//人名问答系统
48+
QuestionAnsweringSystem questionAnsweringSystem = new CommonQuestionAnsweringSystem();
49+
//指定控制台数据源
50+
questionAnsweringSystem.setDataSource(dataSource);
51+
//回答问题
52+
questionAnsweringSystem.answerQuestions();
53+
//输出统计信息
54+
questionAnsweringSystem.showPerfectQuestions();
55+
questionAnsweringSystem.showNotPerfectQuestions();
56+
questionAnsweringSystem.showWrongQuestions();
57+
questionAnsweringSystem.showUnknownTypeQuestions();
58+
}
59+
}

0 commit comments

Comments
 (0)