data = new ArrayList<>();
18 |
19 | try (BufferedReader br = new BufferedReader(new FileReader(new File("st.csv")));) {
20 | String str;
21 | String[] strs;
22 | while ((str = br.readLine()) != null) {
23 | str = str.substring(1, str.length() - 1);
24 | strs = str.split(":");
25 | String ids = "";
26 | for (int i = 1; i < strs.length - 1; i++) {
27 | // System.out.print(strs[i].split("#")[0] + " ");
28 | if (strs[i].split("#")[0].length() != 0) {
29 | data.add(strs[i].split("#")[0]);
30 | ids += strs[i].split("#")[0] + ",";
31 | }
32 | }
33 | // System.out.print(strs[strs.length - 1] + " ");
34 | if (strs[strs.length - 1].length() != 0) {
35 | data.add(strs[strs.length - 1]);
36 | ids += strs[strs.length - 1] + ",";
37 | }
38 | ids = ids.substring(0, ids.length() - 1);
39 | data.add(ids);
40 | }
41 |
42 | } catch (IOException e) {
43 | e.printStackTrace();
44 | }
45 |
46 | System.out.println(JsonUtils.toJson(data));
47 |
48 | for (String d : data) {
49 | if (!JavaPattern.isAllNum(d.replaceAll(",", ""))) {
50 | System.out.println(d);
51 | }
52 | }
53 |
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/sentiment-solr/src/main/resources/README.md:
--------------------------------------------------------------------------------
1 |
2 | ### Redis作用说明
3 |
4 | #### 主从配置集群
5 |
6 | > 两台机器,其中,redis.rp.master和redis.rp.slave
7 |
8 | `master`:hefei09,用于读数据
9 |
10 | `slave`: hefei10,用于读数据
11 |
12 | > 主要用途:
13 |
14 | `用于站点信息存储K-V`: sent.site.groups
15 |
16 | `用于站点Id和站点名存储K-V`: sent:site:map
17 |
18 | #### 消息队列节点
19 |
20 | > 一台机器,hefei10,redis.mq.server
21 |
22 | `索引缓存数据消息队列List`: sent.cache.records
23 |
24 | `用于数据库写入去重`: sent:key:inserted
25 |
26 | #### 有效期缓存节点
27 |
28 | > 一台机器,hefei08,redis.ft.server
29 |
30 | `用于缓存首次抓取时间firsttime`:时效性为7天
31 |
32 |
--------------------------------------------------------------------------------
/sentiment-solr/src/main/resources/cache-config.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### Mater-Slave (For Replicating Record-Key,Index-Data Caching) #####
3 | # Product
4 | redis.rp.master=192.168.32.19
5 | redis.rp.slave=192.168.32.20
6 | # Testing
7 | #redis.rp.master=192.168.31.20
8 | #redis.rp.slave=192.168.31.21
9 |
10 | ##### Message-Queue (For Index-Data Caching) #####
11 | # Product
12 | redis.mq.server=192.168.32.20
13 | # Testing
14 | #redis.mq.server=192.168.31.XX
15 |
16 | ##### Expired-Queue (For Firsttime Caching) #####
17 | # Product
18 | redis.ft.server=192.168.32.18
19 | # Testing
20 | #redis.ft.server=192.168.31.XX
21 |
22 | ##### Port #####
23 | redis.rp.port=16379
24 | redis.mq.port=6379
25 | redis.ft.port=6379
26 |
27 | ##### Password #####
28 | redis.password=zxsoft
29 |
30 | ## Batch Count to Solr
31 | batch.count=10000
--------------------------------------------------------------------------------
/sentiment-solr/src/main/resources/cate_dict/negative_bc:
--------------------------------------------------------------------------------
1 | 造谣窒息事故暴行毁容致死诬陷猥亵砍人诈骗案反动被害逃逸违法罪犯刺死爆炸物施暴开枪迷幻药毒手炸通缉令砍伤毒打砍杀辱骂偷窃窒息而死违法行为灭口杀灭非法滋事下毒手交警刑事案件贪污腐败恐怖行动伸冤害人强奸淫秽强暴炸药事件起火毒死跳楼尸体恶毒暴打变态新疆人毒害受害人草菅人命威吓通缉侵占霸占打架斗殴砸死报案恶名拆迁房死了假释暴力冤枉灾区嫌疑人暴动腐败分子禁毒仇恨死亡淫笑恐怖主义撞死死人侵害犯罪猥亵作乱审判打劫得罪奸商强拆淫荡申冤虐杀放火勒死追捕刑拘焚烧报复骚扰杀人狂流血暴卒刑事拘留逃犯毒品虐待反腐败冤假冤案歹徒惨杀纵火案纵火瘟疫诈骗罪恩仇世仇奸淫死打死大爆炸骗子行窃禽流感心狠手辣投毒暴民毒行骗出事妖言惑众草芥人命死者流感伤亡分赃杀人犯厌世凶杀判决戒毒陷害包庇潜逃举报杀死作案工具尸抢劫行政拘留肇事者自焚性侵作案贪污杀害残暴谋杀扣押监禁粗暴砍死兽性大发获刑糟蹋身亡医疗事故拘留所报警交通事故内乱出血拘留炸弹肢解赃物毒杀残忍拆迁恐吓侮辱网警举报人监狱行贿吸毒毒性病毒越狱杀人罪堕落车祸噩耗打人扫毒逼供洗脑色狼威胁寻死肇事藏独警备区逃亡流氓炸裂冲突骗人下毒色魔镇压暴徒非法拘禁恐怖分子禽兽惨死烧毁乱砍突发事件轮奸骂我诈骗贿赂受贿恐怖袭击假币假钱假钞闹事制服冰毒擒获抢劫罪偷盗被盗失窃纠纷女尸失踪线索涉嫌色情持刀抓获归案同案赃款被害人击毙击伤搜查围捕血案圣战爆炸声爆炸枪走私涉枪涉赌绑架寻衅枪支子弹枪弹举报线索上当骗走被骗谎称受骗骗取被打因涉嫌故意伤害案发后
--------------------------------------------------------------------------------
/sentiment-solr/src/main/resources/data_db.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### Database #####
3 | # Product
4 | sent.db.url=jdbc:mysql://192.168.32.17:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
5 | # Testing
6 | #sent.db.url=jdbc:mysql://192.168.31.23:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
7 | #sent.db.url=jdbc:mysql://192.168.31.23:3306/sentiment_oa?useUnicode=true&characterEncoding=utf-8
8 |
9 | ##### Password #####
10 | sent.db.username=sentimentrecords
11 | sent.db.password=zn/iACQ/Xh19+W6Ot2MghQ==
12 |
13 | ##### Localhost #####
14 | #sent.db.url=jdbc:mysql://localhost:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
15 | #sent.db.username=root
16 | #sent.db.password=root
--------------------------------------------------------------------------------
/sentiment-solr/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %d{ISO8601} [%thread] %-5level %logger{36} [Line:%-3L] - %msg%n
8 |
9 |
10 |
11 | INFO
12 | ACCEPT
13 | DENY
14 |
15 |
16 |
17 |
19 | logs/sentiment-solr.log
20 |
21 | %d{ISO8601} [%thread] %-5level %logger{36} [Line:%-3L] - %msg%n
22 |
23 |
24 |
25 | INFO
26 |
27 |
28 | logs/sentiment-solr.log.%d{yyyy-MM-dd}.gz
29 | 30
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
--------------------------------------------------------------------------------
/sentiment-solr/src/main/resources/oracle_db.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### Product #####
3 | ## HuaiNan 192.168.32.200
4 | ## Shengting 192.168.32.36
5 | db_url=jdbc:oracle:thin:@192.168.32.36:1521:yqjk
6 | ##### Testing #####
7 | #db_url=jdbc:oracle:thin:@192.168.31.22:1521:yqjk
8 | db_username=yqjk
9 | db_password=yqjk#olap#2014
--------------------------------------------------------------------------------
/sentiment-solr/src/main/resources/solr_params.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### SolrCloud #####
3 | collection=sentiment
4 | zookeeper_connect_timeout=50000
5 | zookeeper_client_timeout=50000
6 | #zookeeper_cloud=leader:2181
7 | # Product
8 | zookeeper_cloud=192.168.32.11:2181,192.168.32.12:2181,192.168.32.13:2181,192.168.32.14:2181,192.168.32.15:2181,192.168.32.16:2181
9 | # Testing
10 | #zookeeper_cloud=192.168.31.11:2181,192.168.31.12:2181,192.168.31.20:2181,192.168.31.21:2181,192.168.31.26:2181,192.168.31.27:2181
11 |
12 | ##### Fetch Size #####
13 | fetch_size=20000
--------------------------------------------------------------------------------
/sentiment-solr/src/test/java/zx/soft/sent/solr/search/FacetSearchTest.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.solr.search;
2 |
3 | import static org.junit.Assert.assertEquals;
4 |
5 | import org.junit.Test;
6 |
7 | import zx.soft.sent.solr.domain.FacetDateParams;
8 | import zx.soft.sent.solr.query.FacetSearch;
9 |
10 | public class FacetSearchTest {
11 |
12 | @Test
13 | public void testGetURL() {
14 | FacetDateParams fdp = new FacetDateParams();
15 | fdp.setQ("*:*");
16 | fdp.setFacetDate("timestamp");
17 | fdp.setFacetDateStart("NOW-7DAYS");
18 | fdp.setFacetDateEnd("NOW");
19 | fdp.setFacetDateGap("%2B1DAY");
20 | assertEquals("http://192.168.32.11:8983/solr/sentiment/select?wt=json&indent=true&facet=true&rows=0&q=*:*&"
21 | + "q.op=AND&facet.date=timestamp&facet.date.start=NOW-7DAYS&facet.date.end=NOW&facet.date.gap=%2B1DAY",
22 | FacetSearch.getURL(fdp));
23 | }
24 |
25 | }
26 |
--------------------------------------------------------------------------------
/sentiment-solr/src/test/java/zx/soft/sent/solr/search/SearchingDataTest.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.solr.search;
2 |
3 | import static org.junit.Assert.assertEquals;
4 |
5 | import org.junit.Test;
6 |
7 | import zx.soft.sent.solr.query.QueryCore;
8 |
9 | public class SearchingDataTest {
10 |
11 | @Test
12 | public void testTransFq() {
13 |
14 | String fqs = QueryCore.transFq("nickname:罗永浩;content:锤子");
15 | assertEquals(fqs, "nickname:罗永浩;content:锤子");
16 |
17 | fqs = QueryCore.transFq("nickname:罗永浩;-content:锤子");
18 | assertEquals(fqs, "nickname:罗永浩;-content:锤子");
19 |
20 | fqs = QueryCore.transFq("nickname:罗永浩,北京");
21 | assertEquals(fqs, "nickname:罗永浩 OR nickname:北京");
22 |
23 | fqs = QueryCore.transFq("-content:锤子,手机");
24 | assertEquals(fqs, "-content:锤子 AND -content:手机");
25 |
26 | fqs = QueryCore.transFq("a:b,c,d");
27 | assertEquals(fqs, "a:b OR a:c OR a:d");
28 |
29 | fqs = QueryCore.transFq("-a:b,c,d");
30 | assertEquals(fqs, "-a:b AND -a:c AND -a:d");
31 |
32 | fqs = QueryCore.transFq("timestamp:[2014-4-22T13:39:26Z TO 2014-4-29T13:39:26Z]");
33 | assertEquals(fqs, "timestamp:[2014-4-22T13:39:26Z TO 2014-4-29T13:39:26Z]");
34 |
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/sentiment-solr/src/test/java/zx/soft/sent/solr/utils/RedisCacheExpiredTest.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.solr.utils;
2 |
3 | import org.junit.Ignore;
4 |
5 | public class RedisCacheExpiredTest {
6 |
7 | @Ignore
8 | public void testExpired() {
9 | RedisCacheExpired pool = new RedisCacheExpired(60);
10 | for (int i = 0; i < 30; i++) {
11 | pool.addRecord("test" + i, i + "");
12 | try {
13 | Thread.sleep(1_000);
14 | } catch (InterruptedException e) {
15 | e.printStackTrace();
16 | }
17 | }
18 |
19 | pool.close();
20 | }
21 |
22 | }
23 |
--------------------------------------------------------------------------------
/sentiment-solr/src/test/resources/cache-config.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### Mater-Slave (For Replicating Record-Key) #####
3 | # Product
4 | #redis.rp.master=192.168.32.19
5 | #redis.rp.slave=192.168.32.20
6 | # Testing
7 | redis.rp.master=192.168.31.20
8 | redis.rp.slave=192.168.31.21
9 |
10 | ##### Message-Queue (for Index-Data and Firsttime Caching) #####
11 | # Product
12 | #redis.mq.server=192.168.32.18
13 | # Testing
14 | redis.mq.server=192.168.31.12
15 |
16 | ##### Port #####
17 | redis.rp.port=16379
18 | redis.mq.port=6379
19 |
20 | ##### Password #####
21 | redis.password=zxsoft
--------------------------------------------------------------------------------
/sentiment-solr/src/test/resources/data_db.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### Database #####
3 | # Product
4 | #sent.db.url=jdbc:mysql://192.168.32.17:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
5 | # Testing
6 | sent.db.url=jdbc:mysql://192.168.31.23:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
7 |
8 | ##### Password #####
9 | sent.db.username=sentimentrecords
10 | sent.db.password=zn/iACQ/Xh19+W6Ot2MghQ==
11 |
12 | ##### Localhost #####
13 | #sent.db.url=jdbc:mysql://localhost:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
14 | #sent.db.username=root
15 | #sent.db.password=root
--------------------------------------------------------------------------------
/sentiment-solr/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %d{MMdd.HHmmss.SSS} [%-20t] [%-5p] [%-20c] [L:%-3L] - %m%n
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sentiment-solr/src/test/resources/solr_params.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### SolrCloud #####
3 | collection=sentiment
4 | zookeeper_connect_timeout=50000
5 | zookeeper_client_timeout=50000
6 | #zookeeper_cloud=leader:2181
7 | # Product
8 | #zookeeper_cloud=192.168.32.11:2181,192.168.32.12:2181,192.168.32.13:2181,192.168.32.14:2181,192.168.32.15:2181,192.168.32.16:2181
9 | # Testing
10 | zookeeper_cloud=192.168.31.11:2181,192.168.31.12:2181,192.168.31.20:2181,192.168.31.21:2181,192.168.31.26:2181,192.168.31.27:2181
11 |
12 | ##### Fetch Size #####
13 | fetch_size=20000
--------------------------------------------------------------------------------
/sentiment-solr/src/test/resources/weibo/WBLR1:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 一个连街头小偷都不敢呵斥的民族,却有勇气高呼灭了小日本;一个连活着的人都漠不关心的民族,却让我们不要忘记死去的人;一个连农民的生死都置之不理的国度,却说现在是和谐社会……
5 |
6 | 搜狐新闻|
辽宁抚顺洪灾63人遇难 今日全市哀悼(图)(13108人参与)
7 |
--------------------------------------------------------------------------------
/sentiment-solr/src/test/resources/weibo/WBLR2:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 好吧,我们知道了。
5 |
6 | 搜狐新闻|
辽宁抚顺洪灾63人遇难 今日全市哀悼(图)(13107人参与)
7 |
--------------------------------------------------------------------------------
/sentiment-solr/src/test/resources/weibo/WBLR3:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | 【辽宁抚顺洪灾死亡人数达76人】失踪101人找到13人,全部遇难;目前仍有88人失踪。 http://t.itc.cn/mjaGW @搜狐新闻客户端
6 |
7 |
8 |
--------------------------------------------------------------------------------
/sentiment-solr/src/test/resources/weibo/WBLR4:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 | 以前比较相信网络,现在也不敢了,哀哉!
5 |
6 | 搜狐新闻|
辽宁抚顺洪灾63人遇难 今日全市哀悼(图)(11110人参与)
7 |
8 |
--------------------------------------------------------------------------------
/sentiment-spider/README.md:
--------------------------------------------------------------------------------
1 |
2 | ## 使用说明
3 |
4 | ### 使用域名
5 |
6 | > api.weibo.com:80
7 |
8 | ### 使用IP
9 |
10 | > 180.149.135.176:80
11 |
12 | > 180.149.135.230:80
--------------------------------------------------------------------------------
/sentiment-spider/proxy/proxy-ips.txt:
--------------------------------------------------------------------------------
1 | 219.93.178.162:3128
2 | 219.93.178.162:3128
3 | 219.93.178.162:3128
4 | 219.93.178.162:3128
--------------------------------------------------------------------------------
/sentiment-spider/src/main/assembly/distribution.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | distribution
7 |
8 | tar.gz
9 |
10 | ${project.artifactId}
11 |
12 |
13 | src/main/resources
14 |
15 | cache-config.properties
16 | super.properties
17 | sina-api.properties
18 | logback.xml
19 |
20 | /conf
21 | true
22 |
23 |
24 | src/main/bin
25 |
26 | *
27 |
28 | /bin
29 | 0755
30 |
31 |
32 |
33 |
34 | /lib
35 |
36 |
37 |
--------------------------------------------------------------------------------
/sentiment-spider/src/main/bin/ctl.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | mainClass=zx.soft.sent.spider.driver.SpiderDriver
4 |
5 | # resolve links - $0 may be a softlink
6 | PRG="$0"
7 |
8 | while [ -h "$PRG" ]; do
9 | ls=`ls -ld "$PRG"`
10 | link=`expr "$ls" : '.*-> \(.*\)$'`
11 | if expr "$link" : '/.*' > /dev/null; then
12 | PRG="$link"
13 | else
14 | PRG=`dirname "$PRG"`/"$link"
15 | fi
16 | done
17 |
18 | # Get standard environment variables
19 | PRGDIR=`dirname "$PRG"`
20 |
21 | PROJECT_DIR=`cd "$PRGDIR/.." >/dev/null; pwd`
22 | echo PROJECT_DIR=$PROJECT_DIR
23 |
24 | CLASSPATH="$CLASSHPATH:$PROJECT_DIR/conf"
25 |
26 | for jar in "$PROJECT_DIR/lib"/*.jar; do
27 | CLASSPATH="$CLASSPATH:$jar"
28 | done
29 | echo CLASSPATH=$CLASSPATH
30 |
31 | JVMARGS="${JVMARGS} -Dproject_dir=${PROJECT_DIR} -Djava.net.preferIPv4Stack=true"
32 | echo JVMARGS=$JVMARGS
33 |
34 | usage() {
35 | echo >&2 "usage: $PRG [args]"
36 | echo 'Valid commands: start, stop'
37 | exit 1
38 | }
39 |
40 | start() {
41 | JAVA=${JAVA-'java'}
42 | exec $JAVA $JVMARGS -classpath "$CLASSPATH" $mainClass "$@" &
43 | echo $! > main.pid
44 | }
45 |
46 | stop() {
47 | kill `cat main.pid` > /dev/null
48 | }
49 |
50 | case $1 in
51 | (start)
52 | shift
53 | start $@
54 | ;;
55 | (stop)
56 | stop
57 | ;;
58 | (restart)
59 | stop
60 | shift
61 | start $@
62 | ;;
63 | (*)
64 | echo >&2 "$PRG: error: unknown command '$1'"
65 | usage
66 | ;;
67 | esac
68 |
--------------------------------------------------------------------------------
/sentiment-spider/src/main/bin/timer_spider.sh:
--------------------------------------------------------------------------------
1 | # !/bin/bash
2 |
3 | echo "Starting ..."
4 |
5 | bin/ctl.sh start sinaPublicWeibosSpider
6 |
7 | while (true)
8 | do
9 | sleep 30m
10 | bin/ctl.sh restart sinaPublicWeibosSpider
11 | done
12 |
13 | echo "Finishing ..."
14 |
--------------------------------------------------------------------------------
/sentiment-spider/src/main/java/zx/soft/sent/spider/dns/CacheDNS.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spider.dns;
2 |
3 | import java.net.InetAddress;
4 | import java.net.UnknownHostException;
5 |
6 | /**
7 | * DNS缓存处理
8 | *
9 | * @author wanggang
10 | *
11 | */
12 | public class CacheDNS {
13 |
14 | public static void main(String[] args) throws UnknownHostException {
15 | InetAddress[] ips = InetAddress.getAllByName("www.baidu.com");
16 | for (InetAddress ip : ips) {
17 | System.out.println(ip);
18 | }
19 | }
20 |
21 | }
22 |
--------------------------------------------------------------------------------
/sentiment-spider/src/main/java/zx/soft/sent/spider/driver/SpiderDriver.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spider.driver;
2 |
3 | import zx.soft.sent.spider.sina.SinaPublicWeibosSpider;
4 | import zx.soft.utils.driver.ProgramDriver;
5 |
6 | /**
7 | * 驱动类
8 | *
9 | * @author wanggang
10 | *
11 | */
12 | public class SpiderDriver {
13 |
14 | /**
15 | * 主函数
16 | */
17 | public static void main(String[] args) {
18 |
19 | int exitCode = -1;
20 | ProgramDriver pgd = new ProgramDriver();
21 | try {
22 | // 运行在hefei05机器上
23 | pgd.addClass("sinaPublicWeibosSpider", SinaPublicWeibosSpider.class, "新浪公共微博抓取");
24 | pgd.driver(args);
25 | // Success
26 | exitCode = 0;
27 | } catch (Throwable e) {
28 | throw new RuntimeException(e);
29 | }
30 |
31 | System.exit(exitCode);
32 |
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/sentiment-spider/src/main/java/zx/soft/sent/spider/http/SpiderHttpURLConnection.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spider.http;
2 |
3 | import java.io.IOException;
4 | import java.net.HttpURLConnection;
5 | import java.net.URL;
6 | import java.util.Iterator;
7 | import java.util.List;
8 | import java.util.Map;
9 |
10 | /**
11 | * getContentType等方法的错误指出在于只识别头信息中小写的字符串,需要修改成大小写不敏感。
12 | *
13 | * @author wanggang
14 | *
15 | */
16 | public class SpiderHttpURLConnection extends HttpURLConnection {
17 |
18 | protected SpiderHttpURLConnection(URL u) {
19 | super(u);
20 | // TODO Auto-generated constructor stub
21 | }
22 |
23 | @Override
24 | public String getHeaderField(String fieldKey) {
25 | Map> header = getHeaderFields();
26 | Iterator iter = header.keySet().iterator();
27 | String key = null;
28 | while (iter.hasNext()) {
29 | key = iter.next();
30 | if (key == null) {
31 | if (fieldKey == null) {
32 | return (String) ((List>) (header.get(null))).get(0);
33 | }
34 | } else {
35 | if (key.equalsIgnoreCase(fieldKey)) {
36 | return (String) ((List>) (header.get(key))).get(0);
37 | }
38 | }
39 | }
40 | return null;
41 | }
42 |
43 | @Override
44 | public void disconnect() {
45 | // TODO Auto-generated method stub
46 | }
47 |
48 | @Override
49 | public boolean usingProxy() {
50 | // TODO Auto-generated method stub
51 | return false;
52 | }
53 |
54 | @Override
55 | public void connect() throws IOException {
56 | // TODO Auto-generated method stub
57 | }
58 |
59 | }
60 |
--------------------------------------------------------------------------------
/sentiment-spider/src/main/java/zx/soft/sent/spider/proxy/SocketProxy.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spider.proxy;
2 |
3 | import java.net.InetSocketAddress;
4 | import java.net.Proxy;
5 | import java.net.SocketAddress;
6 | import java.util.List;
7 | import java.util.Random;
8 |
9 | import org.slf4j.Logger;
10 | import org.slf4j.LoggerFactory;
11 |
12 | import zx.soft.sent.spider.utils.DataReader;
13 |
14 | /**
15 | * Socket代理设置
16 | *
17 | * @author wanggang
18 | *
19 | */
20 | public class SocketProxy {
21 |
22 | private static Logger logger = LoggerFactory.getLogger(SocketProxy.class);
23 |
24 | private static List proxyList;
25 |
26 | private static final Random RANDOM = new Random();
27 |
28 | static {
29 | proxyList = DataReader.getProxyIPs("proxy/proxy-ips.txt");
30 | logger.info("Loading proxy ips successful!");
31 | }
32 |
33 | public static Proxy getProxy() {
34 | String ip = proxyList.get(RANDOM.nextInt(proxyList.size()));
35 | String[] ipAndPort = ip.split(":");
36 | if (ipAndPort.length == 2) {
37 | SocketAddress socketAddress = new InetSocketAddress(ipAndPort[0], Integer.parseInt(ipAndPort[1]));
38 | return new Proxy(Proxy.Type.HTTP, socketAddress);
39 | }
40 | return null;
41 | }
42 |
43 | }
44 |
--------------------------------------------------------------------------------
/sentiment-spider/src/main/java/zx/soft/sent/spider/utils/DataReader.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spider.utils;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.File;
5 | import java.io.FileNotFoundException;
6 | import java.io.FileReader;
7 | import java.io.IOException;
8 | import java.util.ArrayList;
9 | import java.util.List;
10 |
11 | import org.slf4j.Logger;
12 | import org.slf4j.LoggerFactory;
13 |
14 | import zx.soft.utils.log.LogbackUtil;
15 |
16 | /**
17 | * 代理数据读取
18 | *
19 | * @author wanggang
20 | *
21 | */
22 | public class DataReader {
23 |
24 | private static Logger logger = LoggerFactory.getLogger(DataReader.class);
25 |
26 | public static void main(String[] args) {
27 | List proxy = DataReader.getProxyIPs("proxy/proxy-ips.txt");
28 | for (String ip : proxy) {
29 | System.out.println(ip);
30 | }
31 | }
32 |
33 | public static List getProxyIPs(String file) {
34 | List result = new ArrayList<>();
35 | try (BufferedReader br = new BufferedReader(new FileReader(new File(file)));) {
36 | String str;
37 | while ((str = br.readLine()) != null) {
38 | result.add(str);
39 | }
40 | return result;
41 | } catch (FileNotFoundException e) {
42 | logger.error("Exception:{}", LogbackUtil.expection2Str(e));
43 | throw new RuntimeException(e);
44 | } catch (IOException e) {
45 | logger.error("Exception:{}", LogbackUtil.expection2Str(e));
46 | throw new RuntimeException(e);
47 | }
48 | }
49 |
50 | }
51 |
--------------------------------------------------------------------------------
/sentiment-spider/src/main/resources/Sentiment-Data/GAB_ZIP_INDEX.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 |
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
27 |
28 |
29 |
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
--------------------------------------------------------------------------------
/sentiment-spider/src/main/resources/cache-config.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### Mater-Slave (For Replicating Record-Key,Index-Data Caching) #####
3 | # Product
4 | redis.rp.master=192.168.32.19
5 | redis.rp.slave=192.168.32.20
6 | # Testing
7 | #redis.rp.master=192.168.31.20
8 | #redis.rp.slave=192.168.31.21
9 |
10 | ##### Message-Queue (For Index-Data Caching) #####
11 | # Product
12 | redis.mq.server=192.168.32.20
13 | # Testing
14 | #redis.mq.server=192.168.31.XX
15 |
16 | ##### Expired-Queue (For Firsttime Caching) #####
17 | # Product
18 | redis.ft.server=192.168.32.18
19 | # Testing
20 | #redis.ft.server=192.168.31.XX
21 |
22 | ##### Port #####
23 | redis.rp.port=16379
24 | redis.mq.port=6379
25 | redis.ft.port=6379
26 |
27 | ##### Password #####
28 | redis.password=zxsoft
--------------------------------------------------------------------------------
/sentiment-spider/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %d{ISO8601} [%thread] %-5level %logger{36} [Line:%-3L] - %msg%n
8 |
9 |
10 |
11 | INFO
12 | ACCEPT
13 | DENY
14 |
15 |
16 |
17 |
19 | logs/sentiment-spider.log
20 |
21 | %d{ISO8601} [%thread] %-5level %logger{36} [Line:%-3L] - %msg%n
22 |
23 |
24 |
25 | INFO
26 |
27 |
28 | logs/sentiment-spider.log.%d{yyyy-MM-dd}.gz
29 | 30
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
--------------------------------------------------------------------------------
/sentiment-spider/src/main/resources/sina-api.properties:
--------------------------------------------------------------------------------
1 |
2 | ## IP
3 | # api.weibo.com:80
4 | # 180.149.135.176
5 | # 180.149.135.230
6 | sina.api.proxy.ip=180.149.135.176:80
--------------------------------------------------------------------------------
/sentiment-spider/src/main/resources/super.properties:
--------------------------------------------------------------------------------
1 |
2 | # super info
3 | super=
--------------------------------------------------------------------------------
/sentiment-spider/src/test/java/zx/soft/sent/spider/dns/CacheDNSTest.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spider.dns;
2 |
3 | import org.junit.Test;
4 |
5 | public class CacheDNSTest {
6 |
7 | @Test
8 | public void test() {
9 | System.out.println("Not yet implemented");
10 | }
11 |
12 | }
13 |
--------------------------------------------------------------------------------
/sentiment-spider/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %d{MMdd.HHmmss.SSS} [%-20t] [%-5p] [%-20c] [L:%-3L] - %m%n
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sentiment-spring/README.md:
--------------------------------------------------------------------------------
1 |
2 | ## 注意事项
3 |
4 | > 该接口运行长时间运行会出现连接释放不了问题,猜测应该是Redis层使用不当造成的,目前的解决方法是定时重启该接口。
5 |
6 | > 长时间运行后,curl测试该接口时出现如下错误:
7 |
8 | ```
9 | curl: (56) Recv failure: Connection reset by peer
10 | ```
--------------------------------------------------------------------------------
/sentiment-spring/ik_dic/ext_ik.dic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wgybzbrobot/sentiment-search/df50eef8f82fbdc4549d1cfffb0d0b393a04f7b5/sentiment-spring/ik_dic/ext_ik.dic
--------------------------------------------------------------------------------
/sentiment-spring/ik_dic/stopwords_ik.dic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wgybzbrobot/sentiment-search/df50eef8f82fbdc4549d1cfffb0d0b393a04f7b5/sentiment-spring/ik_dic/stopwords_ik.dic
--------------------------------------------------------------------------------
/sentiment-spring/src/main/assembly/distribution.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | distribution
7 |
8 | tar.gz
9 |
10 | ${project.artifactId}
11 |
12 |
13 | src/main/resources
14 |
15 | logback.xml
16 | cache-config.properties
17 | data_db.properties
18 | solr_params.properties
19 | web-server.properties
20 |
21 | /conf
22 | true
23 |
24 |
25 | ik_dic
26 |
27 | *
28 |
29 | /ik_dic
30 |
31 |
32 | src/main/bin
33 |
34 | *
35 |
36 | /bin
37 | 0755
38 |
39 |
40 |
41 |
42 | /lib
43 |
44 |
45 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/bin/ctl.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | mainClass=zx.soft.sent.spring.driver.SentimentSpringDriver
4 |
5 | # resolve links - $0 may be a softlink
6 | PRG="$0"
7 |
8 | while [ -h "$PRG" ]; do
9 | ls=`ls -ld "$PRG"`
10 | link=`expr "$ls" : '.*-> \(.*\)$'`
11 | if expr "$link" : '/.*' > /dev/null; then
12 | PRG="$link"
13 | else
14 | PRG=`dirname "$PRG"`/"$link"
15 | fi
16 | done
17 |
18 | # Get standard environment variables
19 | PRGDIR=`dirname "$PRG"`
20 |
21 | PROJECT_DIR=`cd "$PRGDIR/.." >/dev/null; pwd`
22 | echo PROJECT_DIR=$PROJECT_DIR
23 |
24 | CLASSPATH="$CLASSHPATH:$PROJECT_DIR/conf"
25 |
26 | for jar in "$PROJECT_DIR/lib"/*.jar; do
27 | CLASSPATH="$CLASSPATH:$jar"
28 | done
29 | echo CLASSPATH=$CLASSPATH
30 |
31 | JVMARGS="${JVMARGS} -Dproject_dir=${PROJECT_DIR}"
32 | echo JVMARGS=$JVMARGS
33 |
34 | usage() {
35 | echo >&2 "usage: $PRG [args]"
36 | echo 'Valid commands: start, stop'
37 | exit 1
38 | }
39 |
40 | start() {
41 | JAVA=${JAVA-'java'}
42 | exec $JAVA $JVMARGS -classpath "$CLASSPATH" $mainClass "$@" &
43 | echo $! > main.pid
44 | }
45 |
46 | stop() {
47 | kill `cat main.pid` > /dev/null
48 | }
49 |
50 | case $1 in
51 | (start)
52 | shift
53 | start $@
54 | ;;
55 | (stop)
56 | stop
57 | ;;
58 | (restart)
59 | stop
60 | shift
61 | start $@
62 | ;;
63 | (*)
64 | echo >&2 "$PRG: error: unknown command '$1'"
65 | usage
66 | ;;
67 | esac
68 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/bin/timer-index.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "Starting ..."
4 |
5 | bin/ctl.sh start indexApiServer
6 |
7 | while (true)
8 | do
9 | sleep 30m
10 | bin/ctl.sh restart indexApiServer
11 | done
12 |
13 | echo "Finishing ..."
14 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/java/zx/soft/sent/spring/controller/IndexController.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spring.controller;
2 |
3 | import javax.inject.Inject;
4 |
5 | import org.springframework.http.HttpStatus;
6 | import org.springframework.stereotype.Controller;
7 | import org.springframework.web.bind.annotation.RequestBody;
8 | import org.springframework.web.bind.annotation.RequestMapping;
9 | import org.springframework.web.bind.annotation.RequestMethod;
10 | import org.springframework.web.bind.annotation.ResponseBody;
11 | import org.springframework.web.bind.annotation.ResponseStatus;
12 |
13 | import zx.soft.sent.spring.domain.ErrorResponse;
14 | import zx.soft.sent.spring.domain.PostData;
15 | import zx.soft.sent.spring.service.IndexService;
16 |
17 | /**
18 | * 索引控制类
19 | *
20 | * @author wanggang
21 | *
22 | */
23 | @Controller
24 | @RequestMapping("/sentiment/index")
25 | public class IndexController {
26 |
27 | @Inject
28 | private IndexService indexService;
29 |
30 | @RequestMapping(method = RequestMethod.POST)
31 | @ResponseStatus(HttpStatus.CREATED)
32 | public @ResponseBody
33 | ErrorResponse add(@RequestBody PostData postData) {
34 | return indexService.addIndexData(postData);
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/java/zx/soft/sent/spring/domain/ErrorResponse.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spring.domain;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 错误相应类
7 | *
8 | * @author wanggang
9 | *
10 | */
11 | public class ErrorResponse implements Serializable {
12 |
13 | private static final long serialVersionUID = -3408598774435409654L;
14 |
15 | private final int errorCode;
16 | private final String errorMessage;
17 |
18 | public ErrorResponse(Builder builder) {
19 | this.errorCode = builder.errorCode;
20 | this.errorMessage = builder.errorMessage;
21 | }
22 |
23 | public static class Builder {
24 |
25 | private final int errorCode;
26 | private final String errorMessage;
27 |
28 | public Builder(int errorCode, String errorMessage) {
29 | super();
30 | this.errorCode = errorCode;
31 | this.errorMessage = errorMessage;
32 | }
33 |
34 | public ErrorResponse build() {
35 | return new ErrorResponse(this);
36 | }
37 |
38 | }
39 |
40 | public int getErrorCode() {
41 | return errorCode;
42 | }
43 |
44 | public String getErrorMessage() {
45 | return errorMessage;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/java/zx/soft/sent/spring/domain/IndexErrResponse.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spring.domain;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import zx.soft.utils.json.JsonUtils;
8 |
9 | public class IndexErrResponse implements Serializable {
10 |
11 | private static final long serialVersionUID = -5183178204181065266L;
12 |
13 | private int errorCode;
14 | private List errorMessage;
15 |
16 | public IndexErrResponse(int errorCode, List errorMessage) {
17 | this.errorCode = errorCode;
18 | this.errorMessage = errorMessage;
19 | }
20 |
21 | public int getErrorCode() {
22 | return errorCode;
23 | }
24 |
25 | public void setErrorCode(int errorCode) {
26 | this.errorCode = errorCode;
27 | }
28 |
29 | public List getErrorMessage() {
30 | return errorMessage;
31 | }
32 |
33 | public void setErrorMessage(List errorMessage) {
34 | this.errorMessage = errorMessage;
35 | }
36 |
37 | public static void main(String[] args) {
38 | List errorMessage = new ArrayList<>();
39 | errorMessage.add("wwfffrrrrr");
40 | errorMessage.add("1233jjffioo");
41 | IndexErrResponse err = new IndexErrResponse(-1, errorMessage);
42 | System.out.println(JsonUtils.toJson(err));
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/java/zx/soft/sent/spring/domain/PostData.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spring.domain;
2 |
3 | import java.io.Serializable;
4 | import java.util.List;
5 |
6 | import zx.soft.sent.dao.domain.platform.RecordInfo;
7 |
8 | /**
9 | * POST的索引数据
10 | *
11 | * @author wanggang
12 | *
13 | */
14 | public class PostData implements Serializable {
15 |
16 | private static final long serialVersionUID = 3183580989697121542L;
17 |
18 | private int num;
19 | private List records;
20 |
21 | public int getNum() {
22 | return num;
23 | }
24 |
25 | public void setNum(int num) {
26 | this.num = num;
27 | }
28 |
29 | public List getRecords() {
30 | return records;
31 | }
32 |
33 | public void setRecords(List records) {
34 | this.records = records;
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/java/zx/soft/sent/spring/driver/SentimentSpringDriver.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spring.driver;
2 |
3 | import zx.soft.sent.spring.server.IndexApiServer;
4 | import zx.soft.utils.driver.ProgramDriver;
5 |
6 | /**
7 | * 驱动类
8 | *
9 | * @author wanggang
10 | *
11 | */
12 | public class SentimentSpringDriver {
13 |
14 | /**
15 | * 主函数
16 | */
17 | public static void main(String[] args) {
18 |
19 | int exitCode = -1;
20 | ProgramDriver pgd = new ProgramDriver();
21 | try {
22 | // 运行在hefei01~hefei06,hefei08~hefei10机器上
23 | // 测试环境:hefei11:192.168.31.11 目录:/home/solr/run-work/api/index 端口:8900
24 | pgd.addClass("indexApiServer", IndexApiServer.class, "舆情数据索引接口");
25 | pgd.driver(args);
26 | // Success
27 | exitCode = 0;
28 | } catch (Throwable e) {
29 | throw new RuntimeException(e);
30 | }
31 |
32 | System.exit(exitCode);
33 |
34 | }
35 |
36 | }
37 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/java/zx/soft/sent/spring/utils/CustomObjectMapper.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spring.utils;
2 |
3 | import java.text.DateFormat;
4 | import java.text.ParseException;
5 | import java.text.SimpleDateFormat;
6 | import java.util.Date;
7 | import java.util.Locale;
8 |
9 | import com.fasterxml.jackson.databind.ObjectMapper;
10 |
11 | /**
12 | * 自定义的ObjectMapper类,用于处理时间格式
13 | *
14 | * @author wanggang
15 | *
16 | */
17 | public class CustomObjectMapper extends ObjectMapper {
18 |
19 | private static final long serialVersionUID = -3341366863221844412L;
20 |
21 | public static DateFormat sinaDateFormat = new SimpleDateFormat("yyyy-MM-dd'T'HH:mm:ss", Locale.ENGLISH);
22 |
23 | public CustomObjectMapper() {
24 | super();
25 | setDateFormat(sinaDateFormat);
26 | }
27 |
28 | /**
29 | * 测试函数
30 | */
31 | public static void main(String[] args) throws ParseException {
32 | System.out.println(sinaDateFormat.format(new Date()));
33 | }
34 |
35 | }
36 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/java/zx/soft/sent/spring/utils/Demo.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.spring.utils;
2 |
3 | import zx.soft.sent.dao.sql.CreateTables;
4 | import zx.soft.utils.checksum.CheckSumUtils;
5 |
6 | public class Demo {
7 |
8 | public static void main(String[] args) {
9 |
10 | System.out
11 | .println(CreateTables.SENT_TABLE + CheckSumUtils.getCRC32("sentiment79") % CreateTables.MAX_TABLE_NUM);
12 | }
13 |
14 | }
15 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/resources/cache-config.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### Mater-Slave (For Replicating Record-Key,Index-Data Caching) #####
3 | # Product
4 | redis.rp.master=192.168.32.19
5 | redis.rp.slave=192.168.32.20
6 | # Testing
7 | #redis.rp.master=192.168.31.20
8 | #redis.rp.slave=192.168.31.21
9 |
10 | ##### Message-Queue (For Index-Data Caching) #####
11 | # Product
12 | redis.mq.server=192.168.32.20
13 | # Testing
14 | #redis.mq.server=192.168.31.XX
15 |
16 | ##### Expired-Queue (For Firsttime Caching) #####
17 | # Product
18 | redis.ft.server=192.168.32.18
19 | # Testing
20 | #redis.ft.server=192.168.31.XX
21 |
22 | ##### Port #####
23 | redis.rp.port=16379
24 | redis.mq.port=6379
25 | redis.ft.port=6379
26 |
27 | ##### Password #####
28 | redis.password=zxsoft
--------------------------------------------------------------------------------
/sentiment-spring/src/main/resources/data_db.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### Database #####
3 | # Product
4 | # OA
5 | #sent.db.url=jdbc:mysql://192.168.32.17:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
6 | # Records
7 | sent.db.url=jdbc:mysql://192.168.32.18:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
8 | # Testing
9 | #sent.db.url=jdbc:mysql://192.168.31.23:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
10 |
11 | ##### Password #####
12 | sent.db.username=sentimentrecords
13 | sent.db.password=zn/iACQ/Xh19+W6Ot2MghQ==
14 |
15 | ##### Localhost #####
16 | #sent.db.url=jdbc:mysql://localhost:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
17 | #sent.db.username=root
18 | #sent.db.password=root
--------------------------------------------------------------------------------
/sentiment-spring/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %d{ISO8601} [%thread] %-5level %logger{36} [Line:%-3L] - %msg%n
8 |
9 |
10 |
11 | INFO
12 | ACCEPT
13 | DENY
14 |
15 |
16 |
17 |
19 | logs/sentiment-spring.log
20 |
21 | %d{ISO8601} [%thread] %-5level %logger{36} [Line:%-3L] - %msg%n
22 |
23 |
24 |
25 | INFO
26 |
27 |
28 | logs/sentiment-spring.log.%d{yyyy-MM-dd}.gz
29 | 30
30 |
31 |
32 |
33 |
34 |
35 |
36 |
37 |
38 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/resources/solr_params.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### SolrCloud #####
3 | collection=sentiment
4 | zookeeper_connect_timeout=50000
5 | zookeeper_client_timeout=50000
6 | #zookeeper_cloud=leader:2181
7 | # Product
8 | zookeeper_cloud=192.168.32.11:2181,192.168.32.12:2181,192.168.32.13:2181,192.168.32.14:2181,192.168.32.15:2181,192.168.32.16:2181
9 | # Testing
10 | #zookeeper_cloud=192.168.31.11:2181,192.168.31.12:2181,192.168.31.20:2181,192.168.31.21:2181,192.168.31.26:2181,192.168.31.27:2181
11 |
12 | ##### Fetch Size #####
13 | fetch_size=20000
--------------------------------------------------------------------------------
/sentiment-spring/src/main/resources/web-server.properties:
--------------------------------------------------------------------------------
1 | httpConn.maxTotal=10000
2 | httpConn.maxPerRoute=5000
3 | api.port=8900
4 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/webapp/WEB-INF/applicationContext.xml:
--------------------------------------------------------------------------------
1 |
2 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
20 |
21 |
22 |
23 |
24 |
25 |
26 |
28 |
30 |
31 |
32 |
33 |
34 |
35 |
--------------------------------------------------------------------------------
/sentiment-spring/src/main/webapp/images/spring_logo.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wgybzbrobot/sentiment-search/df50eef8f82fbdc4549d1cfffb0d0b393a04f7b5/sentiment-spring/src/main/webapp/images/spring_logo.png
--------------------------------------------------------------------------------
/sentiment-spring/src/test/resources/index-test.sh:
--------------------------------------------------------------------------------
1 | # /bin/bash
2 |
3 | for i in $(seq 1 10000)
4 | do echo '"sentiment'$i'"';
5 | # 192.168.32.17:20000, 36.7.150.150:28094
6 | curl -X POST -H 'Content-Type:application/json' http://192.168.32.17:20000/sentiment/index --data '{"num":1,"records":[{"id":"sentiment'$i'","platform":9,"mid":"123456789987654321","username":"zxsoft","nickname":"中新舆情","original_id":"original_sentiment","original_uid":"original_zxsoft","original_name":"original_中新软件","original_title":"original_标题","original_url":"http://www.orignal_url.com","url":"http://www.url.com","home_url":"http://www.home_url.com","title":"标题","type":"所属类型","isharmful":true,"content":"测试内容","comment_count":10,"read_count":20,"favorite_count":30,"attitude_count":40,"repost_count":50,"video_url":"http://www.video_url.com","pic_url":"htpp://www.pic_url.com","voice_url":"http://www.voice_url.com","timestamp":1419755627695,"source_id":70,"lasttime":1419842027695,"server_id":90,"identify_id":100,"identify_md5":"abcdefg123456789","keyword":"关键词","first_time":1419928427695,"update_time":1420014827695,"ip":"192.168.32.45","location":"安徽省合肥市","geo":"经纬度信息","receive_addr":"receive@gmail.com","append_addr":"append@gmail.com","send_addr":"send@gmail.com","source_name":"新浪微博","source_type":121,"country_code":122,"location_code":123,"province_code":124,"city_code":125}]}';
7 | done;
8 |
--------------------------------------------------------------------------------
/sentiment-spring/src/test/resources/index/curl-index:
--------------------------------------------------------------------------------
1 | curl -X POST --header 'Content-Type:application/json' http://192.168.31.11:8900/sentiment/index --data '{"num":1,"records":[{"id":"sentiment","platform":10,"mid":"123456789987654321","username":"zxsoft","nickname":"中新舆情","original_id":"original_sentiment","original_uid":"original_zxsoft","original_name":"original_中新软件","original_title":"original_标题","original_url":"http://www.orignal_url.com","url":"http://www.url.com","home_url":"http://www.home_url.com","title":"标题","type":"所属类型","isharmful":true,"content":"测试内容","comment_count":10,"read_count":20,"favorite_count":30,"attitude_count":40,"repost_count":50,"video_url":"http://www.video_url.com","pic_url":"htpp://www.pic_url.com","voice_url":"http://www.voice_url.com","timestamp":1416038921,"source_id":70,"lasttime":1416125321,"server_id":90,"identify_id":100,"identify_md5":"abcdefg123456789","keyword":"关键词","first_time":1416211721,"update_time":1416298121,"ip":"192.168.32.45","location":"安徽省合肥市","geo":"经纬度信息","receive_addr":"receive@gmail.com","append_addr":"append@gmail.com","send_addr":"send@gmail.com","source_name":"新浪微博","source_type":121,"country_code":122,"location_code":123,"province_code":124,"city_code":125}]}'
--------------------------------------------------------------------------------
/sentiment-spring/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
8 |
9 | %d{HH:mm:ss.SSS} [%thread] %-5level %logger{36} - %msg%n
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sentiment-web/README.md:
--------------------------------------------------------------------------------
1 |
2 | API接口层
3 | ==========
4 |
5 | `SolrCloud相关`
6 | 1、索引和搜索接口
7 |
8 | `Mysql相关`
9 | 1、读库接口
10 |
11 | `Redis相关`
12 | 1、查询key接口
13 |
--------------------------------------------------------------------------------
/sentiment-web/bin/timer-index.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | echo "Starting ..."
4 |
5 | bin/ctl.sh start sentimentIndexServer
6 |
7 | while (true)
8 | do
9 | sleep 1h
10 | bin/ctl.sh restart sentimentIndexServer
11 | done
12 |
13 | echo "Finishing ..."
14 |
--------------------------------------------------------------------------------
/sentiment-web/ik_dic/ext_ik.dic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wgybzbrobot/sentiment-search/df50eef8f82fbdc4549d1cfffb0d0b393a04f7b5/sentiment-web/ik_dic/ext_ik.dic
--------------------------------------------------------------------------------
/sentiment-web/ik_dic/stopwords_ik.dic:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wgybzbrobot/sentiment-search/df50eef8f82fbdc4549d1cfffb0d0b393a04f7b5/sentiment-web/ik_dic/stopwords_ik.dic
--------------------------------------------------------------------------------
/sentiment-web/src/main/assembly/distribution.xml:
--------------------------------------------------------------------------------
1 |
2 |
6 | distribution
7 |
8 | tar.gz
9 |
10 | ${project.artifactId}
11 |
12 |
13 | src/main/resources
14 |
15 | logback.xml
16 | cache-config.properties
17 | data_db.properties
18 | solr_params.properties
19 | web-server.properties
20 |
21 | /conf
22 | true
23 |
24 |
25 | ik_dic
26 |
27 | *
28 |
29 | /ik_dic
30 |
31 |
32 | src/main/bin
33 |
34 | *
35 |
36 | /bin
37 | 0755
38 |
39 |
40 |
41 |
42 | /lib
43 |
44 |
45 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/bin/ctl.sh:
--------------------------------------------------------------------------------
1 | #!/bin/bash
2 |
3 | mainClass=zx.soft.sent.web.driver.SentWebDriver
4 |
5 | # resolve links - $0 may be a softlink
6 | PRG="$0"
7 |
8 | while [ -h "$PRG" ]; do
9 | ls=`ls -ld "$PRG"`
10 | link=`expr "$ls" : '.*-> \(.*\)$'`
11 | if expr "$link" : '/.*' > /dev/null; then
12 | PRG="$link"
13 | else
14 | PRG=`dirname "$PRG"`/"$link"
15 | fi
16 | done
17 |
18 | # Get standard environment variables
19 | PRGDIR=`dirname "$PRG"`
20 |
21 | PROJECT_DIR=`cd "$PRGDIR/.." >/dev/null; pwd`
22 | echo PROJECT_DIR=$PROJECT_DIR
23 |
24 | CLASSPATH="$CLASSHPATH:$PROJECT_DIR/conf"
25 |
26 | for jar in "$PROJECT_DIR/lib"/*.jar; do
27 | CLASSPATH="$CLASSPATH:$jar"
28 | done
29 | echo CLASSPATH=$CLASSPATH
30 |
31 | JVMARGS="${JVMARGS} -Dproject_dir=${PROJECT_DIR}"
32 | echo JVMARGS=$JVMARGS
33 |
34 | usage() {
35 | echo >&2 "usage: $PRG [args]"
36 | echo 'Valid commands: start, stop'
37 | exit 1
38 | }
39 |
40 | start() {
41 | JAVA=${JAVA-'java'}
42 | exec $JAVA $JVMARGS -classpath "$CLASSPATH" $mainClass "$@" &
43 | echo $! > main.pid
44 | }
45 |
46 | stop() {
47 | kill `cat main.pid` > /dev/null
48 | }
49 |
50 | case $1 in
51 | (start)
52 | shift
53 | start $@
54 | ;;
55 | (stop)
56 | stop
57 | ;;
58 | (restart)
59 | stop
60 | shift
61 | start $@
62 | ;;
63 | (*)
64 | echo >&2 "$PRG: error: unknown command '$1'"
65 | usage
66 | ;;
67 | esac
68 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/application/HarmfulInfoApplication.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.application;
2 |
3 | import java.util.List;
4 |
5 | import org.apache.solr.common.SolrDocument;
6 | import org.restlet.Application;
7 | import org.restlet.Restlet;
8 | import org.restlet.routing.Router;
9 |
10 | import zx.soft.sent.solr.firstpage.OAFirstPage;
11 | import zx.soft.sent.solr.utils.HarmfulInfoUtil;
12 | import zx.soft.sent.web.resource.HarmfulInfoResource;
13 |
14 | public class HarmfulInfoApplication extends Application {
15 |
16 | private final OAFirstPage firstPage;
17 |
18 | public HarmfulInfoApplication() {
19 | firstPage = new OAFirstPage();
20 | }
21 |
22 | @Override
23 | public Restlet createInboundRoot() {
24 | Router router = new Router(getContext());
25 | router.attach("/{keywords}/{num}", HarmfulInfoResource.class);
26 | return router;
27 | }
28 |
29 | /**
30 | * 当天有害信息
31 | * @param num:返回条数
32 | * @param q:查询关键词
33 | * @return
34 | */
35 | public List getTodayNegativeRecords(int num, String q) {
36 | List result = firstPage.getTodayNegativeRecords(7, 100, q);
37 | result = HarmfulInfoUtil.getTopNNegativeRecords(result, num);
38 | return result;
39 | }
40 |
41 | @Override
42 | public void stop() throws Exception {
43 | super.stop();
44 | firstPage.close();
45 | }
46 |
47 | }
48 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/application/InternetTaskApplication.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.application;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.restlet.Application;
7 | import org.restlet.Restlet;
8 | import org.restlet.routing.Router;
9 |
10 | import zx.soft.sent.solr.domain.QueryParams;
11 | import zx.soft.sent.solr.domain.QueryResult;
12 | import zx.soft.sent.solr.query.QueryCore;
13 | import zx.soft.sent.web.domain.Task;
14 | import zx.soft.sent.web.resource.InternetTaskResource;
15 |
16 | public class InternetTaskApplication extends Application {
17 |
18 | private final QueryCore queryCore;
19 |
20 | public InternetTaskApplication() {
21 | queryCore = new QueryCore();
22 | }
23 |
24 | @Override
25 | public Restlet createInboundRoot() {
26 | Router router = new Router(getContext());
27 | // POST专题信息
28 | router.attach("", InternetTaskResource.class);
29 | return router;
30 | }
31 |
32 | /**
33 | * 查询OA首页查询数据
34 | */
35 | public List taskResult(List tasks) {
36 | List result = new ArrayList<>();
37 | QueryParams queryParams = null;
38 | QueryResult queryResult = null;
39 | for (Task task : tasks) {
40 | queryParams = new QueryParams();
41 | queryParams.setQ(task.getKeywords());
42 | if (task.getFq().length() > 0) {
43 | queryParams.setFq(task.getFq());
44 | }
45 | queryResult = queryCore.queryData(queryParams, Boolean.FALSE);
46 | result.add(queryResult.getNumFound());
47 | }
48 | return result;
49 | }
50 |
51 | @Override
52 | public void stop() throws Exception {
53 | super.stop();
54 | queryCore.close();
55 | }
56 |
57 | }
58 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/application/PullRecordApplication.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.application;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import org.restlet.Application;
7 | import org.restlet.Restlet;
8 | import org.restlet.routing.Router;
9 |
10 | import zx.soft.sent.dao.common.MybatisConfig;
11 | import zx.soft.sent.dao.domain.sentiment.RecordSelect;
12 | import zx.soft.sent.dao.sentiment.SentimentRecord;
13 | import zx.soft.sent.dao.sql.CreateTables;
14 | import zx.soft.sent.web.resource.PullRecordResource;
15 | import zx.soft.utils.checksum.CheckSumUtils;
16 |
17 | /**
18 | * MySQL数据提取应用类
19 | *
20 | * @author wanggang
21 | *
22 | */
23 | public class PullRecordApplication extends Application {
24 |
25 | // private static Logger logger = LoggerFactory.getLogger(PullRecordApplication.class);
26 |
27 | private final SentimentRecord sentRecord;
28 |
29 | public PullRecordApplication() {
30 | sentRecord = new SentimentRecord(MybatisConfig.ServerEnum.sentiment);
31 | }
32 |
33 | @Override
34 | public Restlet createInboundRoot() {
35 | Router router = new Router(getContext());
36 | // 1、根据多个id查询记录:
37 | router.attach("/pull/ids/{ids}", PullRecordResource.class);
38 | // 2、根据lasttime时间段查询记录:
39 | // router.attach("/get", PullRecordResource.class);
40 | return router;
41 | }
42 |
43 | public List getRecords(String ids) {
44 | List result = new ArrayList<>();
45 | for (String id : ids.split(",")) {
46 | result.add(getRecord(id));
47 | }
48 | return result;
49 | }
50 |
51 | private RecordSelect getRecord(String id) {
52 | return sentRecord.selectRecordById(CreateTables.SENT_TABLE + CheckSumUtils.getCRC32(id)
53 | % CreateTables.MAX_TABLE_NUM, id);
54 | }
55 |
56 | public void close() {
57 | //
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/application/SentiSearchApplication.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.application;
2 |
3 | import org.restlet.Application;
4 | import org.restlet.Restlet;
5 | import org.restlet.routing.Router;
6 |
7 | import zx.soft.sent.solr.domain.QueryParams;
8 | import zx.soft.sent.solr.domain.QueryResult;
9 | import zx.soft.sent.solr.query.QueryCore;
10 | import zx.soft.sent.web.resource.SentSearchResource;
11 |
12 | /**
13 | * 舆情搜索应用类
14 | *
15 | * @author wanggang
16 | *
17 | */
18 | public class SentiSearchApplication extends Application {
19 |
20 | private final QueryCore queryCore;
21 |
22 | public SentiSearchApplication() {
23 | queryCore = new QueryCore();
24 | }
25 |
26 | @Override
27 | public Restlet createInboundRoot() {
28 | Router router = new Router(getContext());
29 | getContext().getParameters().add("maxThreads", "512");
30 | getContext().getParameters().add("minThreads", "100");
31 | getContext().getParameters().add("lowThreads", "200");
32 | getContext().getParameters().add("maxConnectionsPerHost", "128");
33 | getContext().getParameters().add("initialConnections", "255");
34 | getContext().getParameters().add("maxTotalConnections", "1024");
35 | getContext().getParameters().add("maxIoIdleTimeMs", "100");
36 | router.attach("/search", SentSearchResource.class);
37 | // router.attach("/get", SentGetResource.class);
38 | return router;
39 | }
40 |
41 | public QueryResult queryData(QueryParams queryParams) {
42 | return queryCore.queryData(queryParams, Boolean.TRUE);
43 | }
44 |
45 | public void close() {
46 | queryCore.close();
47 | }
48 |
49 | }
50 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/application/SiteApplication.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.application;
2 |
3 | import java.util.List;
4 |
5 | import org.restlet.Application;
6 | import org.restlet.Restlet;
7 | import org.restlet.routing.Router;
8 |
9 | import zx.soft.redis.client.cache.Cache;
10 | import zx.soft.redis.client.cache.RedisCache;
11 | import zx.soft.redis.client.common.Config;
12 | import zx.soft.sent.dao.common.SentimentConstant;
13 | import zx.soft.sent.web.resource.SiteResource;
14 | import zx.soft.utils.checksum.CheckSumUtils;
15 |
16 | /**
17 | * 站点应用类
18 | *
19 | * @author wanggang
20 | *
21 | */
22 | public class SiteApplication extends Application {
23 |
24 | private static Cache cache;
25 |
26 | public SiteApplication() {
27 | // 写入数据用master节点
28 | cache = new RedisCache(Config.get("redis.rp.master"), Integer.parseInt(Config.get("redis.rp.port")),
29 | Config.get("redis.password"));
30 | }
31 |
32 | @Override
33 | public Restlet createInboundRoot() {
34 | Router router = new Router(getContext());
35 | router.attach("", SiteResource.class);
36 | return router;
37 | }
38 |
39 | /**
40 | * 插入站点组合数据
41 | */
42 | public void insertSiteGroups(List data) {
43 | for (String sites : data) {
44 | // 设置hash表
45 | cache.hset(SentimentConstant.SITE_GROUPS, CheckSumUtils.getMD5(sites), sites);
46 | }
47 | }
48 |
49 | public void close() {
50 | cache.close();
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/common/LogstashDemo.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.common;
2 |
3 | import java.io.BufferedReader;
4 | import java.io.File;
5 | import java.io.FileReader;
6 | import java.io.IOException;
7 | import java.util.ArrayList;
8 | import java.util.List;
9 |
10 | import redis.clients.jedis.Jedis;
11 | import zx.soft.utils.json.JsonUtils;
12 |
13 | public class LogstashDemo {
14 |
15 | public static void main(String[] args) {
16 | Jedis jedis = new Jedis("192.168.31.160", 7000);
17 | String key = "nginx-logs";
18 | List logs = new ArrayList<>();
19 | try (BufferedReader br = new BufferedReader(new FileReader(new File("access.log")));) {
20 | String line;
21 | String[] strs;
22 | while ((line = br.readLine()) != null) {
23 | strs = line.split("-");
24 | NginxLog log = new NginxLog();
25 | log.setRemote_addr(strs[0]);
26 | log.setTime_local(strs[1]);
27 | log.setRequest_length(strs[2]);
28 | log.setStatus(strs[3]);
29 | log.setRequest_time(strs[4]);
30 | log.setBody_bytes_sent(strs[5]);
31 | logs.add(JsonUtils.toJsonWithoutPretty(log));
32 | }
33 | } catch (IOException e) {
34 | e.printStackTrace();
35 | }
36 | jedis.lpush(key, logs.toArray(new String[logs.size()]));
37 | jedis.close();
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/common/NginxLog.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.common;
2 |
3 | public class NginxLog {
4 |
5 | private String remote_addr;
6 | private String time_local;
7 | private String request_length;
8 | private String status;
9 | private String request_time;
10 | private String body_bytes_sent;
11 |
12 | public String getRemote_addr() {
13 | return remote_addr;
14 | }
15 |
16 | public void setRemote_addr(String remote_addr) {
17 | this.remote_addr = remote_addr;
18 | }
19 |
20 | public String getTime_local() {
21 | return time_local;
22 | }
23 |
24 | public void setTime_local(String time_local) {
25 | this.time_local = time_local;
26 | }
27 |
28 | public String getRequest_length() {
29 | return request_length;
30 | }
31 |
32 | public void setRequest_length(String request_length) {
33 | this.request_length = request_length;
34 | }
35 |
36 | public String getStatus() {
37 | return status;
38 | }
39 |
40 | public void setStatus(String status) {
41 | this.status = status;
42 | }
43 |
44 | public String getRequest_time() {
45 | return request_time;
46 | }
47 |
48 | public void setRequest_time(String request_time) {
49 | this.request_time = request_time;
50 | }
51 |
52 | public String getBody_bytes_sent() {
53 | return body_bytes_sent;
54 | }
55 |
56 | public void setBody_bytes_sent(String body_bytes_sent) {
57 | this.body_bytes_sent = body_bytes_sent;
58 | }
59 |
60 | }
61 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/demo/SpecialTopicDemo.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.demo;
2 |
3 | import java.util.ArrayList;
4 | import java.util.List;
5 |
6 | import zx.soft.sent.dao.domain.special.SpecialTopic;
7 | import zx.soft.utils.json.JsonUtils;
8 |
9 | public class SpecialTopicDemo {
10 |
11 | public static void main(String[] args) {
12 |
13 | List specialTopics = new ArrayList<>();
14 | SpecialTopic st1 = new SpecialTopic();
15 | st1.setIdentify("absbhdfhfjfi");
16 | st1.setName("专题1");
17 | st1.setKeywords("(合肥 and 警察) not 打人");
18 | st1.setStart("2014-08-25 00:00:00");
19 | st1.setEnd("2014-08-25 23:59:59");
20 | st1.setHometype(0);
21 | SpecialTopic st2 = new SpecialTopic();
22 | st2.setIdentify("djdjfkfklglg");
23 | st2.setName("专题2");
24 | st2.setKeywords("(安徽 and 城管) not 暴力执法");
25 | st2.setStart("2013-08-25 00:00:00");
26 | st2.setEnd("2013-08-25 23:59:59");
27 | st2.setHometype(2);
28 | specialTopics.add(st1);
29 | specialTopics.add(st2);
30 | System.out.println(JsonUtils.toJsonWithoutPretty(specialTopics));
31 | }
32 |
33 | }
34 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/domain/ErrorResponse.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.domain;
2 |
3 | import java.io.Serializable;
4 |
5 | /**
6 | * 错误相应类
7 | *
8 | * @author wanggang
9 | *
10 | */
11 | public class ErrorResponse implements Serializable {
12 |
13 | private static final long serialVersionUID = -3408598774435409654L;
14 |
15 | private final int errorCode;
16 | private final String errorMessage;
17 |
18 | public ErrorResponse(Builder builder) {
19 | this.errorCode = builder.errorCode;
20 | this.errorMessage = builder.errorMessage;
21 | }
22 |
23 | public static class Builder {
24 |
25 | private final int errorCode;
26 | private final String errorMessage;
27 |
28 | public Builder(int errorCode, String errorMessage) {
29 | super();
30 | this.errorCode = errorCode;
31 | this.errorMessage = errorMessage;
32 | }
33 |
34 | public ErrorResponse build() {
35 | return new ErrorResponse(this);
36 | }
37 |
38 | }
39 |
40 | public int getErrorCode() {
41 | return errorCode;
42 | }
43 |
44 | public String getErrorMessage() {
45 | return errorMessage;
46 | }
47 |
48 | }
49 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/domain/IndexErrResponse.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.domain;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import zx.soft.utils.json.JsonUtils;
8 |
9 | public class IndexErrResponse implements Serializable {
10 |
11 | private static final long serialVersionUID = -5183178204181065266L;
12 |
13 | private int errorCode;
14 | private List errorMessage;
15 |
16 | public IndexErrResponse(int errorCode, List errorMessage) {
17 | this.errorCode = errorCode;
18 | this.errorMessage = errorMessage;
19 | }
20 |
21 | public int getErrorCode() {
22 | return errorCode;
23 | }
24 |
25 | public void setErrorCode(int errorCode) {
26 | this.errorCode = errorCode;
27 | }
28 |
29 | public List getErrorMessage() {
30 | return errorMessage;
31 | }
32 |
33 | public void setErrorMessage(List errorMessage) {
34 | this.errorMessage = errorMessage;
35 | }
36 |
37 | public static void main(String[] args) {
38 | List errorMessage = new ArrayList<>();
39 | errorMessage.add("wwfffrrrrr");
40 | errorMessage.add("1233jjffioo");
41 | IndexErrResponse err = new IndexErrResponse(-1, errorMessage);
42 | System.out.println(JsonUtils.toJson(err));
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/domain/InternetTask.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.domain;
2 |
3 | import java.io.Serializable;
4 | import java.util.ArrayList;
5 | import java.util.List;
6 |
7 | import zx.soft.utils.json.JsonUtils;
8 |
9 | /**
10 | * 全网搜索任务请求参数刘表
11 | *
12 | * @author wanggang
13 | *
14 | */
15 | public class InternetTask implements Serializable {
16 |
17 | private static final long serialVersionUID = 5887938203759551452L;
18 |
19 | // 任务数
20 | private int num;
21 | // 任务列表
22 | private List tasks;
23 |
24 | public int getNum() {
25 | return num;
26 | }
27 |
28 | public void setNum(int num) {
29 | this.num = num;
30 | }
31 |
32 | public List getTasks() {
33 | return tasks;
34 | }
35 |
36 | public void setTasks(List tasks) {
37 | this.tasks = tasks;
38 | }
39 |
40 | public static void main(String[] args) {
41 | InternetTask internetTask = new InternetTask();
42 | List tasks = new ArrayList<>();
43 | Task task1 = new Task();
44 | task1.setKeywords("穿越火线");
45 | task1.setFq("lasttime:[2014-12-25T15:09:01Z TO 2014-12-26T15:09:01Z];source_name:腾讯微博;platform:3");
46 | tasks.add(task1);
47 | Task task2 = new Task();
48 | task2.setKeywords("圣诞节");
49 | task2.setFq("lasttime:[2014-12-25T15:09:01Z TO 2014-12-26T15:09:01Z];source_name:新浪微博;platform:3");
50 | tasks.add(task2);
51 | internetTask.setNum(2);
52 | internetTask.setTasks(tasks);
53 | System.out.println(JsonUtils.toJsonWithoutPretty(internetTask));
54 | }
55 |
56 | }
57 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/domain/Task.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.domain;
2 |
3 | import java.io.Serializable;
4 |
5 | public class Task implements Serializable {
6 |
7 | private static final long serialVersionUID = -1391283603740904033L;
8 |
9 | // 关键词
10 | private String keywords;
11 | // 过滤条件
12 | private String fq;
13 |
14 | public String getKeywords() {
15 | return keywords;
16 | }
17 |
18 | public void setKeywords(String keywords) {
19 | this.keywords = keywords;
20 | }
21 |
22 | public String getFq() {
23 | return fq;
24 | }
25 |
26 | public void setFq(String fq) {
27 | this.fq = fq;
28 | }
29 |
30 | }
31 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/resource/FirstPageHarmfulResource.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.resource;
2 |
3 | import org.restlet.resource.Get;
4 | import org.restlet.resource.ServerResource;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | import zx.soft.sent.web.application.FirstPageHarmfulApplication;
9 | import zx.soft.sent.web.domain.ErrorResponse;
10 | import zx.soft.utils.chars.JavaPattern;
11 | import zx.soft.utils.codec.URLCodecUtils;
12 |
13 | public class FirstPageHarmfulResource extends ServerResource {
14 |
15 | private static Logger logger = LoggerFactory.getLogger(FirstPageHarmfulResource.class);
16 |
17 | private FirstPageHarmfulApplication application;
18 |
19 | private String type = "";
20 | private String datestr = "";
21 |
22 | @Override
23 | public void doInit() {
24 | logger.info("Request Url: " + URLCodecUtils.decoder(getReference().toString(), "utf-8") + ".");
25 | application = (FirstPageHarmfulApplication) getApplication();
26 | type = (String) this.getRequest().getAttributes().get("type");
27 | datestr = (String) this.getRequest().getAttributes().get("datestr");
28 | }
29 |
30 | @Get("json")
31 | public Object getSpecialResult() {
32 | if (type == null || type.length() == 0 || datestr == null || datestr.length() == 0
33 | || !JavaPattern.isAllNum(type)) {
34 | logger.error("Params `type` or `datestr` is null.");
35 | return new ErrorResponse.Builder(-1, "params error!").build();
36 | }
37 | Object result = application.selectFirstPageType(Integer.parseInt(type), datestr);
38 | if (result == null) {
39 | return new ErrorResponse.Builder(-1, "params error!").build();
40 | } else {
41 | return result;
42 | }
43 | }
44 |
45 | }
46 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/resource/FirstPageResource.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.resource;
2 |
3 | import org.restlet.resource.Get;
4 | import org.restlet.resource.ServerResource;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | import zx.soft.sent.web.application.FirstPageApplication;
9 | import zx.soft.sent.web.domain.ErrorResponse;
10 | import zx.soft.utils.chars.JavaPattern;
11 | import zx.soft.utils.codec.URLCodecUtils;
12 |
13 | public class FirstPageResource extends ServerResource {
14 |
15 | private static Logger logger = LoggerFactory.getLogger(FirstPageResource.class);
16 |
17 | private FirstPageApplication application;
18 |
19 | private String type = "";
20 | private String datestr = "";
21 |
22 | @Override
23 | public void doInit() {
24 | logger.info("Request Url: " + URLCodecUtils.decoder(getReference().toString(), "utf-8") + ".");
25 | application = (FirstPageApplication) getApplication();
26 | type = (String) this.getRequest().getAttributes().get("type");
27 | datestr = (String) this.getRequest().getAttributes().get("datestr");
28 | }
29 |
30 | @Get("json")
31 | public Object getSpecialResult() {
32 | if (type == null || type.length() == 0 || datestr == null || datestr.length() == 0
33 | || !JavaPattern.isAllNum(type)) {
34 | logger.error("Params `type` or `datestr` is null.");
35 | return new ErrorResponse.Builder(-1, "params error!").build();
36 | }
37 | int t = Integer.parseInt(type);
38 | Object result = null;
39 | if (t == 1 || t == 2) {
40 | result = application.selectFirstPageType12(t, datestr);
41 | } else if (t == 4) {
42 | result = application.selectFirstPageType4(datestr);
43 | } else if (t == 52 || t == 53) {
44 | result = application.selectFirstPageType5(t, datestr);
45 | }
46 | if (result == null) {
47 | return new ErrorResponse.Builder(-1, "params error!").build();
48 | } else {
49 | return result;
50 | }
51 | }
52 |
53 | }
54 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/resource/HarmfulInfoResource.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.resource;
2 |
3 | import org.restlet.resource.Get;
4 | import org.restlet.resource.ServerResource;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | import zx.soft.sent.web.application.HarmfulInfoApplication;
9 | import zx.soft.sent.web.domain.ErrorResponse;
10 | import zx.soft.utils.chars.JavaPattern;
11 | import zx.soft.utils.codec.URLCodecUtils;
12 | import zx.soft.utils.log.LogbackUtil;
13 |
14 | public class HarmfulInfoResource extends ServerResource {
15 |
16 | private static Logger logger = LoggerFactory.getLogger(HarmfulInfoResource.class);
17 |
18 | private HarmfulInfoApplication application;
19 |
20 | private String keywords = "";
21 | private String num = "";
22 |
23 | @Override
24 | public void doInit() {
25 | logger.info("Request Url: " + URLCodecUtils.decoder(getReference().toString(), "utf-8") + ".");
26 | application = (HarmfulInfoApplication) getApplication();
27 | keywords = (String) this.getRequest().getAttributes().get("keywords");
28 | num = (String) this.getRequest().getAttributes().get("num");
29 | }
30 |
31 | @Get("json")
32 | public Object getSpecialResult() {
33 | if (keywords == null || keywords.length() == 0 || num == null || num.length() == 0
34 | || !JavaPattern.isAllNum(num)) {
35 | logger.error("Params `keywords` or `num` is null.");
36 | return new ErrorResponse.Builder(-1, "params error!").build();
37 | }
38 | try {
39 | return application.getTodayNegativeRecords(Integer.parseInt(num), URLCodecUtils.decoder(keywords, "UTF-8"));
40 | } catch (Exception e) {
41 | logger.error("Exception:{}", LogbackUtil.expection2Str(e));
42 | return new ErrorResponse.Builder(-1, "params error!").build();
43 | }
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/resource/InternetTaskResource.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.resource;
2 |
3 | import org.restlet.resource.Post;
4 | import org.restlet.resource.ServerResource;
5 | import org.slf4j.Logger;
6 | import org.slf4j.LoggerFactory;
7 |
8 | import zx.soft.sent.web.application.InternetTaskApplication;
9 | import zx.soft.sent.web.domain.ErrorResponse;
10 | import zx.soft.sent.web.domain.InternetTask;
11 | import zx.soft.utils.codec.URLCodecUtils;
12 | import zx.soft.utils.log.LogbackUtil;
13 |
14 | public class InternetTaskResource extends ServerResource {
15 |
16 | private static Logger logger = LoggerFactory.getLogger(InternetTaskResource.class);
17 |
18 | private InternetTaskApplication application;
19 |
20 | @Override
21 | public void doInit() {
22 | logger.info("Request Url: " + URLCodecUtils.decoder(getReference().toString(), "utf-8") + ".");
23 | application = (InternetTaskApplication) getApplication();
24 | }
25 |
26 | @Post("json")
27 | public Object taskResult(InternetTask internetTask) {
28 | logger.info("Tasks'size={}", internetTask.getNum());
29 | try {
30 | return application.taskResult(internetTask.getTasks());
31 | } catch (Exception e) {
32 | logger.error("Exception:{}", LogbackUtil.expection2Str(e));
33 | return new ErrorResponse.Builder(-1, "params error!").build();
34 | }
35 | }
36 |
37 | }
38 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/resource/SentGetResource.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.resource;
2 |
3 | import java.util.HashMap;
4 |
5 | import org.restlet.data.Form;
6 | import org.restlet.data.Parameter;
7 | import org.restlet.resource.Get;
8 | import org.restlet.resource.ServerResource;
9 | import org.slf4j.Logger;
10 | import org.slf4j.LoggerFactory;
11 |
12 | import zx.soft.sent.web.domain.ErrorResponse;
13 | import zx.soft.utils.codec.URLCodecUtils;
14 | import zx.soft.utils.http.HttpUtils;
15 |
16 | /**
17 | * 舆情数据获取资源类
18 | *
19 | * @author wanggang
20 | *
21 | */
22 | public class SentGetResource extends ServerResource {
23 |
24 | private static Logger logger = LoggerFactory.getLogger(SentGetResource.class);
25 |
26 | private static final String BASE_URL = "http://192.168.3.21:8983/solr/sentiment/get?id=";
27 |
28 | private String id = "";
29 |
30 | @Override
31 | public void doInit() {
32 | logger.info("Request Url: " + URLCodecUtils.decoder(getReference().toString(), "utf-8") + ".");
33 | HashMap params = new HashMap<>();
34 | Form form = getRequest().getResourceRef().getQueryAsForm();
35 | for (Parameter p : form) {
36 | if (params.get(p.getName()) == null) {
37 | params.put(p.getName(), p.getValue());
38 | } else { // 重复参数以最后一个为准
39 | params.put(p.getName(), p.getValue());
40 | }
41 | }
42 | if (params.get("id") != null) {
43 | id = params.get("id");
44 | } else {
45 | logger.error("id is null.");
46 | }
47 | logger.info("id=" + id);
48 | }
49 |
50 | @Get("json")
51 | public Object getQueryResult() {
52 | if (id.length() == 0) {
53 | return new ErrorResponse.Builder(20003, "your query params is illegal.").build();
54 | }
55 | return HttpUtils.doGet(BASE_URL + id, "utf-8");
56 | }
57 |
58 | }
59 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/resource/SiteResource.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.resource;
2 |
3 | import java.util.List;
4 |
5 | import org.restlet.resource.Post;
6 | import org.restlet.resource.ServerResource;
7 | import org.slf4j.Logger;
8 | import org.slf4j.LoggerFactory;
9 |
10 | import zx.soft.sent.web.application.SiteApplication;
11 | import zx.soft.sent.web.domain.ErrorResponse;
12 | import zx.soft.utils.codec.URLCodecUtils;
13 | import zx.soft.utils.json.JsonUtils;
14 |
15 | /**
16 | * 站点数据
17 | *
18 | * @author wanggang
19 | *
20 | */
21 | public class SiteResource extends ServerResource {
22 |
23 | private static Logger logger = LoggerFactory.getLogger(SiteResource.class);
24 |
25 | private SiteApplication application;
26 |
27 | @Override
28 | public void doInit() {
29 | logger.info("Request Url: " + URLCodecUtils.decoder(getReference().toString(), "utf-8") + ".");
30 | application = (SiteApplication) getApplication();
31 | }
32 |
33 | @Post("json")
34 | public Object siteDate(List data) {
35 | logger.info("Site data is {}.", JsonUtils.toJsonWithoutPretty(data));
36 | application.insertSiteGroups(data);
37 | return new ErrorResponse.Builder(0, "ok").build();
38 | }
39 |
40 | }
41 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/resource/SpecialSpeedResource.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.resource;
2 |
3 | import java.util.List;
4 |
5 | import org.restlet.resource.Get;
6 | import org.restlet.resource.ServerResource;
7 | import org.slf4j.Logger;
8 | import org.slf4j.LoggerFactory;
9 |
10 | import zx.soft.sent.web.application.SpecialSpeedApplication;
11 | import zx.soft.sent.web.application.SpecialSpeedApplication.SpecialResult;
12 | import zx.soft.sent.web.domain.ErrorResponse;
13 | import zx.soft.utils.codec.URLCodecUtils;
14 |
15 | /**
16 | * 专题资源类
17 | *
18 | * @author wanggang
19 | *
20 | */
21 | public class SpecialSpeedResource extends ServerResource {
22 |
23 | private static Logger logger = LoggerFactory.getLogger(SpecialSpeedResource.class);
24 |
25 | private SpecialSpeedApplication application;
26 |
27 | private String identifys = "";
28 |
29 | @Override
30 | public void doInit() {
31 | logger.info("Request Url: " + URLCodecUtils.decoder(getReference().toString(), "utf-8") + ".");
32 | application = (SpecialSpeedApplication) getApplication();
33 | identifys = (String) this.getRequest().getAttributes().get("identifys");
34 | }
35 |
36 | @Get("json")
37 | public Object getSpecialResult() {
38 | if (identifys == null || identifys.length() == 0) {
39 | logger.error("Params `identifys` is null.");
40 | return new ErrorResponse.Builder(-1, "params error!").build();
41 | }
42 | List queryResult = application.selectSpecialResult(identifys);
43 | return queryResult;
44 | }
45 |
46 | }
47 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/server/FirstPageHarmfulServer.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.server;
2 |
3 | import java.util.Properties;
4 |
5 | import org.restlet.Component;
6 | import org.restlet.data.Protocol;
7 |
8 | import zx.soft.sent.web.application.FirstPageHarmfulApplication;
9 | import zx.soft.utils.config.ConfigUtil;
10 | import zx.soft.utils.jackson.ReplaceConvert;
11 |
12 | /**
13 | * OA首页负面信息查询缓存服务:hefei07
14 | * 示例:http://localhost:5902/firstpage/{type}/{datestr}
15 | *
16 | * type是平台类型,1~10
17 | *
18 | * 运行目录:/home/zxdfs/run-work/api/oa-firstpage-harmful
19 | * 运行命令:cd sentiment-web
20 | * bin/ctl.sh start firstPageHarmfulServer
21 | *
22 | * @author wanggang
23 | *
24 | */
25 | public class FirstPageHarmfulServer {
26 |
27 | private final Component component;
28 | private final FirstPageHarmfulApplication firstPageApplication;
29 |
30 | private final int PORT;
31 |
32 | public FirstPageHarmfulServer() {
33 | Properties props = ConfigUtil.getProps("web-server.properties");
34 | PORT = Integer.parseInt(props.getProperty("api.port"));
35 | component = new Component();
36 | firstPageApplication = new FirstPageHarmfulApplication();
37 | }
38 |
39 | /**
40 | * 主函数
41 | */
42 | public static void main(String[] args) {
43 |
44 | FirstPageHarmfulServer specialServer = new FirstPageHarmfulServer();
45 | specialServer.start();
46 | }
47 |
48 | public void start() {
49 | component.getServers().add(Protocol.HTTP, PORT);
50 | try {
51 | component.getDefaultHost().attach("/firstpage", firstPageApplication);
52 | ReplaceConvert.configureJacksonConverter();
53 | component.start();
54 | } catch (Exception e) {
55 | throw new RuntimeException(e);
56 | }
57 | }
58 |
59 | public void stop() {
60 | try {
61 | component.stop();
62 | firstPageApplication.stop();
63 | } catch (Exception e) {
64 | throw new RuntimeException(e);
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/server/FirstPageServer.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.server;
2 |
3 | import java.util.Properties;
4 |
5 | import org.restlet.Component;
6 | import org.restlet.data.Protocol;
7 |
8 | import zx.soft.sent.web.application.FirstPageApplication;
9 | import zx.soft.utils.config.ConfigUtil;
10 | import zx.soft.utils.jackson.ReplaceConvert;
11 |
12 | /**
13 | * OA首页查询缓存服务:hefei07
14 | * 示例:http://localhost:5901/firstpage/{type}/{datestr}
15 | *
16 | * 运行目录:/home/zxdfs/run-work/api/oa-firstpage
17 | * 运行命令:cd sentiment-web
18 | * bin/ctl.sh start firstPageServer
19 | *
20 | * @author wanggang
21 | *
22 | */
23 | public class FirstPageServer {
24 |
25 | private final Component component;
26 | private final FirstPageApplication firstPageApplication;
27 |
28 | private final int PORT;
29 |
30 | public FirstPageServer() {
31 | Properties props = ConfigUtil.getProps("web-server.properties");
32 | PORT = Integer.parseInt(props.getProperty("api.port"));
33 | component = new Component();
34 | firstPageApplication = new FirstPageApplication();
35 | }
36 |
37 | /**
38 | * 主函数
39 | */
40 | public static void main(String[] args) {
41 |
42 | FirstPageServer specialServer = new FirstPageServer();
43 | specialServer.start();
44 | }
45 |
46 | public void start() {
47 | component.getServers().add(Protocol.HTTP, PORT);
48 | try {
49 | component.getDefaultHost().attach("/firstpage", firstPageApplication);
50 | ReplaceConvert.configureJacksonConverter();
51 | component.start();
52 | } catch (Exception e) {
53 | throw new RuntimeException(e);
54 | }
55 | }
56 |
57 | public void stop() {
58 | try {
59 | component.stop();
60 | firstPageApplication.stop();
61 | } catch (Exception e) {
62 | throw new RuntimeException(e);
63 | }
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/server/HarmfulInfoServer.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.server;
2 |
3 | import java.util.Properties;
4 |
5 | import org.restlet.Component;
6 | import org.restlet.data.Protocol;
7 |
8 | import zx.soft.sent.web.application.HarmfulInfoApplication;
9 | import zx.soft.utils.config.ConfigUtil;
10 | import zx.soft.utils.jackson.ReplaceConvert;
11 |
12 | /**
13 | * OA有害信息查询:hefei07
14 | * 根据关键词keywords查询最近7天的数据,并根据评分排序,返回num条结果。
15 | * 示例:http://localhost:4900/harmful/{keywords}/{num}
16 | *
17 | * 运行目录:/home/zxdfs/run-work/api/oa-harmful
18 | * 运行命令:cd sentiment-web
19 | * bin/ctl.sh start harmfulInfoServer
20 | *
21 | * @author wanggang
22 | *
23 | */
24 | public class HarmfulInfoServer {
25 |
26 | private final Component component;
27 | private final HarmfulInfoApplication harmfulInfoApplication;
28 |
29 | private final int PORT;
30 |
31 | public HarmfulInfoServer() {
32 | Properties props = ConfigUtil.getProps("web-server.properties");
33 | PORT = Integer.parseInt(props.getProperty("api.port"));
34 | component = new Component();
35 | harmfulInfoApplication = new HarmfulInfoApplication();
36 | }
37 |
38 | /**
39 | * 主函数
40 | */
41 | public static void main(String[] args) {
42 |
43 | HarmfulInfoServer specialServer = new HarmfulInfoServer();
44 | specialServer.start();
45 | }
46 |
47 | public void start() {
48 | component.getServers().add(Protocol.HTTP, PORT);
49 | try {
50 | component.getDefaultHost().attach("/harmful", harmfulInfoApplication);
51 | ReplaceConvert.configureJacksonConverter();
52 | component.start();
53 | } catch (Exception e) {
54 | throw new RuntimeException(e);
55 | }
56 | }
57 |
58 | public void stop() {
59 | try {
60 | component.stop();
61 | harmfulInfoApplication.stop();
62 | } catch (Exception e) {
63 | throw new RuntimeException(e);
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/server/InternetTaskServer.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.server;
2 |
3 | import java.util.Properties;
4 |
5 | import org.restlet.Component;
6 | import org.restlet.data.Protocol;
7 |
8 | import zx.soft.sent.web.application.InternetTaskApplication;
9 | import zx.soft.utils.config.ConfigUtil;
10 | import zx.soft.utils.jackson.ReplaceConvert;
11 |
12 | /**
13 | * 全网搜索任务联合接口服务:hefei05
14 | * 示例:http://192.168.32.15:3900/task
15 | *
16 | * 运行目录:/home/zxdfs/run-work/api/internettask
17 | * 运行命令:cd sentiment-web
18 | * bin/ctl.sh start internetTaskServer
19 | *
20 | * @author wanggang
21 | *
22 | */
23 | public class InternetTaskServer {
24 |
25 | private final Component component;
26 | private final InternetTaskApplication internetTaskApplication;
27 |
28 | private final int PORT;
29 |
30 | public InternetTaskServer() {
31 | Properties props = ConfigUtil.getProps("web-server.properties");
32 | PORT = Integer.parseInt(props.getProperty("api.port"));
33 | component = new Component();
34 | internetTaskApplication = new InternetTaskApplication();
35 | }
36 |
37 | /**
38 | * 主函数
39 | */
40 | public static void main(String[] args) {
41 |
42 | InternetTaskServer specialServer = new InternetTaskServer();
43 | specialServer.start();
44 | }
45 |
46 | public void start() {
47 | component.getServers().add(Protocol.HTTP, PORT);
48 | try {
49 | component.getDefaultHost().attach("/task", internetTaskApplication);
50 | ReplaceConvert.configureJacksonConverter();
51 | component.start();
52 | } catch (Exception e) {
53 | throw new RuntimeException(e);
54 | }
55 | }
56 |
57 | public void stop() {
58 | try {
59 | component.stop();
60 | internetTaskApplication.stop();
61 | } catch (Exception e) {
62 | throw new RuntimeException(e);
63 | }
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/server/NicknameGroupServer.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.server;
2 |
3 | import java.util.Properties;
4 |
5 | import org.restlet.Component;
6 | import org.restlet.data.Protocol;
7 |
8 | import zx.soft.sent.web.application.NicknameGroupApplication;
9 | import zx.soft.utils.config.ConfigUtil;
10 | import zx.soft.utils.jackson.ReplaceConvert;
11 |
12 | /**
13 | * 舆情搜索Server,针对nickname:hefei02
14 | * 搜索示例:http://192.168.32.12:8901/sentiment/search?q=合肥&fq=timestamp:[2014-12-23T00:00:00Z TO 2014-12-29T23:59:59Z]
15 | * http://192.168.31.11:8902/sentiment/search?q="人"&fq=timestamp:[2015-05-06T00:00:00Z TO 2015-06-04T23:59:59Z];
16 | *
17 | * 运行目录:/home/zxdfs/run-work/api/nicknamegroup
18 | * 运行命令: cd sentiment-web
19 | * bin/ctl.sh start nicknameGroupServer
20 | *
21 | * @author wanggang
22 | *
23 | */
24 | public class NicknameGroupServer {
25 |
26 | private final Component component;
27 | private final NicknameGroupApplication nicknameGroupApplication;
28 |
29 | private final int PORT;
30 |
31 | public NicknameGroupServer() {
32 | Properties props = ConfigUtil.getProps("web-server.properties");
33 | PORT = Integer.parseInt(props.getProperty("api.port"));
34 | component = new Component();
35 | nicknameGroupApplication = new NicknameGroupApplication();
36 | }
37 |
38 | /**
39 | * 主函数
40 | */
41 | public static void main(String[] args) {
42 |
43 | NicknameGroupServer server = new NicknameGroupServer();
44 | server.start();
45 | }
46 |
47 | public void start() {
48 | component.getServers().add(Protocol.HTTP, PORT);
49 | try {
50 | component.getDefaultHost().attach("/sentiment", nicknameGroupApplication);
51 | ReplaceConvert.configureJacksonConverter();
52 | component.start();
53 | } catch (Exception e) {
54 | throw new RuntimeException(e);
55 | }
56 | }
57 |
58 | public void stop() {
59 | try {
60 | component.stop();
61 | nicknameGroupApplication.close();
62 | } catch (Exception e) {
63 | throw new RuntimeException(e);
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/server/PullRecordServer.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.server;
2 |
3 | import java.util.Properties;
4 |
5 | import org.restlet.Component;
6 | import org.restlet.data.Protocol;
7 |
8 | import zx.soft.sent.web.application.PullRecordApplication;
9 | import zx.soft.utils.config.ConfigUtil;
10 | import zx.soft.utils.jackson.ReplaceConvert;
11 |
12 | /**
13 | * 从Mysql中根据id获取记录数据:hefei01
14 | * 示例:
15 | * 根据多个id、关键词、高亮标签查询数据:http://192.168.32.11:7900/sentiment/pull/ids/{ids}?keyword=XXXX&hlsimple=red
16 | *
17 | * 运行目录:/home/zxdfs/run-work/api/mysql
18 | * 运行命令:cd sentiment-web
19 | * bin/ctl.sh start pullRecordServer
20 | *
21 | * @author wanggang
22 | *
23 | */
24 | public class PullRecordServer {
25 |
26 | private final Component component;
27 | private final PullRecordApplication retriveRecordApplication;
28 |
29 | private final int PORT;
30 |
31 | public PullRecordServer() {
32 | Properties props = ConfigUtil.getProps("web-server.properties");
33 | PORT = Integer.parseInt(props.getProperty("api.port"));
34 | component = new Component();
35 | retriveRecordApplication = new PullRecordApplication();
36 | }
37 |
38 | /**
39 | * 主函数
40 | */
41 | public static void main(String[] args) {
42 |
43 | PullRecordServer server = new PullRecordServer();
44 | server.start();
45 |
46 | }
47 |
48 | public void start() {
49 | component.getServers().add(Protocol.HTTP, PORT);
50 | try {
51 | component.getDefaultHost().attach("/sentiment", retriveRecordApplication);
52 | ReplaceConvert.configureJacksonConverter();
53 | component.start();
54 | } catch (Exception e) {
55 | throw new RuntimeException(e);
56 | }
57 | }
58 |
59 | public void stop() {
60 | try {
61 | component.stop();
62 | retriveRecordApplication.close();
63 | } catch (Exception e) {
64 | throw new RuntimeException(e);
65 | }
66 | }
67 |
68 | }
69 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/server/SentimentSearchServer.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.server;
2 |
3 | import java.util.Properties;
4 |
5 | import org.restlet.Component;
6 | import org.restlet.data.Protocol;
7 |
8 | import zx.soft.sent.web.application.SentiSearchApplication;
9 | import zx.soft.utils.config.ConfigUtil;
10 | import zx.soft.utils.jackson.ReplaceConvert;
11 |
12 | /**
13 | * 舆情搜索服务:hefei01和hefei03
14 | * 搜索示例:
15 | * http://localhost:8901/sentiment/search?q=美食&fq=platform:7&sort=lasttime:desc&start=10&rows=50&fl=username,nickname&wt=xml&hlfl=content&facetQuery=abc&facetField=nickname
16 | *
17 | * 运行目录:/home/zxdfs/run-work/api/search
18 | * 运行命令: cd sentiment-web
19 | * bin/ctl.sh start sentimentSearchServer
20 | *
21 | * @author wanggang
22 | *
23 | */
24 | public class SentimentSearchServer {
25 |
26 | private final Component component;
27 | private final SentiSearchApplication sentiSearchApplication;
28 |
29 | private final int PORT;
30 |
31 | public SentimentSearchServer() {
32 | Properties props = ConfigUtil.getProps("web-server.properties");
33 | PORT = Integer.parseInt(props.getProperty("api.port"));
34 | component = new Component();
35 | sentiSearchApplication = new SentiSearchApplication();
36 | }
37 |
38 | /**
39 | * 主函数
40 | */
41 | public static void main(String[] args) {
42 |
43 | SentimentSearchServer server = new SentimentSearchServer();
44 | server.start();
45 | }
46 |
47 | public void start() {
48 | component.getServers().add(Protocol.HTTP, PORT);
49 | try {
50 | component.getDefaultHost().attach("/sentiment", sentiSearchApplication);
51 | ReplaceConvert.configureJacksonConverter();
52 | component.start();
53 | } catch (Exception e) {
54 | throw new RuntimeException(e);
55 | }
56 | }
57 |
58 | public void stop() {
59 | try {
60 | component.stop();
61 | sentiSearchApplication.close();
62 | } catch (Exception e) {
63 | throw new RuntimeException(e);
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/server/SiteServer.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.server;
2 |
3 | import java.util.Properties;
4 |
5 | import org.restlet.Component;
6 | import org.restlet.data.Protocol;
7 |
8 | import zx.soft.sent.web.application.SiteApplication;
9 | import zx.soft.utils.config.ConfigUtil;
10 | import zx.soft.utils.jackson.ReplaceConvert;
11 |
12 | /**
13 | * 站点组合数据服务:hefei01
14 | * 示例: http://192.168.32.11:6900/site POST: [ "2344,543,23,1355", "667,99,145,987" ]
15 | *
16 | * 运行目录:/home/zxdfs/run-work/api/site
17 | * 运行命令:cd sentiment-web
18 | * bin/ctl.sh start siteServer
19 | *
20 | * @author wanggang
21 | */
22 | public class SiteServer {
23 |
24 | private final Component component;
25 | private final SiteApplication siteApplication;
26 |
27 | private final int PORT;
28 |
29 | public SiteServer() {
30 | Properties props = ConfigUtil.getProps("web-server.properties");
31 | PORT = Integer.parseInt(props.getProperty("api.port"));
32 | component = new Component();
33 | siteApplication = new SiteApplication();
34 | }
35 |
36 | /**
37 | * 主函数
38 | */
39 | public static void main(String[] args) {
40 |
41 | SiteServer server = new SiteServer();
42 | server.start();
43 |
44 | }
45 |
46 | public void start() {
47 | component.getServers().add(Protocol.HTTP, PORT);
48 | try {
49 | component.getDefaultHost().attach("/site", siteApplication);
50 | ReplaceConvert.configureJacksonConverter();
51 | component.start();
52 | } catch (Exception e) {
53 | throw new RuntimeException(e);
54 | }
55 | }
56 |
57 | public void stop() {
58 | try {
59 | component.stop();
60 | siteApplication.close();
61 | } catch (Exception e) {
62 | throw new RuntimeException(e);
63 | }
64 | }
65 |
66 | }
67 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/java/zx/soft/sent/web/server/SpecialSpeedServer.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.server;
2 |
3 | import java.util.Properties;
4 |
5 | import org.restlet.Component;
6 | import org.restlet.data.Protocol;
7 |
8 | import zx.soft.sent.web.application.SpecialSpeedApplication;
9 | import zx.soft.utils.config.ConfigUtil;
10 | import zx.soft.utils.jackson.ReplaceConvert;
11 |
12 | /**
13 | * OA专题查询缓存服务:hefei03
14 | * 示例:GET: http://192.168.32.13:5900/special/{identifys}
15 | * 408,409,410,412,413,414,415,416,417,419,427,450
16 | *
17 | * 运行目录:/home/zxdfs/run-work/api/special
18 | * 运行命令:cd sentiment-web
19 | * bin/ctl.sh start specialSpeedServer
20 | *
21 | * @author wanggang
22 | *
23 | */
24 | public class SpecialSpeedServer {
25 |
26 | private final Component component;
27 | private final SpecialSpeedApplication specialApplication;
28 |
29 | private final int PORT;
30 |
31 | public SpecialSpeedServer() {
32 | Properties props = ConfigUtil.getProps("web-server.properties");
33 | PORT = Integer.parseInt(props.getProperty("api.port"));
34 | component = new Component();
35 | specialApplication = new SpecialSpeedApplication();
36 | }
37 |
38 | /**
39 | * 主函数
40 | */
41 | public static void main(String[] args) {
42 |
43 | SpecialSpeedServer specialServer = new SpecialSpeedServer();
44 | specialServer.start();
45 | }
46 |
47 | public void start() {
48 | component.getServers().add(Protocol.HTTP, PORT);
49 | try {
50 | component.getDefaultHost().attach("/special", specialApplication);
51 | ReplaceConvert.configureJacksonConverter();
52 | component.start();
53 | } catch (Exception e) {
54 | throw new RuntimeException(e);
55 | }
56 | }
57 |
58 | public void stop() {
59 | try {
60 | component.stop();
61 | specialApplication.stop();
62 | } catch (Exception e) {
63 | throw new RuntimeException(e);
64 | }
65 | }
66 |
67 | }
68 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/resources/cache-config.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### Mater-Slave (For Replicating Record-Key,Index-Data Caching) #####
3 | # Product
4 | redis.rp.master=192.168.32.19
5 | redis.rp.slave=192.168.32.20
6 | # Testing
7 | #redis.rp.master=192.168.31.20
8 | #redis.rp.slave=192.168.31.21
9 |
10 | ##### Message-Queue (For Index-Data Caching) #####
11 | # Product
12 | redis.mq.server=192.168.32.20
13 | # Testing
14 | #redis.mq.server=192.168.31.XX
15 |
16 | ##### Expired-Queue (For Firsttime Caching) #####
17 | # Product
18 | redis.ft.server=192.168.32.18
19 | # Testing
20 | #redis.ft.server=192.168.31.XX
21 |
22 | ##### Port #####
23 | redis.rp.port=16379
24 | redis.mq.port=6379
25 | redis.ft.port=6379
26 |
27 | ##### Password #####
28 | redis.password=zxsoft
--------------------------------------------------------------------------------
/sentiment-web/src/main/resources/data_db.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### Database #####
3 | # Product
4 | sent.db.url=jdbc:mysql://192.168.32.17:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
5 | # Testing
6 | #sent.db.url=jdbc:mysql://192.168.31.23:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
7 | #sent.db.url=jdbc:mysql://192.168.31.23:3306/sentiment_oa?useUnicode=true&characterEncoding=utf-8
8 |
9 | ##### Password #####
10 | sent.db.username=sentimentrecords
11 | sent.db.password=zn/iACQ/Xh19+W6Ot2MghQ==
12 |
13 | ##### Localhost #####
14 | #sent.db.url=jdbc:mysql://localhost:3306/sentiment_records?useUnicode=true&characterEncoding=utf-8
15 | #sent.db.username=root
16 | #sent.db.password=root
--------------------------------------------------------------------------------
/sentiment-web/src/main/resources/logback.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %d{ISO8601} [%thread] %-5level %logger{36} [Line:%-3L] - %msg%n
8 |
9 |
10 |
11 | INFO
12 | ACCEPT
13 | DENY
14 |
15 |
16 |
17 |
19 | logs/sentiment-web.log
20 |
21 | %d{ISO8601} [%thread] %-5level %logger{36} [Line:%-3L] - %msg%n
22 |
23 |
24 |
25 | INFO
26 |
27 |
28 | logs/sentiment-web.log.%d{yyyy-MM-dd}.gz
29 | 30
30 |
31 |
32 |
33 |
34 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
--------------------------------------------------------------------------------
/sentiment-web/src/main/resources/oracle_db.properties:
--------------------------------------------------------------------------------
1 | # db params of localhost
2 | db_url=jdbc:oracle:thin:@192.168.3.10:1521:yqjk
3 | db_username=yqjk
4 | db_password=yqjk
--------------------------------------------------------------------------------
/sentiment-web/src/main/resources/solr_params.properties:
--------------------------------------------------------------------------------
1 |
2 | ##### SolrCloud #####
3 | collection=sentiment
4 | zookeeper_connect_timeout=50000
5 | zookeeper_client_timeout=50000
6 | #zookeeper_cloud=leader:2181
7 | # Product
8 | zookeeper_cloud=192.168.32.11:2181,192.168.32.12:2181,192.168.32.13:2181,192.168.32.14:2181,192.168.32.15:2181,192.168.32.16:2181
9 | # Testing
10 | #zookeeper_cloud=192.168.31.11:2181,192.168.31.12:2181,192.168.31.20:2181,192.168.31.21:2181,192.168.31.26:2181,192.168.31.27:2181
11 |
12 | ##### Fetch Size #####
13 | fetch_size=20000
--------------------------------------------------------------------------------
/sentiment-web/src/main/resources/web-server.properties:
--------------------------------------------------------------------------------
1 | httpConn.maxTotal=10000
2 | httpConn.maxPerRoute=5000
3 | api.port=8900
4 |
--------------------------------------------------------------------------------
/sentiment-web/src/test/java/zx/soft/sent/web/json/JsonTest.java:
--------------------------------------------------------------------------------
1 | package zx.soft.sent.web.json;
2 |
3 | import org.codehaus.jackson.JsonParser;
4 | import org.codehaus.jackson.map.ObjectMapper;
5 | import org.junit.Before;
6 | import org.junit.Test;
7 |
8 | public class JsonTest {
9 |
10 | private ObjectMapper om;
11 |
12 | @Before
13 | public void initOM() {
14 | om = new ObjectMapper();
15 | om.configure(JsonParser.Feature.ALLOW_COMMENTS, true);
16 | }
17 |
18 | @Test
19 | public void test1() throws java.io.IOException {
20 | om.readTree("/* (C) 2099 Yoyodyne Inc. */\n{ \"foo\": \"bar©\" }\n".getBytes("UTF-8"));
21 | }
22 |
23 | @Test
24 | public void test2() throws java.io.IOException {
25 | om.readTree("/* © 2099 Yoyodyne Inc. */\n{ \"foo\": \"bar©\" }\n".getBytes("UTF-8"));
26 | }
27 |
28 | }
29 |
--------------------------------------------------------------------------------
/sentiment-web/src/test/resources/index_data/autmsearch:
--------------------------------------------------------------------------------
1 | {"num":10,"records":[{"id":"123456","platform":2,"mid":"","username":0,"nickname":"","original_uid":0,"original_name":"","original_title":"","original_url":"","url":"","home_url":"","title":"","type":"","content":"合山论坛发图片教程第一点击发帖按钮,如下图下载 (20.77 KB)2010-10-20 14:57然后点击浏览按钮,如下图所示点击浏览按钮之后,就可以通系统下拉按钮找到你所要发布的图片所在电脑中的位置,然后选中要发布的图片,最后点击打开,具体操作如下图下载 (28.64 KB)2010-10-20 14:57当你点击打开按钮后就会进入下图下载 (19.6 KB)2010-10-20 14:57然后,你就可以点击上传按钮,之后会有个上传等待的过程,如下图所示下载 (15.56 KB)2010-10-20 14:57过了一会儿,你所上传的图片完成后会有下图所示下载 (18.13 KB)2010-10-20 14:57你点击确定后,即完成了图片的上传,但是图片还没有发布到论坛你还要进行如下操作,图片描述你可以不写,如下所示下载 (21.1 KB)2010-10-20 14:57然后,将鼠标在空白处点击,会有个光标闪东,然后你就点击你刚才上传的图片,如下所示下载 (19.98 KB)2010-10-20 14:57之后点击发布按钮就可以完成图片的发布了,如下图下载 (26.45 KB)2010-10-20 14:57","comment_count":0,"read_count":0,"favorite_count":0,"attitude_count":0,"repost_count":0,"video_url":"","pic_url":"","voice_url":"","timestamp":1397470718,"source_id":0,"lasttime":0,"server_id":0,"identify_id":0,"identify_md5":"","keyword":"","first_time":0,"update_time":0,"ip":"","location":"","geo":"","receive_addr":"","append_addr":"","send_addr":"","source_name":"","country_code":0,"location_code":0},{"id":"456","platform":4,"mid":"","username":0,"nickname":"","original_uid":0,"original_name":"","original_title":"","original_url":"","url":"","home_url":"","title":"","type":"","content":"","comment_count":0,"read_count":0,"favorite_count":0,"attitude_count":0,"repost_count":0,"video_url":"","pic_url":"","voice_url":"","timestamp":1397384318,"source_id":0,"lasttime":0,"server_id":0,"identify_id":0,"identify_md5":"","keyword":"","first_time":0,"update_time":0,"ip":"","location":"","geo":"","receive_addr":"","append_addr":"","send_addr":"","source_name":"","country_code":0,"location_code":0}]}
--------------------------------------------------------------------------------
/sentiment-web/src/test/resources/index_data/email:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wgybzbrobot/sentiment-search/df50eef8f82fbdc4549d1cfffb0d0b393a04f7b5/sentiment-web/src/test/resources/index_data/email
--------------------------------------------------------------------------------
/sentiment-web/src/test/resources/index_data/postData:
--------------------------------------------------------------------------------
1 | {"num":2,"records":[{"id":"123456789","platform":7,"mid":"123abcdef","username":"987654321","nickname":"wgybzb","original_id":"5648333","original_uid":"256339988","original_name":"owgybzb","original_title":"原创标题","original_url":"http://www.baidu.com","url":"http://www.pp.cc","home_url":"http://www.google.com","title":"标题","type":"美容美食","isharmful":true,"content":"这是一条测试数据","comment_count":100,"read_count":200,"favorite_count":300,"attitude_count":400,"repost_count":500,"video_url":"http://www.video.vom","pic_url":"http://www.pic.com","voice_url":"http://www.voice.com","timestamp":129856473,"source_id":153,"lasttime":985647213,"server_id":5,"identify_id":125633,"identify_md5":"identifymd5value","keyword":"美食娱乐","first_time":1566423587,"update_time":1426879123,"ip":"192.168.1.100","location":"安徽省合肥市","geo":"经度:120.2366554,纬度:50.122599","receive_addr":"wanggang@zxils.com","append_addr":"wanggang@pp.cc","send_addr":"wgybzb@sina.cn","source_name":"新浪微博","source_type":5,"country_code":1,"location_code":2130123,"province_code":34,"city_code":12},{"id":"987654321","platform":7,"mid":"456jdjdkff","username":"2564788","nickname":"wgybzb1","original_id":"5648333","original_uid":"256339988","original_name":"owgybzb1","original_title":"原创标题","original_url":"http://www.baidu.com","url":"http://www.pp.cc","home_url":"http://www.google.com","title":"标题","type":"美容美食","isharmful":false,"content":"这是一条测试数据","comment_count":100,"read_count":200,"favorite_count":300,"attitude_count":400,"repost_count":500,"video_url":"http://www.video.vom","pic_url":"http://www.pic.com","voice_url":"http://www.voice.com","timestamp":129856473,"source_id":153,"lasttime":985647213,"server_id":5,"identify_id":125633,"identify_md5":"identifymd5value","keyword":"美食娱乐","first_time":1566423587,"update_time":1426879123,"ip":"192.168.1.100","location":"安徽省合肥市","geo":"经度:120.2366554,纬度:50.122599","receive_addr":"wanggang@zxils.com","append_addr":"wanggang@pp.cc","send_addr":"wgybzb@sina.cn","source_name":"新浪微博","source_type":5,"country_code":1,"location_code":2130123,"province_code":34,"city_code":12}]}
--------------------------------------------------------------------------------
/sentiment-web/src/test/resources/index_data/qqgroup:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wgybzbrobot/sentiment-search/df50eef8f82fbdc4549d1cfffb0d0b393a04f7b5/sentiment-web/src/test/resources/index_data/qqgroup
--------------------------------------------------------------------------------
/sentiment-web/src/test/resources/index_data/record:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/wgybzbrobot/sentiment-search/df50eef8f82fbdc4549d1cfffb0d0b393a04f7b5/sentiment-web/src/test/resources/index_data/record
--------------------------------------------------------------------------------
/sentiment-web/src/test/resources/index_data/weibo:
--------------------------------------------------------------------------------
1 | {"id":"testweibo1","platform":3,"mid":"","username":0,"nickname":"王可心521","original_uid":0,"original_name":"","original_title":"","original_url":"","url":"","home_url":"","title":"","type":"","content":"看我的发型肿么样?@王可心521","comment_count":0,"read_count":0,"favorite_count":0,"attitude_count":0,"repost_count":0,"video_url":"","pic_url":"","voice_url":"","timestamp":"Mon Aug 26 16:18:00 +0800 2013","source_id":54,"lasttime":"Fri Aug 30 16:50:07 +0800 2013","server_id":454,"identify_id":1,"identify_md5":"","keyword":"肿么","first_time":null,"update_time":"Tue Sep 03 10:35:23 +0800 2013","ip":"","location":"","geo":"","receive_addr":"","append_addr":"","send_addr":"","source_name":"","country_code":0,"location_code":0}
--------------------------------------------------------------------------------
/sentiment-web/src/test/resources/logback-test.xml:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
7 | %d{MMdd.HHmmss.SSS} [%-20t] [%-5p] [%-20c] [L:%-3L] - %m%n
8 |
9 |
10 |
11 |
12 |
13 |
14 |
15 |
16 |
17 |
18 |
19 |
--------------------------------------------------------------------------------
/sentiment-web/src/test/resources/test-indexdata:
--------------------------------------------------------------------------------
1 | {"num":1,"records":[{"id":"sentiment","platform":10,"mid":"123456789987654321","username":"zxsoft","nickname":"中新舆情","original_id":"original_sentiment","original_uid":"original_zxsoft","original_name":"original_中新软件","original_title":"original_标题","original_url":"http://www.orignal_url.com","url":"http://www.url.com","home_url":"http://www.home_url.com","title":"标题","type":"所属类型","isharmful":true,"content":"测试内容","comment_count":10,"read_count":20,"favorite_count":30,"attitude_count":40,"repost_count":50,"video_url":"http://www.video_url.com","pic_url":"htpp://www.pic_url.com","voice_url":"http://www.voice_url.com","timestamp":1416038921,"source_id":70,"lasttime":1416125321,"server_id":90,"identify_id":100,"identify_md5":"abcdefg123456789","keyword":"关键词","first_time":1416211721,"update_time":1416298121,"ip":"192.168.32.45","location":"安徽省合肥市","geo":"经纬度信息","receive_addr":"receive@gmail.com","append_addr":"append@gmail.com","send_addr":"send@gmail.com","source_name":"新浪微博","source_type":121,"country_code":122,"location_code":123,"province_code":124,"city_code":125}]}
--------------------------------------------------------------------------------
/sentiment-web/src/test/resources/test-specialdata:
--------------------------------------------------------------------------------
1 | [{"identify":"absbhdfhfjfi","name":"专题1","keywords":"(合肥 and 警察) not 打人","start":"2014-08-25 00:00:00","end":"2014-08-25 23:59:59","hometype":0},{"identify":"djdjfkfklglg","name":"专题2","keywords":"(安徽 and 城管) not 暴力执法","start":"2013-08-25 00:00:00","end":"2013-08-25 23:59:59","hometype":2}]
--------------------------------------------------------------------------------