├── WeiboAnalyzer ├── traningText.txt ├── bin │ ├── ext.dic │ ├── weibo4j │ │ ├── Tags.class │ │ ├── Oauth.class │ │ ├── Place.class │ │ ├── Search.class │ │ ├── Trend.class │ │ ├── Users.class │ │ ├── Weibo.class │ │ ├── Account.class │ │ ├── Comments.class │ │ ├── Favorite.class │ │ ├── Reminds.class │ │ ├── ShortUrl.class │ │ ├── Timeline.class │ │ ├── model │ │ │ ├── .DS_Store │ │ │ ├── IDs.class │ │ │ ├── Tag.class │ │ │ ├── Query.class │ │ │ ├── Trend.class │ │ │ ├── User.class │ │ │ ├── Comment.class │ │ │ ├── Emotion.class │ │ │ ├── Gender.class │ │ │ ├── Paging.class │ │ │ ├── School.class │ │ │ ├── Source.class │ │ │ ├── Status.class │ │ │ ├── Trends.class │ │ │ ├── Version.class │ │ │ ├── Visible.class │ │ │ ├── Constants.class │ │ │ ├── Favorites.class │ │ │ ├── TagWapper.class │ │ │ ├── UserTrend.class │ │ │ ├── UserWapper.class │ │ │ ├── ApiRateLimits.class │ │ │ ├── CommentWapper.class │ │ │ ├── Configuration.class │ │ │ ├── FavoritesTag.class │ │ │ ├── PostParameter.class │ │ │ ├── StatusWapper.class │ │ │ ├── WeiboResponse.class │ │ │ ├── RateLimitStatus.class │ │ │ ├── WeiboException.class │ │ │ ├── MySSLSocketFactory.class │ │ │ └── MySSLSocketFactory$TrustAnyTrustManager.class │ │ ├── Friendships.class │ │ ├── Suggestion.class │ │ ├── PublicService.class │ │ ├── http │ │ │ ├── Response.class │ │ │ ├── AccessToken.class │ │ │ ├── HTMLEntity.class │ │ │ ├── HttpClient.class │ │ │ ├── Response$1.class │ │ │ ├── BASE64Encoder.class │ │ │ └── HttpClient$ByteArrayPart.class │ │ ├── org │ │ │ └── json │ │ │ │ ├── CDL.class │ │ │ │ ├── HTTP.class │ │ │ │ ├── Cookie.class │ │ │ │ ├── CookieList.class │ │ │ │ ├── JSONArray.class │ │ │ │ ├── JSONObject.class │ │ │ │ ├── JSONString.class │ │ │ │ ├── JSONWriter.class │ │ │ │ ├── HTTPTokener.class │ │ │ │ ├── JSONStringer.class │ │ │ │ ├── JSONTokener.class │ │ │ │ ├── JSONException.class │ │ │ │ └── JSONObject$Null.class │ │ └── util │ │ │ ├── WeiboConfig.class │ │ │ ├── URLEncodeUtils.class │ │ │ └── BareBonesBrowserLaunch.class │ ├── DataMining │ │ ├── Doc.class │ │ ├── Global.class │ │ ├── People.class │ │ ├── DBHander.class │ │ ├── Liexicon.class │ │ ├── MyFilter.class │ │ ├── PeopleQueue.class │ │ ├── SetManager.class │ │ ├── dataMining.class │ │ ├── sampleDoc.class │ │ ├── sampleLex.class │ │ ├── splitSystem.class │ │ ├── splitSystem$wordCount.class │ │ └── splitSystem$wordCount$wordAndCount.class │ ├── TestCase │ │ ├── zplTest.class │ │ ├── FilterTest.class │ │ ├── TestFilter.class │ │ ├── testExcel.class │ │ ├── AnalyzerTest.class │ │ ├── GetWeiboTest.class │ │ └── TestStatistic.class │ ├── DataAnalyzer │ │ ├── Global.class │ │ ├── DBHander.class │ │ ├── docVector.class │ │ ├── zplKMeans.class │ │ ├── TermVector.class │ │ ├── zplCluster.class │ │ └── dataAnalyzer.class │ ├── org │ │ └── wltea │ │ │ └── analyzer │ │ │ ├── dic │ │ │ ├── Hit.class │ │ │ ├── DictSegment.class │ │ │ ├── Dictionary.class │ │ │ └── quantifier.dic │ │ │ ├── core │ │ │ ├── Lexeme.class │ │ │ ├── ISegmenter.class │ │ │ ├── LexemePath.class │ │ │ ├── CJKSegmenter.class │ │ │ ├── CharacterUtil.class │ │ │ ├── IKArbitrator.class │ │ │ ├── IKSegmenter.class │ │ │ ├── QuickSortSet.class │ │ │ ├── AnalyzeContext.class │ │ │ ├── LetterSegmenter.class │ │ │ ├── QuickSortSet$Cell.class │ │ │ └── CN_QuantifierSegmenter.class │ │ │ ├── cfg │ │ │ ├── Configuration.class │ │ │ └── DefaultConfig.class │ │ │ ├── lucene │ │ │ ├── IKAnalyzer.class │ │ │ └── IKTokenizer.class │ │ │ └── query │ │ │ ├── SWMCQueryBuilder.class │ │ │ ├── IKQueryExpressionParser.class │ │ │ └── IKQueryExpressionParser$Element.class │ ├── config.properties │ ├── IKAnalyzer.cfg.xml │ ├── stopword.dic │ └── log4j.properties ├── src │ ├── ext.dic │ ├── weibo4j │ │ ├── model │ │ │ ├── .DS_Store │ │ │ ├── Constants.java │ │ │ ├── Gender.java │ │ │ ├── TagWapper.java │ │ │ ├── Source.java │ │ │ ├── Visible.java │ │ │ ├── StatusWapper.java │ │ │ ├── CommentWapper.java │ │ │ ├── ApiRateLimits.java │ │ │ ├── UserWapper.java │ │ │ ├── Version.java │ │ │ ├── School.java │ │ │ ├── UserTrend.java │ │ │ ├── FavoritesTag.java │ │ │ ├── WeiboException.java │ │ │ ├── Trend.java │ │ │ ├── Favorites.java │ │ │ ├── MySSLSocketFactory.java │ │ │ ├── Emotion.java │ │ │ ├── Tag.java │ │ │ └── IDs.java │ │ ├── Weibo.java │ │ ├── org │ │ │ └── json │ │ │ │ ├── JSONException.java │ │ │ │ ├── JSONString.java │ │ │ │ ├── HTTPTokener.java │ │ │ │ ├── JSONStringer.java │ │ │ │ └── CookieList.java │ │ ├── util │ │ │ ├── WeiboConfig.java │ │ │ ├── BareBonesBrowserLaunch.java │ │ │ └── URLEncodeUtils.java │ │ ├── Reminds.java │ │ ├── http │ │ │ ├── ImageItem.java │ │ │ ├── AccessToken.java │ │ │ └── BASE64Encoder.java │ │ ├── Users.java │ │ ├── ShortUrl.java │ │ ├── Place.java │ │ ├── Account.java │ │ ├── Oauth.java │ │ ├── Search.java │ │ └── PublicService.java │ ├── DataMining │ │ ├── sampleDoc.java │ │ ├── MyFilter.java │ │ ├── sampleLex.java │ │ ├── Doc.java │ │ ├── SetManager.java │ │ ├── Liexicon.java │ │ ├── dataMining.java │ │ ├── PeopleQueue.java │ │ ├── Global.java │ │ ├── People.java │ │ └── splitSystem.java │ ├── TestCase │ │ ├── FilterTest.java │ │ ├── AnalyzerTest.java │ │ ├── GetWeiboTest.java │ │ ├── TestStatistic.java │ │ ├── TestFilter.java │ │ ├── testExcel.java │ │ └── zplTest.java │ ├── DataAnalyzer │ │ ├── Global.java │ │ ├── dataAnalyzer.java │ │ ├── TermVector.java │ │ ├── zplCluster.java │ │ └── docVector.java │ ├── config.properties │ ├── IKAnalyzer.cfg.xml │ ├── stopword.dic │ ├── log4j.properties │ └── org │ │ └── wltea │ │ └── analyzer │ │ ├── core │ │ ├── ISegmenter.java │ │ ├── CharacterUtil.java │ │ ├── CJKSegmenter.java │ │ ├── IKArbitrator.java │ │ └── IKSegmenter.java │ │ ├── cfg │ │ └── Configuration.java │ │ ├── lucene │ │ ├── IKAnalyzer.java │ │ └── IKTokenizer.java │ │ └── dic │ │ ├── quantifier.dic │ │ └── Hit.java ├── lib │ ├── jxl-2.6.10.jar │ ├── commons-codec.jar │ ├── log4j-1.2.16.jar │ ├── weibo4j-oauth2.jar │ ├── commons-logging-1.1.jar │ ├── jackson-all-1.8.5.jar │ ├── lucene-core-4.2.1.jar │ ├── commons-httpclient-3.1.jar │ ├── lucene-queryparser-4.2.1.jar │ ├── lucene-analyzers-common-4.2.1.jar │ └── mysql-connector-java-5.1.20-bin.jar ├── .settings │ ├── org.eclipse.m2e.core.prefs │ ├── org.maven.ide.eclipse.prefs │ └── org.eclipse.jdt.core.prefs ├── .project ├── .classpath └── pom.xml ├── 微博舆情热点分析系统11.pdf ├── README.md └── weiboinfo.sql /WeiboAnalyzer/traningText.txt: -------------------------------------------------------------------------------- 1 | -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/ext.dic: -------------------------------------------------------------------------------- 1 | 诛仙 2 | 诛仙2 3 | 梦幻诛仙 4 | 梦幻诛仙2 -------------------------------------------------------------------------------- /WeiboAnalyzer/src/ext.dic: -------------------------------------------------------------------------------- 1 | 诛仙 2 | 诛仙2 3 | 梦幻诛仙 4 | 梦幻诛仙2 -------------------------------------------------------------------------------- /微博舆情热点分析系统11.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/微博舆情热点分析系统11.pdf -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | WeiboCluster 2 | ============ 3 | 4 | 毕业设计,通过新浪微博api获取网上的微博信息,然后通过一个简单的k-means算法进行简单的分类,以便找到热点事件 5 | -------------------------------------------------------------------------------- /WeiboAnalyzer/lib/jxl-2.6.10.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/lib/jxl-2.6.10.jar -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Tags.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Tags.class -------------------------------------------------------------------------------- /WeiboAnalyzer/lib/commons-codec.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/lib/commons-codec.jar -------------------------------------------------------------------------------- /WeiboAnalyzer/lib/log4j-1.2.16.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/lib/log4j-1.2.16.jar -------------------------------------------------------------------------------- /WeiboAnalyzer/lib/weibo4j-oauth2.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/lib/weibo4j-oauth2.jar -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/Doc.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/Doc.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Oauth.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Oauth.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Place.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Place.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Search.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Search.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Trend.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Trend.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Users.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Users.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Weibo.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Weibo.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/Global.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/Global.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/People.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/People.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/TestCase/zplTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/TestCase/zplTest.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Account.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Account.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Comments.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Comments.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Favorite.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Favorite.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Reminds.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Reminds.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/ShortUrl.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/ShortUrl.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Timeline.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Timeline.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/.DS_Store -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/IDs.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/IDs.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Tag.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Tag.class -------------------------------------------------------------------------------- /WeiboAnalyzer/lib/commons-logging-1.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/lib/commons-logging-1.1.jar -------------------------------------------------------------------------------- /WeiboAnalyzer/lib/jackson-all-1.8.5.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/lib/jackson-all-1.8.5.jar -------------------------------------------------------------------------------- /WeiboAnalyzer/lib/lucene-core-4.2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/lib/lucene-core-4.2.1.jar -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/.DS_Store: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/src/weibo4j/model/.DS_Store -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataAnalyzer/Global.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataAnalyzer/Global.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/DBHander.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/DBHander.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/Liexicon.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/Liexicon.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/MyFilter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/MyFilter.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/TestCase/FilterTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/TestCase/FilterTest.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/TestCase/TestFilter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/TestCase/TestFilter.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/TestCase/testExcel.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/TestCase/testExcel.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Friendships.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Friendships.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/Suggestion.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/Suggestion.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Query.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Query.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Trend.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Trend.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/User.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/User.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataAnalyzer/DBHander.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataAnalyzer/DBHander.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataAnalyzer/docVector.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataAnalyzer/docVector.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataAnalyzer/zplKMeans.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataAnalyzer/zplKMeans.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/PeopleQueue.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/PeopleQueue.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/SetManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/SetManager.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/dataMining.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/dataMining.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/sampleDoc.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/sampleDoc.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/sampleLex.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/sampleLex.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/splitSystem.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/splitSystem.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/TestCase/AnalyzerTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/TestCase/AnalyzerTest.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/TestCase/GetWeiboTest.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/TestCase/GetWeiboTest.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/TestCase/TestStatistic.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/TestCase/TestStatistic.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/PublicService.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/PublicService.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/http/Response.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/http/Response.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Comment.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Comment.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Emotion.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Emotion.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Gender.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Gender.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Paging.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Paging.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/School.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/School.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Source.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Source.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Status.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Status.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Trends.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Trends.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Version.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Version.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Visible.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Visible.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/CDL.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/CDL.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/HTTP.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/HTTP.class -------------------------------------------------------------------------------- /WeiboAnalyzer/lib/commons-httpclient-3.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/lib/commons-httpclient-3.1.jar -------------------------------------------------------------------------------- /WeiboAnalyzer/lib/lucene-queryparser-4.2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/lib/lucene-queryparser-4.2.1.jar -------------------------------------------------------------------------------- /WeiboAnalyzer/.settings/org.eclipse.m2e.core.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | resolveWorkspaceProjects=true 4 | version=1 5 | -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataAnalyzer/TermVector.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataAnalyzer/TermVector.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataAnalyzer/zplCluster.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataAnalyzer/zplCluster.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/http/AccessToken.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/http/AccessToken.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/http/HTMLEntity.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/http/HTMLEntity.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/http/HttpClient.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/http/HttpClient.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/http/Response$1.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/http/Response$1.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Constants.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Constants.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Favorites.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Favorites.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/TagWapper.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/TagWapper.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/UserTrend.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/UserTrend.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/UserWapper.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/UserWapper.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/Cookie.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/Cookie.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/util/WeiboConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/util/WeiboConfig.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataAnalyzer/dataAnalyzer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataAnalyzer/dataAnalyzer.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/dic/Hit.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/dic/Hit.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/http/BASE64Encoder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/http/BASE64Encoder.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/ApiRateLimits.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/ApiRateLimits.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/CommentWapper.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/CommentWapper.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/Configuration.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/Configuration.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/FavoritesTag.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/FavoritesTag.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/PostParameter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/PostParameter.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/StatusWapper.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/StatusWapper.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/WeiboResponse.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/WeiboResponse.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/CookieList.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/CookieList.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/JSONArray.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/JSONArray.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/JSONObject.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/JSONObject.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/JSONString.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/JSONString.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/JSONWriter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/JSONWriter.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/util/URLEncodeUtils.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/util/URLEncodeUtils.class -------------------------------------------------------------------------------- /WeiboAnalyzer/lib/lucene-analyzers-common-4.2.1.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/lib/lucene-analyzers-common-4.2.1.jar -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/RateLimitStatus.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/RateLimitStatus.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/WeiboException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/WeiboException.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/HTTPTokener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/HTTPTokener.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/JSONStringer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/JSONStringer.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/JSONTokener.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/JSONTokener.class -------------------------------------------------------------------------------- /WeiboAnalyzer/lib/mysql-connector-java-5.1.20-bin.jar: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/lib/mysql-connector-java-5.1.20-bin.jar -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/splitSystem$wordCount.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/splitSystem$wordCount.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/core/Lexeme.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/core/Lexeme.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/MySSLSocketFactory.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/MySSLSocketFactory.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/JSONException.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/JSONException.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/org/json/JSONObject$Null.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/org/json/JSONObject$Null.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/core/ISegmenter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/core/ISegmenter.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/core/LexemePath.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/core/LexemePath.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/dic/DictSegment.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/dic/DictSegment.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/dic/Dictionary.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/dic/Dictionary.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/cfg/Configuration.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/cfg/Configuration.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/cfg/DefaultConfig.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/cfg/DefaultConfig.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/core/CJKSegmenter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/core/CJKSegmenter.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/core/CharacterUtil.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/core/CharacterUtil.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/core/IKArbitrator.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/core/IKArbitrator.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/core/IKSegmenter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/core/IKSegmenter.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/core/QuickSortSet.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/core/QuickSortSet.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/lucene/IKAnalyzer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/lucene/IKAnalyzer.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/lucene/IKTokenizer.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/lucene/IKTokenizer.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/http/HttpClient$ByteArrayPart.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/http/HttpClient$ByteArrayPart.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/util/BareBonesBrowserLaunch.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/util/BareBonesBrowserLaunch.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/core/AnalyzeContext.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/core/AnalyzeContext.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/core/LetterSegmenter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/core/LetterSegmenter.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/core/QuickSortSet$Cell.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/core/QuickSortSet$Cell.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/query/SWMCQueryBuilder.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/query/SWMCQueryBuilder.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/DataMining/splitSystem$wordCount$wordAndCount.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/DataMining/splitSystem$wordCount$wordAndCount.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/core/CN_QuantifierSegmenter.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/core/CN_QuantifierSegmenter.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/query/IKQueryExpressionParser.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/query/IKQueryExpressionParser.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/weibo4j/model/MySSLSocketFactory$TrustAnyTrustManager.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/weibo4j/model/MySSLSocketFactory$TrustAnyTrustManager.class -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/query/IKQueryExpressionParser$Element.class: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/royzhao/WeiboCluster/HEAD/WeiboAnalyzer/bin/org/wltea/analyzer/query/IKQueryExpressionParser$Element.class -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/Constants.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | public class Constants { 4 | public static final String X_AUTH_MODE = "client_auth"; 5 | public static final String UPLOAD_MODE = "pic"; 6 | } 7 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataMining/sampleDoc.java: -------------------------------------------------------------------------------- 1 | package DataMining; 2 | 3 | public class sampleDoc extends Doc { 4 | int isad; 5 | public sampleDoc() { 6 | } 7 | public sampleDoc(int isad){ 8 | this.isad = isad; 9 | } 10 | } 11 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataMining/MyFilter.java: -------------------------------------------------------------------------------- 1 | package DataMining; 2 | 3 | public class MyFilter { 4 | public MyFilter() { 5 | // TODO Auto-generated constructor stub 6 | } 7 | 8 | public boolean isad(String text){ 9 | return true; 10 | } 11 | } 12 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/TestCase/FilterTest.java: -------------------------------------------------------------------------------- 1 | package TestCase; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | public class FilterTest { 8 | 9 | @Test 10 | public void test() { 11 | fail("Not yet implemented"); 12 | } 13 | 14 | } 15 | -------------------------------------------------------------------------------- /WeiboAnalyzer/.settings/org.maven.ide.eclipse.prefs: -------------------------------------------------------------------------------- 1 | activeProfiles= 2 | eclipse.preferences.version=1 3 | fullBuildGoals=process-test-resources 4 | resolveWorkspaceProjects=false 5 | resourceFilterGoals=process-resources resources\:testResources 6 | skipCompilerPlugin=true 7 | version=1 8 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataMining/sampleLex.java: -------------------------------------------------------------------------------- 1 | package DataMining; 2 | 3 | public class sampleLex extends Liexicon { 4 | private double p; 5 | private int num; 6 | public sampleLex(String lex){ 7 | this._lexicon = lex; 8 | num = 1; 9 | 10 | } 11 | public void updateP(){ 12 | 13 | } 14 | } 15 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataAnalyzer/Global.java: -------------------------------------------------------------------------------- 1 | package DataAnalyzer; 2 | 3 | public class Global { 4 | 5 | public static int weidu; 6 | public static int docNum; 7 | public static int _k; 8 | 9 | public static double MAX = 10000000; 10 | 11 | public static DBHander dBer = new DBHander(); 12 | } 13 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/Gender.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | /** 4 | * @author SinaWeibo 5 | * 6 | */ 7 | public enum Gender { 8 | MALE, FEMALE; 9 | public static String valueOf(Gender gender) { 10 | int ordinal= gender.ordinal(); 11 | if(ordinal==0) 12 | return "m"; 13 | return "f"; 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/TestCase/AnalyzerTest.java: -------------------------------------------------------------------------------- 1 | package TestCase; 2 | 3 | import org.junit.Test; 4 | 5 | import DataAnalyzer.dataAnalyzer; 6 | 7 | public class AnalyzerTest { 8 | 9 | //case5 分析数据 10 | @Test 11 | public void testAnalyzer(){ 12 | dataAnalyzer ss = new dataAnalyzer(); 13 | ss.mainAnalyzer(); 14 | } 15 | 16 | } 17 | -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/config.properties: -------------------------------------------------------------------------------- 1 | client_ID =4060093582 2 | client_SERCRET =4807975c64165e87725cf4323933e347 3 | redirect_URI =https://api.weibo.com/oauth2/client.html 4 | baseURL=https://api.weibo.com/2/ 5 | accessTokenURL=https://api.weibo.com/oauth2/access_token 6 | authorizeURL=https://api.weibo.com/oauth2/authorize 7 | rmURL=https://rm.api.weibo.com/2/ -------------------------------------------------------------------------------- /WeiboAnalyzer/src/config.properties: -------------------------------------------------------------------------------- 1 | client_ID =4060093582 2 | client_SERCRET =4807975c64165e87725cf4323933e347 3 | redirect_URI =https://api.weibo.com/oauth2/client.html 4 | baseURL=https://api.weibo.com/2/ 5 | accessTokenURL=https://api.weibo.com/oauth2/access_token 6 | authorizeURL=https://api.weibo.com/oauth2/authorize 7 | rmURL=https://rm.api.weibo.com/2/ -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/Weibo.java: -------------------------------------------------------------------------------- 1 | package weibo4j; 2 | 3 | import weibo4j.http.HttpClient; 4 | 5 | public class Weibo implements java.io.Serializable { 6 | 7 | private static final long serialVersionUID = 4282616848978535016L; 8 | 9 | public HttpClient client = new HttpClient(); 10 | 11 | public void setToken(String token) { 12 | client.setToken(token); 13 | } 14 | 15 | } -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataAnalyzer/dataAnalyzer.java: -------------------------------------------------------------------------------- 1 | package DataAnalyzer; 2 | 3 | public class dataAnalyzer { 4 | public void mainAnalyzer(){ 5 | Global.dBer.connectDB(); 6 | zplKMeans kMeans; 7 | 8 | kMeans = new zplKMeans(20); 9 | kMeans.readVectorSet(); 10 | kMeans.initRandom(); 11 | kMeans.start(); 12 | kMeans.showAll(); 13 | Global.dBer.closeDB(); 14 | } 15 | } 16 | -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/IKAnalyzer.cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IK Analyzer 扩展配置 5 | 6 | ext.dic; 7 | 8 | 9 | stopword.dic; 10 | 11 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/IKAnalyzer.cfg.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | IK Analyzer 扩展配置 5 | 6 | ext.dic; 7 | 8 | 9 | stopword.dic; 10 | 11 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataMining/Doc.java: -------------------------------------------------------------------------------- 1 | package DataMining; 2 | 3 | public class Doc { 4 | protected int DocID; 5 | protected String DocCon; 6 | 7 | public void setDocID(int num){ 8 | DocID = num; 9 | } 10 | public void setCon(String con){ 11 | DocCon = con; 12 | } 13 | public int getDocID(){ 14 | return DocID; 15 | } 16 | public String getDocCon(){ 17 | return DocCon; 18 | } 19 | } 20 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/TestCase/GetWeiboTest.java: -------------------------------------------------------------------------------- 1 | package TestCase; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | import DataMining.dataMining; 8 | 9 | public class GetWeiboTest { 10 | 11 | //case1 测试数据获取模块 12 | @Test 13 | public void testMining() { 14 | dataMining testdata = new dataMining(); 15 | testdata.mainDataMining(); 16 | 17 | } 18 | 19 | } 20 | -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/stopword.dic: -------------------------------------------------------------------------------- 1 | a 2 | an 3 | and 4 | are 5 | as 6 | at 7 | be 8 | but 9 | by 10 | for 11 | if 12 | in 13 | into 14 | is 15 | it 16 | no 17 | not 18 | of 19 | on 20 | or 21 | such 22 | that 23 | the 24 | their 25 | then 26 | there 27 | these 28 | they 29 | this 30 | to 31 | was 32 | will 33 | with 34 | 也 35 | 了 36 | 仍 37 | 从 38 | 以 39 | 使 40 | 则 41 | 却 42 | 又 43 | 及 44 | 对 45 | 就 46 | 并 47 | 很 48 | 或 49 | 把 50 | 是 51 | 的 52 | 着 53 | 给 54 | 而 55 | 被 56 | 让 57 | 在 58 | 还 59 | 比 60 | 等 61 | 当 62 | 与 63 | 于 64 | 但 -------------------------------------------------------------------------------- /WeiboAnalyzer/src/stopword.dic: -------------------------------------------------------------------------------- 1 | a 2 | an 3 | and 4 | are 5 | as 6 | at 7 | be 8 | but 9 | by 10 | for 11 | if 12 | in 13 | into 14 | is 15 | it 16 | no 17 | not 18 | of 19 | on 20 | or 21 | such 22 | that 23 | the 24 | their 25 | then 26 | there 27 | these 28 | they 29 | this 30 | to 31 | was 32 | will 33 | with 34 | 也 35 | 了 36 | 仍 37 | 从 38 | 以 39 | 使 40 | 则 41 | 却 42 | 又 43 | 及 44 | 对 45 | 就 46 | 并 47 | 很 48 | 或 49 | 把 50 | 是 51 | 的 52 | 着 53 | 给 54 | 而 55 | 被 56 | 让 57 | 在 58 | 还 59 | 比 60 | 等 61 | 当 62 | 与 63 | 于 64 | 但 -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataMining/SetManager.java: -------------------------------------------------------------------------------- 1 | package DataMining; 2 | 3 | import java.util.List; 4 | 5 | public class SetManager { 6 | int sampleDocNum; 7 | public SetManager(){ 8 | 9 | } 10 | public SetManager(int isad){ 11 | if(isad == Global.ad){ 12 | 13 | } 14 | else { 15 | 16 | } 17 | } 18 | public void beginAnalyzer(){ 19 | 20 | } 21 | 22 | public int sampleNum(){ 23 | return sampleDocNum; 24 | } 25 | public List getlexlist(){ 26 | return null; 27 | } 28 | 29 | } 30 | -------------------------------------------------------------------------------- /WeiboAnalyzer/.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | WeiboAnalyzer 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.jdt.core.javabuilder 10 | 11 | 12 | 13 | 14 | org.eclipse.m2e.core.maven2Builder 15 | 16 | 17 | 18 | 19 | 20 | org.eclipse.m2e.core.maven2Nature 21 | org.eclipse.jdt.core.javanature 22 | 23 | 24 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/TestCase/TestStatistic.java: -------------------------------------------------------------------------------- 1 | package TestCase; 2 | import DataMining.*; 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | 7 | public class TestStatistic { 8 | 9 | SetManager adSet,unadSet; 10 | 11 | public TestStatistic(){ 12 | adSet = new SetManager(Global.ad); 13 | unadSet = new SetManager(Global.unad); 14 | 15 | } 16 | @Test 17 | public void test() { 18 | adSet.beginAnalyzer(); 19 | assertEquals(30, adSet.sampleNum()); 20 | assertNotNull(adSet.getlexlist()); 21 | unadSet.beginAnalyzer(); 22 | assertEquals(45, unadSet.sampleNum()); 23 | assertNotNull(unadSet.getlexlist()); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/TagWapper.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | import java.util.List; 4 | 5 | public class TagWapper { 6 | private List tags; 7 | private String id; 8 | 9 | public TagWapper(List tags, String id) { 10 | this.tags = tags; 11 | this.id = id; 12 | } 13 | public List getTags() { 14 | return tags; 15 | } 16 | public void setTags(List tags) { 17 | this.tags = tags; 18 | } 19 | public String getId() { 20 | return id; 21 | } 22 | public void setId(String id) { 23 | this.id = id; 24 | } 25 | @Override 26 | public String toString() { 27 | return "TagWapper [tags=" + tags + ", id=" + id + "]"; 28 | } 29 | 30 | } 31 | -------------------------------------------------------------------------------- /WeiboAnalyzer/.settings/org.eclipse.jdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | org.eclipse.jdt.core.compiler.codegen.inlineJsrBytecode=enabled 3 | org.eclipse.jdt.core.compiler.codegen.targetPlatform=1.7 4 | org.eclipse.jdt.core.compiler.codegen.unusedLocal=preserve 5 | org.eclipse.jdt.core.compiler.compliance=1.7 6 | org.eclipse.jdt.core.compiler.debug.lineNumber=generate 7 | org.eclipse.jdt.core.compiler.debug.localVariable=generate 8 | org.eclipse.jdt.core.compiler.debug.sourceFile=generate 9 | org.eclipse.jdt.core.compiler.problem.assertIdentifier=error 10 | org.eclipse.jdt.core.compiler.problem.enumIdentifier=error 11 | org.eclipse.jdt.core.compiler.problem.forbiddenReference=warning 12 | org.eclipse.jdt.core.compiler.source=1.7 13 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/TestCase/TestFilter.java: -------------------------------------------------------------------------------- 1 | package TestCase; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import org.junit.Test; 6 | import DataMining.*; 7 | public class TestFilter { 8 | String adtext; 9 | String unadtext; 10 | MyFilter filter; 11 | 12 | public TestFilter() { 13 | adtext = "[可怜]体毛多的女人伤不起啊[抓狂]手臂、腋下,腿上,各种毛毛各种忧啊[泪] 短袖短裙不敢穿,游泳露毛多尴尬[晕]不过这个夏天姐彻底翻身了,因为偶找到个秘密武器 一抹一擦,毛毛彻底掉光,皮肤变得白嫩润滑,神马脱毛膏,蜡纸跟它比都弱爆了[弱]好东西分享啦>>> http://t.cn/zYseWsE"; 14 | unadtext= "#五四青年节#五一过去五四又来,这样的节日早已经淡忘,尽管自己已不再年轻!"; 15 | filter = new MyFilter(); 16 | } 17 | @Test 18 | public void Adtest() { 19 | assertTrue(filter.isad(adtext)); 20 | } 21 | @Test 22 | public void unAdtest(){ 23 | assertFalse(filter.isad(unadtext)); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/org/json/JSONException.java: -------------------------------------------------------------------------------- 1 | package weibo4j.org.json; 2 | 3 | /** 4 | * The JSONException is thrown by the JSON.org classes then things are amiss. 5 | * @author JSON.org 6 | * @version 2008-09-18 7 | */ 8 | public class JSONException extends Exception { 9 | private Throwable cause; 10 | 11 | /** 12 | * Constructs a JSONException with an explanatory message. 13 | * @param message Detail about the reason for the exception. 14 | */ 15 | public JSONException(String message) { 16 | super(message); 17 | } 18 | 19 | public JSONException(Throwable t) { 20 | super(t.getMessage()); 21 | this.cause = t; 22 | } 23 | 24 | public Throwable getCause() { 25 | return this.cause; 26 | } 27 | } 28 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/org/json/JSONString.java: -------------------------------------------------------------------------------- 1 | package weibo4j.org.json; 2 | /** 3 | * The JSONString interface allows a toJSONString() 4 | * method so that a class can change the behavior of 5 | * JSONObject.toString(), JSONArray.toString(), 6 | * and JSONWriter.value(Object). The 7 | * toJSONString method will be used instead of the default behavior 8 | * of using the Object's toString() method and quoting the result. 9 | */ 10 | public interface JSONString { 11 | /** 12 | * The toJSONString method allows a class to produce its own JSON 13 | * serialization. 14 | * 15 | * @return A strictly syntactically correct JSON text. 16 | */ 17 | public String toJSONString(); 18 | } 19 | -------------------------------------------------------------------------------- /WeiboAnalyzer/.classpath: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/util/WeiboConfig.java: -------------------------------------------------------------------------------- 1 | package weibo4j.util; 2 | 3 | import java.io.FileNotFoundException; 4 | import java.io.IOException; 5 | import java.util.Properties; 6 | 7 | public class WeiboConfig { 8 | public WeiboConfig(){} 9 | private static Properties props = new Properties(); 10 | static{ 11 | try { 12 | props.load(Thread.currentThread().getContextClassLoader().getResourceAsStream("config.properties")); 13 | } catch (FileNotFoundException e) { 14 | e.printStackTrace(); 15 | } catch (IOException e) { 16 | e.printStackTrace(); 17 | } 18 | } 19 | public static String getValue(String key){ 20 | return props.getProperty(key); 21 | } 22 | 23 | public static void updateProperties(String key,String value) { 24 | props.setProperty(key, value); 25 | } 26 | } 27 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/Reminds.java: -------------------------------------------------------------------------------- 1 | package weibo4j; 2 | 3 | import weibo4j.model.PostParameter; 4 | import weibo4j.model.WeiboException; 5 | import weibo4j.org.json.JSONObject; 6 | import weibo4j.util.WeiboConfig; 7 | 8 | public class Reminds extends Weibo{ 9 | 10 | private static final long serialVersionUID = 1L; 11 | 12 | /** 13 | * 获取某个用户的各种消息未读数 14 | * 15 | */ 16 | public JSONObject getUnreadCountOfRemind () throws WeiboException { 17 | return client.get(WeiboConfig.getValue("rmURL") + "remind/unread_count.json").asJSONObject(); 18 | } 19 | 20 | public JSONObject getUnreadCountOfRemind (String callback) throws WeiboException { 21 | return client.get(WeiboConfig.getValue("rmURL") + "remind/unread_count.json",new PostParameter[] { 22 | new PostParameter("callback", callback) 23 | }).asJSONObject(); 24 | } 25 | 26 | } 27 | -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=debug, stdout, R 2 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 3 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 4 | 5 | log4j.logger.org.apache.commons.httpclient=info 6 | log4j.logger.httpclient.wire.content=info 7 | log4j.logger.httpclient.wire.header=info 8 | 9 | # Pattern to output the caller's file name and line number. 10 | log4j.appender.stdout.layout.ConversionPattern=%-4r %-5p [%d{yyyy-MM-dd HH:mm:ss}] %m%n 11 | 12 | log4j.appender.R=org.apache.log4j.RollingFileAppender 13 | log4j.appender.R.File=weibo.log 14 | log4j.appender.R.MaxFileSize= 100KB 15 | 16 | # Keep one backup file 17 | log4j.appender.R.MaxBackupIndex=1 18 | 19 | log4j.appender.R.layout=org.apache.log4j.PatternLayout 20 | log4j.appender.R.layout.ConversionPattern=%-4r %-5p [%d{yyyy-MM-dd HH:mm:ss}] %m%n -------------------------------------------------------------------------------- /WeiboAnalyzer/src/log4j.properties: -------------------------------------------------------------------------------- 1 | log4j.rootLogger=debug, stdout, R 2 | log4j.appender.stdout=org.apache.log4j.ConsoleAppender 3 | log4j.appender.stdout.layout=org.apache.log4j.PatternLayout 4 | 5 | log4j.logger.org.apache.commons.httpclient=info 6 | log4j.logger.httpclient.wire.content=info 7 | log4j.logger.httpclient.wire.header=info 8 | 9 | # Pattern to output the caller's file name and line number. 10 | log4j.appender.stdout.layout.ConversionPattern=%-4r %-5p [%d{yyyy-MM-dd HH:mm:ss}] %m%n 11 | 12 | log4j.appender.R=org.apache.log4j.RollingFileAppender 13 | log4j.appender.R.File=weibo.log 14 | log4j.appender.R.MaxFileSize= 100KB 15 | 16 | # Keep one backup file 17 | log4j.appender.R.MaxBackupIndex=1 18 | 19 | log4j.appender.R.layout=org.apache.log4j.PatternLayout 20 | log4j.appender.R.layout.ConversionPattern=%-4r %-5p [%d{yyyy-MM-dd HH:mm:ss}] %m%n -------------------------------------------------------------------------------- /WeiboAnalyzer/pom.xml: -------------------------------------------------------------------------------- 1 | 2 | 4.0.0 3 | WeiboAnalyzer 4 | WeiboAnalyzer 5 | 0.0.1-SNAPSHOT 6 | 7 | 8 | org.apache.lucene 9 | lucene-core 10 | 4.2.1 11 | 12 | 13 | org.apache.lucene 14 | lucene-analyzers-common 15 | 4.2.1 16 | 17 | 18 | net.sourceforge.jexcelapi 19 | jxl 20 | 2.6.12 21 | 22 | 23 | 24 | org.apache.lucene 25 | lucene-queryparser 26 | 4.2.1 27 | 28 | 29 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataMining/Liexicon.java: -------------------------------------------------------------------------------- 1 | package DataMining; 2 | public class Liexicon { 3 | private int LexID; 4 | protected String _lexicon; 5 | private int docF; 6 | private double IDF; 7 | 8 | public Liexicon(){ 9 | _lexicon = null; 10 | docF = 0; 11 | IDF = (Math.log(Global.dBer.getDocCount()/1)/Math.log(2)) +0.5; 12 | LexID = 0; 13 | } 14 | public Liexicon(int lexID,String lex,int docCount){ 15 | _lexicon = lex; 16 | LexID = lexID; 17 | docF = docCount; 18 | IDF = (Math.log(Global.dBer.getDocCount()/1)/Math.log(2)) +0.5; 19 | updatedocF(); 20 | } 21 | public void setID(int num){ 22 | LexID = num; 23 | } 24 | public int getID(){ 25 | return LexID; 26 | } 27 | public void setLexicon(String aLexicon) { 28 | _lexicon = aLexicon; 29 | } 30 | 31 | public String getLexicon() { 32 | return this._lexicon; 33 | } 34 | public void computeIDF(double allDOcCount){ 35 | IDF = (Math.log(allDOcCount/docF)/Math.log(2))+0.5; 36 | } 37 | public void updatedocF(){ 38 | docF++; 39 | computeIDF(Global.dBer.getDocCount()); 40 | } 41 | public int getDocF(){ 42 | return (int) docF; 43 | } 44 | public double getIDF(){ 45 | return IDF; 46 | } 47 | public void setIDF(double idf){ 48 | IDF = idf; 49 | } 50 | } -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/Source.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | public class Source implements java.io.Serializable{ 4 | 5 | private static final long serialVersionUID = -8972443458374235866L; 6 | private String url; //来源连接 7 | private String relationShip; 8 | private String name; //来源文案名称 9 | public Source(String str) { 10 | super(); 11 | String[] source = str.split("\"",5); 12 | url = source[1]; 13 | relationShip = source[3]; 14 | name = source[4].replace(">", "").replace(" _docVset; 9 | 10 | public List getList(){ 11 | return _docVset; 12 | } 13 | 14 | public void clearAll(){ 15 | _docNum = 0; 16 | _docVset.clear(); 17 | } 18 | public TermVector(docVector v){ 19 | _docNum = 1; 20 | _docVset = new LinkedList(); 21 | _docVset.add(v); 22 | } 23 | public TermVector(){ 24 | _docNum = 0; 25 | _docVset = new LinkedList(); 26 | } 27 | public void addVector(docVector v){ 28 | _docNum ++; 29 | _docVset.add(v); 30 | } 31 | public void removeVector(docVector v){ 32 | _docVset.remove(v); 33 | } 34 | public int getdocNum(){ 35 | return _docNum; 36 | } 37 | 38 | 39 | public static double getDist(docVector aV1, docVector aV2) { 40 | double a1 = 0; 41 | double a2 = 0; 42 | try { 43 | a1 = aV1.computeLength(); 44 | a2 = aV2.computeLength(); 45 | if(a1 == 0 || a2 == 0){ 46 | throw new Exception(); 47 | } 48 | } 49 | catch (Exception e) { 50 | } 51 | 52 | return 1-mult2Vector(aV1, aV2)/(a1*a2); 53 | } 54 | public static double mult2Vector(docVector aV1, docVector aV2){ 55 | int num = aV1.getitemNum(); 56 | double tem= 0 ; 57 | for(int i =0; i< num; i++ ){ 58 | tem += aV1.getValue()[i] * aV2.getValue()[i]; 59 | } 60 | return tem; 61 | } 62 | } -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataAnalyzer/zplCluster.java: -------------------------------------------------------------------------------- 1 | package DataAnalyzer; 2 | 3 | public class zplCluster { 4 | private docVector _mean; 5 | private int clusterNum; 6 | private TermVector _vector; 7 | 8 | 9 | public zplCluster(){ 10 | _mean = new docVector(-1); 11 | _vector = null; 12 | clusterNum = 0; 13 | } 14 | public int getNum(){ 15 | return clusterNum; 16 | } 17 | public boolean addDoc(docVector v){ 18 | if(v !=null){ 19 | _vector.addVector(v); 20 | clusterNum ++; 21 | return true; 22 | } 23 | return false; 24 | 25 | } 26 | public docVector getMean(){ 27 | return _mean; 28 | } 29 | public TermVector getTerm(){ 30 | return _vector; 31 | } 32 | public void UpdateMean() { 33 | 34 | int weidu = Global.weidu; 35 | double[] value = new double[weidu]; 36 | for(int i = 0; i< weidu;i++){ 37 | double tmp = 0; 38 | for(docVector v:_vector.getList()){ 39 | tmp += v.getValue()[i]; 40 | } 41 | value[i]= tmp/(double)weidu; 42 | } 43 | _mean.setValue(value); 44 | try{ 45 | if(_mean.computeLength() ==0) 46 | throw new Exception(); 47 | 48 | }catch (Exception e) { 49 | System.out.println("list len:"+_vector.getList().size()); 50 | if(_vector.getList().size() == 0){ 51 | System.out.println("+++++"); 52 | } 53 | } 54 | 55 | 56 | } 57 | 58 | 59 | public boolean setCluster(TermVector _v) { 60 | if(_v != null){ 61 | _vector = _v; 62 | System.out.println("list cluster len:"+_v.getList().size()); 63 | UpdateMean(); 64 | return true; 65 | } 66 | return false; 67 | 68 | } 69 | } -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/StatusWapper.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | import java.util.List; 4 | 5 | public class StatusWapper { 6 | 7 | private List statuses; 8 | 9 | private long previousCursor; 10 | 11 | private long nextCursor; 12 | 13 | private long totalNumber; 14 | 15 | private String hasvisible; 16 | 17 | public StatusWapper(List statuses, long previousCursor, 18 | long nextCursor, long totalNumber,String hasvisible) { 19 | this.statuses = statuses; 20 | this.previousCursor = previousCursor; 21 | this.nextCursor = nextCursor; 22 | this.totalNumber = totalNumber; 23 | this.hasvisible = hasvisible; 24 | } 25 | 26 | public List getStatuses() { 27 | return statuses; 28 | } 29 | 30 | public void setStatuses(List statuses) { 31 | this.statuses = statuses; 32 | } 33 | 34 | public long getPreviousCursor() { 35 | return previousCursor; 36 | } 37 | 38 | public void setPreviousCursor(long previousCursor) { 39 | this.previousCursor = previousCursor; 40 | } 41 | 42 | public long getNextCursor() { 43 | return nextCursor; 44 | } 45 | 46 | public void setNextCursor(long nextCursor) { 47 | this.nextCursor = nextCursor; 48 | } 49 | 50 | public long getTotalNumber() { 51 | return totalNumber; 52 | } 53 | 54 | public void setTotalNumber(long totalNumber) { 55 | this.totalNumber = totalNumber; 56 | } 57 | 58 | public String getHasvisible() { 59 | return hasvisible; 60 | } 61 | 62 | public void setHasvisible(String hasvisible) { 63 | this.hasvisible = hasvisible; 64 | } 65 | 66 | } 67 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/CommentWapper.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | import java.util.List; 4 | 5 | public class CommentWapper { 6 | private List comments; 7 | 8 | private long previousCursor; 9 | 10 | private long nextCursor; 11 | 12 | private long totalNumber; 13 | 14 | private String hasvisible; 15 | 16 | public CommentWapper(List comments, long previousCursor, 17 | long nextCursor, long totalNumber,String hasvisible) { 18 | this.comments = comments; 19 | this.previousCursor = previousCursor; 20 | this.nextCursor = nextCursor; 21 | this.totalNumber = totalNumber; 22 | this.hasvisible = hasvisible; 23 | } 24 | 25 | public List getComments() { 26 | return comments; 27 | } 28 | 29 | public void setComments(List comments) { 30 | this.comments = comments; 31 | } 32 | 33 | public long getPreviousCursor() { 34 | return previousCursor; 35 | } 36 | 37 | public void setPreviousCursor(long previousCursor) { 38 | this.previousCursor = previousCursor; 39 | } 40 | 41 | public long getNextCursor() { 42 | return nextCursor; 43 | } 44 | 45 | public void setNextCursor(long nextCursor) { 46 | this.nextCursor = nextCursor; 47 | } 48 | 49 | public long getTotalNumber() { 50 | return totalNumber; 51 | } 52 | 53 | public void setTotalNumber(long totalNumber) { 54 | this.totalNumber = totalNumber; 55 | } 56 | 57 | public String getHasvisible() { 58 | return hasvisible; 59 | } 60 | 61 | public void setHasvisible(String hasvisible) { 62 | this.hasvisible = hasvisible; 63 | } 64 | 65 | } 66 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataMining/PeopleQueue.java: -------------------------------------------------------------------------------- 1 | package DataMining; 2 | 3 | 4 | public class PeopleQueue { 5 | /** 6 | * 人物队列 7 | */ 8 | private People[] _peopleList; 9 | private int _head; 10 | private int _rear; 11 | private static int MAXQUEUELEN = 100000; 12 | private static int B_Y = 1; 13 | private static int B_N = 0; 14 | private int count; 15 | private People breakPoint; 16 | 17 | //判断是否需要设置断点 18 | private int flag; 19 | 20 | public void needBreak(){ 21 | flag = B_Y; 22 | } 23 | public boolean isBreak(){ 24 | if (flag == B_Y) 25 | return true; 26 | return false; 27 | } 28 | public int getCount(){ 29 | return count; 30 | } 31 | public People getBreak(){ 32 | return breakPoint; 33 | } 34 | public void setBreak(People tmp){ 35 | breakPoint = tmp; 36 | } 37 | public PeopleQueue(){ 38 | _peopleList = new People[MAXQUEUELEN]; 39 | _head = 0; 40 | _rear = 0; 41 | count = 0; 42 | breakPoint = null; 43 | flag = B_N; 44 | } 45 | public int getMaxQueueLen(){ 46 | return MAXQUEUELEN; 47 | } 48 | public boolean putIn(People aInfo) { 49 | for(String s:Global.usedIDList){ 50 | if (s.equals(aInfo.getID())) 51 | return true; 52 | } 53 | if (count != MAXQUEUELEN) 54 | { 55 | count ++; 56 | _peopleList[_rear] = aInfo; 57 | _rear = (_rear+1)%MAXQUEUELEN; 58 | } 59 | else { 60 | return false; 61 | } 62 | return true; 63 | } 64 | 65 | public People getOut() { 66 | People temPeople; 67 | if(count != 0) 68 | { 69 | count --; 70 | temPeople = _peopleList[_head] ; 71 | _head = (_head+1)%MAXQUEUELEN; 72 | } 73 | else { 74 | return null; 75 | } 76 | return temPeople; 77 | } 78 | } -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/ApiRateLimits.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | import weibo4j.org.json.JSONException; 4 | import weibo4j.org.json.JSONObject; 5 | 6 | public class ApiRateLimits implements java.io.Serializable{ 7 | 8 | private static final long serialVersionUID = 8550645887134692311L; 9 | private String api; //接口 10 | private int limit; //接口限制 11 | private String limitTimeUnit; //限制单元 12 | private long remainingHits; //剩余调用次数 13 | 14 | ApiRateLimits(JSONObject json) throws WeiboException { 15 | try { 16 | api = json.getString("api"); 17 | limit = json.getInt("limit"); 18 | limitTimeUnit = json.getString("limit_time_unit"); 19 | remainingHits = json.getLong("remaining_hits"); 20 | } catch (JSONException jsone) { 21 | throw new WeiboException(jsone.getMessage() + ":" + json.toString(), jsone); 22 | } 23 | } 24 | 25 | public String getApi() { 26 | return api; 27 | } 28 | 29 | public void setApi(String api) { 30 | this.api = api; 31 | } 32 | 33 | public int getLimit() { 34 | return limit; 35 | } 36 | 37 | public void setLimit(int limit) { 38 | this.limit = limit; 39 | } 40 | 41 | public String getLimitTimeUnit() { 42 | return limitTimeUnit; 43 | } 44 | 45 | public void setLimitTimeUnit(String limitTimeUnit) { 46 | this.limitTimeUnit = limitTimeUnit; 47 | } 48 | 49 | public long getRemainingHits() { 50 | return remainingHits; 51 | } 52 | 53 | public void setRemainingHits(long remainingHits) { 54 | this.remainingHits = remainingHits; 55 | } 56 | 57 | @Override 58 | public String toString() { 59 | return "api_rate_limits [api=" + api + ", limit=" + limit 60 | + ", limitTimeUnit=" + limitTimeUnit + ", remainingHits=" 61 | + remainingHits + "]"; 62 | } 63 | 64 | 65 | } 66 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataMining/Global.java: -------------------------------------------------------------------------------- 1 | package DataMining; 2 | 3 | import java.util.ArrayList; 4 | import java.util.LinkedList; 5 | import java.util.List; 6 | 7 | 8 | 9 | //全局变量 10 | 11 | public final class Global { 12 | public static String access_token = "2.00GLy1AC3ojl7E9d85327844CQtJFB"; 13 | public static String screen_name = "蛇之行"; 14 | public static String uIDString = "1837263552"; 15 | public static int docCount = 0; 16 | public static int ad = 1; 17 | public static int unad = 0; 18 | public static String[] noMeanStrings ={"此微博已被", 19 | "[0-9a-zA-z]*"}; 20 | public static String[] noMeanLex={"[0-9a-zA-z.:/]*", 21 | "我", 22 | "你", 23 | "他", 24 | "的", 25 | "啊", 26 | "要", 27 | "噗", 28 | "最", 29 | "之", 30 | "有", 31 | "哦", 32 | "@" 33 | }; 34 | public static int noMeanNum = 2; 35 | public static int noMeanLexNum = 13; 36 | public static List usedIDList = new ArrayList(); 37 | public static DBHander dBer = new DBHander(); 38 | public static PeopleQueue queue = new PeopleQueue(); 39 | public static splitSystem split = new splitSystem(); 40 | public static List docList = new LinkedList(); 41 | 42 | public static boolean markNolex(String s){ 43 | for(int i =0; i< noMeanLexNum;i++){ 44 | if(s.matches(noMeanLex[i])){ 45 | return true; 46 | } 47 | 48 | } 49 | return false; 50 | } 51 | public static boolean markNoMean(String s){ 52 | if(s.contains(noMeanStrings[0])) 53 | return true; 54 | if(s.length() < 6) 55 | return true; 56 | for(int i =0; i< noMeanNum;i++){ 57 | if(s.matches(noMeanStrings[i])){ 58 | System.out.println("no Mean:"); 59 | return true; 60 | } 61 | 62 | } 63 | return false; 64 | } 65 | } 66 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataAnalyzer/docVector.java: -------------------------------------------------------------------------------- 1 | package DataAnalyzer; 2 | 3 | public class docVector { 4 | private int _itemNum; 5 | private int docID; 6 | private int _nearestCluster; 7 | private double _nearestDist; 8 | private double _clusterAssignment; 9 | private double[] _itemValue; 10 | private double[] dist; 11 | private int _k; 12 | 13 | public String getWeiboCon(){ 14 | return Global.dBer.getDoc(docID); 15 | } 16 | public docVector(int _docID){ 17 | this.docID = _docID; 18 | _k = Global._k; 19 | _itemNum = Global.weidu; 20 | _nearestCluster = -1; 21 | _nearestDist = Global.MAX; 22 | _clusterAssignment =0; 23 | _itemValue = new double[_itemNum]; 24 | dist = new double[_k]; 25 | 26 | } 27 | public void setAeqN(){ 28 | _nearestDist = _clusterAssignment; 29 | } 30 | public void setclusterAssignment(double s){ 31 | _clusterAssignment = s; 32 | } 33 | public int getnearestCluster(){ 34 | return _nearestCluster; 35 | } 36 | public void setnearestCluster(){ 37 | int cluster=0; 38 | for(int i=0; i<_k;i++){ 39 | if(_nearestDist >= dist[i]){ 40 | _nearestDist = dist[i]; 41 | cluster = i; 42 | } 43 | } 44 | _nearestCluster = cluster; 45 | } 46 | public void setDist(int i,double dis){ 47 | dist[i]= dis; 48 | } 49 | public double getDist(int i){ 50 | return dist[i]; 51 | } 52 | 53 | public int getitemNum(){ 54 | return _itemNum; 55 | } 56 | public void setitemNum(int num){ 57 | _itemNum = num; 58 | } 59 | public void setValue(double[] value){ 60 | _itemValue = value; 61 | } 62 | public double[] getValue(){ 63 | return _itemValue; 64 | } 65 | public int getID(){ 66 | return docID; 67 | } 68 | public double computeLength(){ 69 | double s = 0; 70 | s = Math.sqrt(TermVector.mult2Vector(this, this)); 71 | 72 | return s; 73 | } 74 | public boolean isEqAssig(){ 75 | if (_clusterAssignment == _nearestDist) 76 | return true; 77 | return false; 78 | } 79 | } -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/UserWapper.java: -------------------------------------------------------------------------------- 1 | /* 2 | * UserObjectWapper.java created on 2010-7-28 上午08:48:35 by bwl (Liu Daoru) 3 | */ 4 | 5 | package weibo4j.model; 6 | 7 | import java.io.Serializable; 8 | import java.util.List; 9 | 10 | /** 11 | * 对User对象列表进行的包装,以支持cursor相关信息传递 12 | * @author sinaWeibo 13 | */ 14 | public class UserWapper implements Serializable { 15 | 16 | private static final long serialVersionUID = -3119107701303920284L; 17 | 18 | /** 19 | * 用户对象列表 20 | */ 21 | private List users; 22 | 23 | /** 24 | * 向前翻页的cursor 25 | */ 26 | private long previousCursor; 27 | 28 | /** 29 | * 向后翻页的cursor 30 | */ 31 | private long nextCursor; 32 | 33 | private long totalNumber; 34 | 35 | private String hasvisible; 36 | 37 | public UserWapper(List users, long previousCursor, long nextCursor, long totalNumber,String hasvisible) { 38 | this.users = users; 39 | this.previousCursor = previousCursor; 40 | this.nextCursor = nextCursor; 41 | this.totalNumber=totalNumber; 42 | this.hasvisible = hasvisible; 43 | } 44 | 45 | public List getUsers() { 46 | return users; 47 | } 48 | 49 | public void setUsers(List users) { 50 | this.users = users; 51 | } 52 | 53 | public long getPreviousCursor() { 54 | return previousCursor; 55 | } 56 | 57 | public void setPreviousCursor(long previousCursor) { 58 | this.previousCursor = previousCursor; 59 | } 60 | 61 | public long getNextCursor() { 62 | return nextCursor; 63 | } 64 | 65 | public void setNextCursor(long nextCursor) { 66 | this.nextCursor = nextCursor; 67 | } 68 | 69 | public long getTotalNumber() { 70 | return totalNumber; 71 | } 72 | 73 | public void setTotalNumber(long totalNumber) { 74 | this.totalNumber = totalNumber; 75 | } 76 | 77 | public String getHasvisible() { 78 | return hasvisible; 79 | } 80 | 81 | public void setHasvisible(String hasvisible) { 82 | this.hasvisible = hasvisible; 83 | } 84 | 85 | } 86 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/Version.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007-2009, Yusuke Yamamoto 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Yusuke Yamamoto nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Yusuke Yamamoto ``AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Yusuke Yamamoto BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package weibo4j.model; 28 | 29 | /** 30 | * @author Yusuke Yamamoto - yusuke at mac.com 31 | */ 32 | public class Version { 33 | private final static String VERSION = "1.0.0"; 34 | private final static String TITLE = "weibo4jV2"; 35 | 36 | public static String getVersion(){ 37 | return VERSION; 38 | } 39 | public static void main(String[] args) { 40 | System.out.println(TITLE +" " + VERSION); 41 | } 42 | } 43 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/org/wltea/analyzer/cfg/Configuration.java: -------------------------------------------------------------------------------- 1 | /** 2 | * IK 中文分词 版本 5.0 3 | * IK Analyzer release 5.0 4 | * 5 | * Licensed to the Apache Software Foundation (ASF) under one or more 6 | * contributor license agreements. See the NOTICE file distributed with 7 | * this work for additional information regarding copyright ownership. 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 9 | * (the "License"); you may not use this file except in compliance with 10 | * the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * 源代码由林良益(linliangyi2005@gmail.com)提供 21 | * 版权声明 2012,乌龙茶工作室 22 | * provided by Linliangyi and copyright 2012 by Oolong studio 23 | * 24 | */ 25 | package org.wltea.analyzer.cfg; 26 | 27 | import java.util.List; 28 | 29 | /** 30 | * 31 | * 配置管理类接口 32 | * 33 | */ 34 | public interface Configuration { 35 | 36 | 37 | 38 | /** 39 | * 返回useSmart标志位 40 | * useSmart =true ,分词器使用智能切分策略, =false则使用细粒度切分 41 | * @return useSmart 42 | */ 43 | public boolean useSmart(); 44 | 45 | /** 46 | * 设置useSmart标志位 47 | * useSmart =true ,分词器使用智能切分策略, =false则使用细粒度切分 48 | * @param useSmart 49 | */ 50 | public void setUseSmart(boolean useSmart); 51 | 52 | 53 | /** 54 | * 获取主词典路径 55 | * 56 | * @return String 主词典路径 57 | */ 58 | public String getMainDictionary(); 59 | 60 | /** 61 | * 获取量词词典路径 62 | * @return String 量词词典路径 63 | */ 64 | public String getQuantifierDicionary(); 65 | 66 | /** 67 | * 获取扩展字典配置路径 68 | * @return List 相对类加载器的路径 69 | */ 70 | public List getExtDictionarys(); 71 | 72 | 73 | /** 74 | * 获取扩展停止词典配置路径 75 | * @return List 相对类加载器的路径 76 | */ 77 | public List getExtStopWordDictionarys(); 78 | 79 | } 80 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/TestCase/testExcel.java: -------------------------------------------------------------------------------- 1 | package TestCase; 2 | import java.io.BufferedReader; 3 | import java.io.File; 4 | import java.io.FileInputStream; 5 | import java.io.IOException; 6 | import java.io.InputStreamReader; 7 | 8 | 9 | import jxl.Workbook; 10 | import jxl.write.Label; 11 | import jxl.write.WritableSheet; 12 | import jxl.write.WritableWorkbook; 13 | import jxl.write.WriteException; 14 | import jxl.write.biff.RowsExceededException; 15 | 16 | 17 | 18 | public class testExcel { 19 | 20 | public static void readFileByLines(String fileName) throws IOException, RowsExceededException, WriteException{ 21 | 22 | //打开文件 23 | WritableWorkbook book = Workbook.createWorkbook(new File("D://data3.xls")); 24 | //生成名为“第一页”的工作表,参数0表示这是第一页 25 | WritableSheet sheet = book.createSheet("第一页", 0); 26 | //读入txt中的内容 27 | File file = new File(fileName); 28 | FileInputStream fis = new FileInputStream(file); 29 | InputStreamReader isr = new InputStreamReader(fis,"Unicode"); 30 | BufferedReader reader = null; 31 | try{ 32 | reader = new BufferedReader(isr); 33 | String tempString = null; 34 | //一次读入一行,直到读入null为文件结束 35 | int i = 0; 36 | while((tempString = reader.readLine())!= null){ 37 | System.out.println(tempString); 38 | String[] str = tempString.split(","); 39 | //Label[] label = null; 40 | for(int j = 0;j < str.length;j++){ 41 | //在Label对象的构造子中指名单元格位置是第j列第i行(j,i)以及单元格内容为str[j] 42 | Label label = new Label(j,i,str[j]); 43 | //将定义好的单元格添加到工作表中 44 | sheet.addCell(label); 45 | } 46 | i++; 47 | } 48 | //写入数据并关闭文件 49 | book.write(); 50 | try { 51 | book.close(); 52 | } catch (WriteException e) { 53 | // TODO Auto-generated catch block 54 | e.printStackTrace(); 55 | } 56 | reader.close(); 57 | }catch(IOException e){ 58 | e.printStackTrace(); 59 | } finally{ 60 | if(reader!= null){ 61 | reader.close(); 62 | } 63 | } 64 | } 65 | public static void main(String[] args) throws RowsExceededException, WriteException{ 66 | try { 67 | readFileByLines("D://data.txt"); 68 | } catch (IOException e) { 69 | // TODO Auto-generated catch block 70 | e.printStackTrace(); 71 | } 72 | } 73 | } 74 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/org/wltea/analyzer/lucene/IKAnalyzer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * IK 中文分词 版本 5.0.1 3 | * IK Analyzer release 5.0.1 4 | * 5 | * Licensed to the Apache Software Foundation (ASF) under one or more 6 | * contributor license agreements. See the NOTICE file distributed with 7 | * this work for additional information regarding copyright ownership. 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 9 | * (the "License"); you may not use this file except in compliance with 10 | * the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * 源代码由林良益(linliangyi2005@gmail.com)提供 21 | * 版权声明 2012,乌龙茶工作室 22 | * provided by Linliangyi and copyright 2012 by Oolong studio 23 | * 24 | */ 25 | package org.wltea.analyzer.lucene; 26 | 27 | import java.io.Reader; 28 | 29 | import org.apache.lucene.analysis.Analyzer; 30 | import org.apache.lucene.analysis.Tokenizer; 31 | 32 | /** 33 | * IK分词器,Lucene Analyzer接口实现 34 | * 兼容Lucene 4.0版本 35 | */ 36 | public final class IKAnalyzer extends Analyzer{ 37 | 38 | private boolean useSmart; 39 | 40 | public boolean useSmart() { 41 | return useSmart; 42 | } 43 | 44 | public void setUseSmart(boolean useSmart) { 45 | this.useSmart = useSmart; 46 | } 47 | 48 | /** 49 | * IK分词器Lucene Analyzer接口实现类 50 | * 51 | * 默认细粒度切分算法 52 | */ 53 | public IKAnalyzer(){ 54 | this(false); 55 | } 56 | 57 | /** 58 | * IK分词器Lucene Analyzer接口实现类 59 | * 60 | * @param useSmart 当为true时,分词器进行智能切分 61 | */ 62 | public IKAnalyzer(boolean useSmart){ 63 | super(); 64 | this.useSmart = useSmart; 65 | } 66 | 67 | /** 68 | * 重载Analyzer接口,构造分词组件 69 | */ 70 | @Override 71 | protected TokenStreamComponents createComponents(String fieldName, final Reader in) { 72 | Tokenizer _IKTokenizer = new IKTokenizer(in , this.useSmart()); 73 | return new TokenStreamComponents(_IKTokenizer); 74 | } 75 | 76 | } 77 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/School.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import weibo4j.http.Response; 7 | import weibo4j.org.json.JSONArray; 8 | import weibo4j.org.json.JSONException; 9 | import weibo4j.org.json.JSONObject; 10 | 11 | public class School extends WeiboResponse { 12 | 13 | private static final long serialVersionUID = -5991828656755790609L; 14 | private int id; // 学校id 15 | private String name; // 学校名称 16 | 17 | public School(Response res) throws WeiboException { 18 | super(res); 19 | JSONObject json = res.asJSONObject(); 20 | try { 21 | id = json.getInt("id"); 22 | name = json.getString("name"); 23 | } catch (JSONException je) { 24 | throw new WeiboException(je.getMessage() + ":" + json.toString(), 25 | je); 26 | } 27 | } 28 | 29 | public School(JSONObject json) throws WeiboException { 30 | try { 31 | id = json.getInt("id"); 32 | name = json.getString("name"); 33 | } catch (JSONException je) { 34 | throw new WeiboException(je.getMessage() + ":" + json.toString(), 35 | je); 36 | } 37 | } 38 | 39 | public static List constructSchool(Response res) throws WeiboException { 40 | try { 41 | JSONArray list = res.asJSONArray(); 42 | int size = list.length(); 43 | List schools = new ArrayList(size); 44 | for (int i = 0; i < size; i++) { 45 | schools.add(new School(list.getJSONObject(i))); 46 | } 47 | return schools; 48 | } catch (JSONException jsone) { 49 | throw new WeiboException(jsone); 50 | } catch (WeiboException te) { 51 | throw te; 52 | } 53 | 54 | } 55 | 56 | public int getId() { 57 | return id; 58 | } 59 | 60 | public String getName() { 61 | return name; 62 | } 63 | 64 | @Override 65 | public int hashCode() { 66 | final int prime = 31; 67 | int result = 1; 68 | result = prime * result + id; 69 | return result; 70 | } 71 | 72 | @Override 73 | public boolean equals(Object obj) { 74 | if (this == obj) 75 | return true; 76 | if (obj == null) 77 | return false; 78 | if (getClass() != obj.getClass()) 79 | return false; 80 | School other = (School) obj; 81 | if (id != other.id) 82 | return false; 83 | return true; 84 | } 85 | 86 | @Override 87 | public String toString() { 88 | return "School [id=" + id + ", name=" + name + "]"; 89 | } 90 | 91 | } 92 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataMining/People.java: -------------------------------------------------------------------------------- 1 | package DataMining; 2 | 3 | 4 | import weibo4j.Friendships; 5 | import weibo4j.Timeline; 6 | import weibo4j.model.Status; 7 | import weibo4j.model.StatusWapper; 8 | import weibo4j.model.User; 9 | import weibo4j.model.UserWapper; 10 | import weibo4j.model.WeiboException; 11 | 12 | public class People { 13 | /** 14 | * 人物 15 | */ 16 | private String _uID; 17 | 18 | private Friendships fm; 19 | private Timeline tm; 20 | public People(String ID){ 21 | this._uID = ID; 22 | } 23 | public String getID(){ 24 | return _uID; 25 | } 26 | 27 | //得到朋友列表,并加入人物队列 28 | public boolean getFriends(PeopleQueue queue) { 29 | fm = new Friendships(); 30 | fm.client.setToken(Global.access_token); 31 | try { 32 | UserWapper users = fm.getFriendsByID(_uID); 33 | for(User u : users.getUsers()){ 34 | int flag = 0; 35 | for(String t:Global.usedIDList){ 36 | if(t.equals(u.getId())) 37 | { 38 | flag = 1; 39 | } 40 | } 41 | if(flag == 0) 42 | { 43 | //朋友入队 44 | People tmpPeople = new People(u.getId()); 45 | if(queue.putIn(tmpPeople) == false){ 46 | //记录断点 47 | throw new WeiboException("putinQueue Error!"); 48 | } 49 | } 50 | 51 | } 52 | } catch (WeiboException e) { 53 | e.printStackTrace(); 54 | System.out.println(e.getMessage()); 55 | } 56 | return true; 57 | } 58 | 59 | public boolean getDoc() { 60 | tm = new Timeline(); 61 | tm.client.setToken(Global.access_token); 62 | Global.usedIDList.add(_uID); 63 | try { 64 | //StatusWapper status = tm.getUserTimeline(); 65 | StatusWapper status=tm.getUserTimelineByUid(_uID); 66 | for(Status s : status.getStatuses()){ 67 | String conString ; 68 | if (s.getRetweetedStatus() == null) 69 | conString = s.getText(); 70 | else { 71 | conString = (s.getRetweetedStatus().getText()); 72 | } 73 | if(Global.markNoMean(conString) == false){ 74 | //加入文档词典 75 | if(Global.dBer.addDoc(s) == false) 76 | throw new WeiboException("addDoc wrong"); 77 | //进行分词 78 | System.out.println("doc:"+conString); 79 | if (s.getRetweetedStatus() == null) 80 | Global.split.setDoc(s.getText()); 81 | else { 82 | Global.split.setDoc(s.getRetweetedStatus().getText()); 83 | } 84 | Global.split.beginSplit(); 85 | } 86 | } 87 | } catch (WeiboException e) { 88 | e.printStackTrace(); 89 | System.out.println("Error:"+e.getMessage()); 90 | return false; 91 | } 92 | return true; 93 | } 94 | } -------------------------------------------------------------------------------- /WeiboAnalyzer/bin/org/wltea/analyzer/dic/quantifier.dic: -------------------------------------------------------------------------------- 1 | 丈 2 | 下 3 | 世 4 | 世纪 5 | 两 6 | 个 7 | 中 8 | 串 9 | 亩 10 | 人 11 | 介 12 | 付 13 | 代 14 | 件 15 | 任 16 | 份 17 | 伏 18 | 伙 19 | 位 20 | 位数 21 | 例 22 | 倍 23 | 像素 24 | 元 25 | 克 26 | 克拉 27 | 公亩 28 | 公克 29 | 公分 30 | 公升 31 | 公尺 32 | 公担 33 | 公斤 34 | 公里 35 | 公顷 36 | 具 37 | 册 38 | 出 39 | 刀 40 | 分 41 | 分钟 42 | 分米 43 | 划 44 | 列 45 | 则 46 | 刻 47 | 剂 48 | 剑 49 | 副 50 | 加仑 51 | 勺 52 | 包 53 | 匙 54 | 匹 55 | 区 56 | 千克 57 | 千米 58 | 升 59 | 卷 60 | 厅 61 | 厘 62 | 厘米 63 | 双 64 | 发 65 | 口 66 | 句 67 | 只 68 | 台 69 | 叶 70 | 号 71 | 名 72 | 吨 73 | 听 74 | 员 75 | 周 76 | 周年 77 | 品 78 | 回 79 | 团 80 | 圆 81 | 圈 82 | 地 83 | 场 84 | 块 85 | 坪 86 | 堆 87 | 声 88 | 壶 89 | 处 90 | 夜 91 | 大 92 | 天 93 | 头 94 | 套 95 | 女 96 | 孔 97 | 字 98 | 宗 99 | 室 100 | 家 101 | 寸 102 | 对 103 | 封 104 | 尊 105 | 小时 106 | 尺 107 | 尾 108 | 局 109 | 层 110 | 届 111 | 岁 112 | 师 113 | 帧 114 | 幅 115 | 幕 116 | 幢 117 | 平方 118 | 平方公尺 119 | 平方公里 120 | 平方分米 121 | 平方厘米 122 | 平方码 123 | 平方米 124 | 平方英寸 125 | 平方英尺 126 | 平方英里 127 | 平米 128 | 年 129 | 年代 130 | 年级 131 | 度 132 | 座 133 | 式 134 | 引 135 | 张 136 | 成 137 | 战 138 | 截 139 | 户 140 | 房 141 | 所 142 | 扇 143 | 手 144 | 打 145 | 批 146 | 把 147 | 折 148 | 担 149 | 拍 150 | 招 151 | 拨 152 | 拳 153 | 指 154 | 掌 155 | 排 156 | 撮 157 | 支 158 | 文 159 | 斗 160 | 斤 161 | 方 162 | 族 163 | 日 164 | 时 165 | 曲 166 | 月 167 | 月份 168 | 期 169 | 本 170 | 朵 171 | 村 172 | 束 173 | 条 174 | 来 175 | 杯 176 | 枚 177 | 枝 178 | 枪 179 | 架 180 | 柄 181 | 柜 182 | 栋 183 | 栏 184 | 株 185 | 样 186 | 根 187 | 格 188 | 案 189 | 桌 190 | 档 191 | 桩 192 | 桶 193 | 梯 194 | 棵 195 | 楼 196 | 次 197 | 款 198 | 步 199 | 段 200 | 毛 201 | 毫 202 | 毫升 203 | 毫米 204 | 毫克 205 | 池 206 | 洲 207 | 派 208 | 海里 209 | 滴 210 | 炮 211 | 点 212 | 点钟 213 | 片 214 | 版 215 | 环 216 | 班 217 | 瓣 218 | 瓶 219 | 生 220 | 男 221 | 画 222 | 界 223 | 盆 224 | 盎司 225 | 盏 226 | 盒 227 | 盘 228 | 相 229 | 眼 230 | 石 231 | 码 232 | 碗 233 | 碟 234 | 磅 235 | 种 236 | 科 237 | 秒 238 | 秒钟 239 | 窝 240 | 立方公尺 241 | 立方分米 242 | 立方厘米 243 | 立方码 244 | 立方米 245 | 立方英寸 246 | 立方英尺 247 | 站 248 | 章 249 | 笔 250 | 等 251 | 筐 252 | 筒 253 | 箱 254 | 篇 255 | 篓 256 | 篮 257 | 簇 258 | 米 259 | 类 260 | 粒 261 | 级 262 | 组 263 | 维 264 | 缕 265 | 缸 266 | 罐 267 | 网 268 | 群 269 | 股 270 | 脚 271 | 船 272 | 艇 273 | 艘 274 | 色 275 | 节 276 | 英亩 277 | 英寸 278 | 英尺 279 | 英里 280 | 行 281 | 袋 282 | 角 283 | 言 284 | 课 285 | 起 286 | 趟 287 | 路 288 | 车 289 | 转 290 | 轮 291 | 辆 292 | 辈 293 | 连 294 | 通 295 | 遍 296 | 部 297 | 里 298 | 重 299 | 针 300 | 钟 301 | 钱 302 | 锅 303 | 门 304 | 间 305 | 队 306 | 阶段 307 | 隅 308 | 集 309 | 页 310 | 顶 311 | 顷 312 | 项 313 | 顿 314 | 颗 315 | 餐 316 | 首 -------------------------------------------------------------------------------- /WeiboAnalyzer/src/org/wltea/analyzer/dic/quantifier.dic: -------------------------------------------------------------------------------- 1 | 丈 2 | 下 3 | 世 4 | 世纪 5 | 两 6 | 个 7 | 中 8 | 串 9 | 亩 10 | 人 11 | 介 12 | 付 13 | 代 14 | 件 15 | 任 16 | 份 17 | 伏 18 | 伙 19 | 位 20 | 位数 21 | 例 22 | 倍 23 | 像素 24 | 元 25 | 克 26 | 克拉 27 | 公亩 28 | 公克 29 | 公分 30 | 公升 31 | 公尺 32 | 公担 33 | 公斤 34 | 公里 35 | 公顷 36 | 具 37 | 册 38 | 出 39 | 刀 40 | 分 41 | 分钟 42 | 分米 43 | 划 44 | 列 45 | 则 46 | 刻 47 | 剂 48 | 剑 49 | 副 50 | 加仑 51 | 勺 52 | 包 53 | 匙 54 | 匹 55 | 区 56 | 千克 57 | 千米 58 | 升 59 | 卷 60 | 厅 61 | 厘 62 | 厘米 63 | 双 64 | 发 65 | 口 66 | 句 67 | 只 68 | 台 69 | 叶 70 | 号 71 | 名 72 | 吨 73 | 听 74 | 员 75 | 周 76 | 周年 77 | 品 78 | 回 79 | 团 80 | 圆 81 | 圈 82 | 地 83 | 场 84 | 块 85 | 坪 86 | 堆 87 | 声 88 | 壶 89 | 处 90 | 夜 91 | 大 92 | 天 93 | 头 94 | 套 95 | 女 96 | 孔 97 | 字 98 | 宗 99 | 室 100 | 家 101 | 寸 102 | 对 103 | 封 104 | 尊 105 | 小时 106 | 尺 107 | 尾 108 | 局 109 | 层 110 | 届 111 | 岁 112 | 师 113 | 帧 114 | 幅 115 | 幕 116 | 幢 117 | 平方 118 | 平方公尺 119 | 平方公里 120 | 平方分米 121 | 平方厘米 122 | 平方码 123 | 平方米 124 | 平方英寸 125 | 平方英尺 126 | 平方英里 127 | 平米 128 | 年 129 | 年代 130 | 年级 131 | 度 132 | 座 133 | 式 134 | 引 135 | 张 136 | 成 137 | 战 138 | 截 139 | 户 140 | 房 141 | 所 142 | 扇 143 | 手 144 | 打 145 | 批 146 | 把 147 | 折 148 | 担 149 | 拍 150 | 招 151 | 拨 152 | 拳 153 | 指 154 | 掌 155 | 排 156 | 撮 157 | 支 158 | 文 159 | 斗 160 | 斤 161 | 方 162 | 族 163 | 日 164 | 时 165 | 曲 166 | 月 167 | 月份 168 | 期 169 | 本 170 | 朵 171 | 村 172 | 束 173 | 条 174 | 来 175 | 杯 176 | 枚 177 | 枝 178 | 枪 179 | 架 180 | 柄 181 | 柜 182 | 栋 183 | 栏 184 | 株 185 | 样 186 | 根 187 | 格 188 | 案 189 | 桌 190 | 档 191 | 桩 192 | 桶 193 | 梯 194 | 棵 195 | 楼 196 | 次 197 | 款 198 | 步 199 | 段 200 | 毛 201 | 毫 202 | 毫升 203 | 毫米 204 | 毫克 205 | 池 206 | 洲 207 | 派 208 | 海里 209 | 滴 210 | 炮 211 | 点 212 | 点钟 213 | 片 214 | 版 215 | 环 216 | 班 217 | 瓣 218 | 瓶 219 | 生 220 | 男 221 | 画 222 | 界 223 | 盆 224 | 盎司 225 | 盏 226 | 盒 227 | 盘 228 | 相 229 | 眼 230 | 石 231 | 码 232 | 碗 233 | 碟 234 | 磅 235 | 种 236 | 科 237 | 秒 238 | 秒钟 239 | 窝 240 | 立方公尺 241 | 立方分米 242 | 立方厘米 243 | 立方码 244 | 立方米 245 | 立方英寸 246 | 立方英尺 247 | 站 248 | 章 249 | 笔 250 | 等 251 | 筐 252 | 筒 253 | 箱 254 | 篇 255 | 篓 256 | 篮 257 | 簇 258 | 米 259 | 类 260 | 粒 261 | 级 262 | 组 263 | 维 264 | 缕 265 | 缸 266 | 罐 267 | 网 268 | 群 269 | 股 270 | 脚 271 | 船 272 | 艇 273 | 艘 274 | 色 275 | 节 276 | 英亩 277 | 英寸 278 | 英尺 279 | 英里 280 | 行 281 | 袋 282 | 角 283 | 言 284 | 课 285 | 起 286 | 趟 287 | 路 288 | 车 289 | 转 290 | 轮 291 | 辆 292 | 辈 293 | 连 294 | 通 295 | 遍 296 | 部 297 | 里 298 | 重 299 | 针 300 | 钟 301 | 钱 302 | 锅 303 | 门 304 | 间 305 | 队 306 | 阶段 307 | 隅 308 | 集 309 | 页 310 | 顶 311 | 顷 312 | 项 313 | 顿 314 | 颗 315 | 餐 316 | 首 -------------------------------------------------------------------------------- /weiboinfo.sql: -------------------------------------------------------------------------------- 1 | /* 2 | Navicat MySQL Data Transfer 3 | 4 | Source Server : zpl 5 | Source Server Version : 50523 6 | Source Host : localhost:3306 7 | Source Database : weiboinfo 8 | 9 | Target Server Type : MYSQL 10 | Target Server Version : 50523 11 | File Encoding : 65001 12 | 13 | Date: 2014-02-23 17:19:48 14 | */ 15 | 16 | SET FOREIGN_KEY_CHECKS=0; 17 | 18 | -- ---------------------------- 19 | -- Table structure for `doc` 20 | -- ---------------------------- 21 | DROP TABLE IF EXISTS `doc`; 22 | CREATE TABLE `doc` ( 23 | `DocText` varchar(500) CHARACTER SET utf8 DEFAULT NULL, 24 | `DocID` int(20) NOT NULL, 25 | PRIMARY KEY (`DocID`) 26 | ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4; 27 | 28 | -- ---------------------------- 29 | -- Records of doc 30 | -- ---------------------------- 31 | 32 | -- ---------------------------- 33 | -- Table structure for `lexcion` 34 | -- ---------------------------- 35 | DROP TABLE IF EXISTS `lexcion`; 36 | CREATE TABLE `lexcion` ( 37 | `Lexicon` tinytext NOT NULL, 38 | `LexiconID` int(20) NOT NULL, 39 | `IDF` double(20,0) NOT NULL, 40 | PRIMARY KEY (`LexiconID`) 41 | ) ENGINE=InnoDB DEFAULT CHARSET=gbk; 42 | 43 | -- ---------------------------- 44 | -- Records of lexcion 45 | -- ---------------------------- 46 | 47 | -- ---------------------------- 48 | -- Table structure for `postingfile` 49 | -- ---------------------------- 50 | DROP TABLE IF EXISTS `postingfile`; 51 | CREATE TABLE `postingfile` ( 52 | `ListID` int(20) NOT NULL AUTO_INCREMENT, 53 | `LexiconID` int(20) NOT NULL, 54 | PRIMARY KEY (`ListID`), 55 | KEY `F_L_ID` (`LexiconID`), 56 | CONSTRAINT `F_L_ID` FOREIGN KEY (`LexiconID`) REFERENCES `lexcion` (`LexiconID`) 57 | ) ENGINE=InnoDB AUTO_INCREMENT=14934 DEFAULT CHARSET=utf8; 58 | 59 | -- ---------------------------- 60 | -- Records of postingfile 61 | -- ---------------------------- 62 | 63 | -- ---------------------------- 64 | -- Table structure for `postingitem` 65 | -- ---------------------------- 66 | DROP TABLE IF EXISTS `postingitem`; 67 | CREATE TABLE `postingitem` ( 68 | `id` int(11) NOT NULL AUTO_INCREMENT, 69 | `tf` int(20) DEFAULT NULL, 70 | `lexiconID` int(20) DEFAULT NULL, 71 | `docID` int(20) DEFAULT NULL, 72 | PRIMARY KEY (`id`), 73 | KEY `LexID_F` (`lexiconID`), 74 | KEY `DocID_F` (`docID`), 75 | CONSTRAINT `DocID_F` FOREIGN KEY (`docID`) REFERENCES `doc` (`DocID`), 76 | CONSTRAINT `LexID_F` FOREIGN KEY (`lexiconID`) REFERENCES `postingfile` (`LexiconID`) 77 | ) ENGINE=InnoDB AUTO_INCREMENT=38662 DEFAULT CHARSET=utf8; 78 | 79 | -- ---------------------------- 80 | -- Records of postingitem 81 | -- ---------------------------- 82 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/util/BareBonesBrowserLaunch.java: -------------------------------------------------------------------------------- 1 | package weibo4j.util; 2 | 3 | ///////////////////////////////////////////////////////// 4 | //Bare Bones Browser Launch // 5 | //Version 1.5 (December 10, 2005) // 6 | //By Dem Pilafian // 7 | //Supports: Mac OS X, GNU/Linux, Unix, Windows XP // 8 | //Example Usage: // 9 | // String url = "http://www.centerkey.com/"; // 10 | // BareBonesBrowserLaunch.openURL(url); // 11 | //Public Domain Software -- Free to Use as You Like // 12 | ///////////////////////////////////////////////////////// 13 | 14 | /** 15 | * @author Dem Pilafian 16 | * @author John Kristian 17 | */ 18 | import java.io.IOException; 19 | import java.lang.reflect.InvocationTargetException; 20 | import java.lang.reflect.Method; 21 | import javax.swing.JOptionPane; 22 | 23 | public class BareBonesBrowserLaunch { 24 | 25 | public static void openURL(String url) { 26 | try { 27 | browse(url); 28 | } catch (Exception e) { 29 | JOptionPane.showMessageDialog(null, "Error attempting to launch web browser:\n" + e.getLocalizedMessage()); 30 | } 31 | } 32 | 33 | private static void browse(String url) throws ClassNotFoundException, IllegalAccessException, 34 | IllegalArgumentException, InterruptedException, InvocationTargetException, IOException, 35 | NoSuchMethodException { 36 | String osName = System.getProperty("os.name", ""); 37 | if (osName.startsWith("Mac OS")) { 38 | Class fileMgr = Class.forName("com.apple.eio.FileManager"); 39 | Method openURL = fileMgr.getDeclaredMethod("openURL", new Class[] { String.class }); 40 | openURL.invoke(null, new Object[] { url }); 41 | } else if (osName.startsWith("Windows")) { 42 | Runtime.getRuntime().exec("rundll32 url.dll,FileProtocolHandler " + url); 43 | } else { // assume Unix or Linux 44 | String[] browsers = { "firefox", "opera", "konqueror", "epiphany", "mozilla", "netscape" }; 45 | String browser = null; 46 | for (int count = 0; count < browsers.length && browser == null; count++) 47 | if (Runtime.getRuntime().exec(new String[] { "which", browsers[count] }).waitFor() == 0) 48 | browser = browsers[count]; 49 | if (browser == null) 50 | throw new NoSuchMethodException("Could not find web browser"); 51 | else 52 | Runtime.getRuntime().exec(new String[] { browser, url }); 53 | } 54 | } 55 | 56 | } 57 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/UserTrend.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import weibo4j.http.Response; 7 | import weibo4j.org.json.JSONArray; 8 | import weibo4j.org.json.JSONException; 9 | import weibo4j.org.json.JSONObject; 10 | 11 | /** 12 | * 话题 13 | * 14 | * @author SinaWeibo 15 | * @since weibo4j-V2 1.0.0 16 | */ 17 | public class UserTrend extends WeiboResponse{ 18 | private String num; 19 | private String hotword = null; 20 | private String trendId = null; 21 | private static final long serialVersionUID = 1925956704460743946L; 22 | 23 | public UserTrend() { 24 | super(); 25 | } 26 | public UserTrend(Response res) throws WeiboException { 27 | super(res); 28 | JSONObject json = res.asJSONObject(); 29 | try { 30 | num = json.getString("num"); 31 | hotword = json.getString("hotword"); 32 | trendId = json.getString("trend_id"); 33 | if( json.getString("topicid")!=null) 34 | trendId = json.getString("topicid"); 35 | } catch (JSONException je) { 36 | throw new WeiboException(je.getMessage() + ":" + json.toString(), 37 | je); 38 | } 39 | } 40 | public UserTrend(JSONObject json) throws WeiboException { 41 | try { 42 | num = json.getString("num"); 43 | hotword = json.getString("hotword"); 44 | trendId = json.getString("trend_id"); 45 | } catch (JSONException je) { 46 | throw new WeiboException(je.getMessage() + ":" + json.toString(), 47 | je); 48 | } 49 | } 50 | 51 | public static List constructTrendList(Response res) throws WeiboException { 52 | try { 53 | JSONArray list = res.asJSONArray(); 54 | int size = list.length(); 55 | List trends = new ArrayList(size); 56 | for (int i = 0; i < size; i++) { 57 | trends.add(new UserTrend(list.getJSONObject(i))); 58 | } 59 | return trends; 60 | } catch (JSONException jsone) { 61 | throw new WeiboException(jsone); 62 | } catch (WeiboException te) { 63 | throw te; 64 | } 65 | 66 | } 67 | public String getNum() { 68 | return num; 69 | } 70 | public void setNum(String num) { 71 | this.num = num; 72 | } 73 | public String getHotword() { 74 | return hotword; 75 | } 76 | public void setHotword(String hotword) { 77 | this.hotword = hotword; 78 | } 79 | public String gettrendId() { 80 | return trendId; 81 | } 82 | public void settrendId(String trendId) { 83 | this.trendId = trendId; 84 | } 85 | @Override 86 | public String toString() { 87 | return "Trend [num=" + num + ", hotword=" + hotword + ", trendId=" 88 | + trendId + "]"; 89 | } 90 | 91 | 92 | } -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/org/json/HTTPTokener.java: -------------------------------------------------------------------------------- 1 | package weibo4j.org.json; 2 | 3 | /* 4 | Copyright (c) 2002 JSON.org 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | The Software shall be used for Good, not Evil. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | /** 28 | * The HTTPTokener extends the JSONTokener to provide additional methods 29 | * for the parsing of HTTP headers. 30 | * @author JSON.org 31 | * @version 2008-09-18 32 | */ 33 | public class HTTPTokener extends JSONTokener { 34 | 35 | /** 36 | * Construct an XMLTokener from a string. 37 | * @param s A source string. 38 | */ 39 | public HTTPTokener(String s) { 40 | super(s); 41 | } 42 | 43 | 44 | /** 45 | * Get the next token or string. This is used in parsing HTTP headers. 46 | * @throws JSONException 47 | * @return A String. 48 | */ 49 | public String nextToken() throws JSONException { 50 | char c; 51 | char q; 52 | StringBuffer sb = new StringBuffer(); 53 | do { 54 | c = next(); 55 | } while (Character.isWhitespace(c)); 56 | if (c == '"' || c == '\'') { 57 | q = c; 58 | for (;;) { 59 | c = next(); 60 | if (c < ' ') { 61 | throw syntaxError("Unterminated string."); 62 | } 63 | if (c == q) { 64 | return sb.toString(); 65 | } 66 | sb.append(c); 67 | } 68 | } 69 | for (;;) { 70 | if (c == 0 || Character.isWhitespace(c)) { 71 | return sb.toString(); 72 | } 73 | sb.append(c); 74 | c = next(); 75 | } 76 | } 77 | } 78 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/http/ImageItem.java: -------------------------------------------------------------------------------- 1 | /*package weibo4j.http; 2 | 3 | import java.io.ByteArrayInputStream; 4 | import java.io.IOException; 5 | import java.util.Iterator; 6 | 7 | import javax.imageio.ImageIO; 8 | import javax.imageio.ImageReader; 9 | import javax.imageio.stream.MemoryCacheImageInputStream; 10 | 11 | import weibo4j.model.Constants; 12 | import weibo4j.model.WeiboException; 13 | 14 | import com.sun.imageio.plugins.bmp.BMPImageReader; 15 | import com.sun.imageio.plugins.gif.GIFImageReader; 16 | import com.sun.imageio.plugins.jpeg.JPEGImageReader; 17 | import com.sun.imageio.plugins.png.PNGImageReader; 18 | 19 | /** 20 | * 临时存储上传图片的内容,格式,文件信息等 21 | * 22 | */ 23 | 24 | /* 25 | public class ImageItem { 26 | private byte[] content; 27 | private String name; 28 | private String contentType; 29 | public ImageItem(byte[] content) throws WeiboException { 30 | this(Constants.UPLOAD_MODE,content); 31 | } 32 | public ImageItem(String name,byte[] content) throws WeiboException{ 33 | String imgtype = null; 34 | try { 35 | imgtype = getContentType(content); 36 | } catch (IOException e) { 37 | throw new WeiboException(e); 38 | } 39 | 40 | if(imgtype!=null&&(imgtype.equalsIgnoreCase("image/gif")||imgtype.equalsIgnoreCase("image/png") 41 | ||imgtype.equalsIgnoreCase("image/jpeg"))){ 42 | this.content=content; 43 | this.name=name; 44 | this.contentType=imgtype; 45 | }else{ 46 | throw new WeiboException( 47 | "Unsupported image type, Only Suport JPG ,GIF,PNG!"); 48 | } 49 | } 50 | 51 | public byte[] getContent() { 52 | return content; 53 | } 54 | public String getName() { 55 | return name; 56 | } 57 | public String getContentType() { 58 | return contentType; 59 | } 60 | 61 | public static String getContentType(byte[] mapObj) throws IOException { 62 | 63 | String type = ""; 64 | ByteArrayInputStream bais = null; 65 | MemoryCacheImageInputStream mcis = null; 66 | try { 67 | bais = new ByteArrayInputStream(mapObj); 68 | mcis = new MemoryCacheImageInputStream(bais); 69 | Iterator itr = ImageIO.getImageReaders(mcis); 70 | while (itr.hasNext()) { 71 | ImageReader reader = (ImageReader) itr.next(); 72 | if (reader instanceof GIFImageReader) { 73 | type = "image/gif"; 74 | } else if (reader instanceof JPEGImageReader) { 75 | type = "image/jpeg"; 76 | } else if (reader instanceof PNGImageReader) { 77 | type = "image/png"; 78 | } else if (reader instanceof BMPImageReader) { 79 | type = "application/x-bmp"; 80 | } 81 | } 82 | } finally { 83 | if (bais != null) { 84 | try { 85 | bais.close(); 86 | } catch (IOException ioe) { 87 | 88 | } 89 | } 90 | if (mcis != null) { 91 | try { 92 | mcis.close(); 93 | } catch (IOException ioe) { 94 | 95 | } 96 | } 97 | } 98 | return type; 99 | } 100 | } 101 | */ 102 | 103 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/org/wltea/analyzer/dic/Hit.java: -------------------------------------------------------------------------------- 1 | /** 2 | * 3 | * IK 中文分词 版本 5.0 4 | * IK Analyzer release 5.0 5 | * 6 | * Licensed to the Apache Software Foundation (ASF) under one or more 7 | * contributor license agreements. See the NOTICE file distributed with 8 | * this work for additional information regarding copyright ownership. 9 | * The ASF licenses this file to You under the Apache License, Version 2.0 10 | * (the "License"); you may not use this file except in compliance with 11 | * the License. You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * 源代码由林良益(linliangyi2005@gmail.com)提供 22 | * 版权声明 2012,乌龙茶工作室 23 | * provided by Linliangyi and copyright 2012 by Oolong studio 24 | * 25 | */ 26 | package org.wltea.analyzer.dic; 27 | 28 | /** 29 | * 表示一次词典匹配的命中 30 | */ 31 | public class Hit { 32 | //Hit不匹配 33 | private static final int UNMATCH = 0x00000000; 34 | //Hit完全匹配 35 | private static final int MATCH = 0x00000001; 36 | //Hit前缀匹配 37 | private static final int PREFIX = 0x00000010; 38 | 39 | 40 | //该HIT当前状态,默认未匹配 41 | private int hitState = UNMATCH; 42 | 43 | //记录词典匹配过程中,当前匹配到的词典分支节点 44 | private DictSegment matchedDictSegment; 45 | /* 46 | * 词段开始位置 47 | */ 48 | private int begin; 49 | /* 50 | * 词段的结束位置 51 | */ 52 | private int end; 53 | 54 | 55 | /** 56 | * 判断是否完全匹配 57 | */ 58 | public boolean isMatch() { 59 | return (this.hitState & MATCH) > 0; 60 | } 61 | /** 62 | * 63 | */ 64 | public void setMatch() { 65 | this.hitState = this.hitState | MATCH; 66 | } 67 | 68 | /** 69 | * 判断是否是词的前缀 70 | */ 71 | public boolean isPrefix() { 72 | return (this.hitState & PREFIX) > 0; 73 | } 74 | /** 75 | * 76 | */ 77 | public void setPrefix() { 78 | this.hitState = this.hitState | PREFIX; 79 | } 80 | /** 81 | * 判断是否是不匹配 82 | */ 83 | public boolean isUnmatch() { 84 | return this.hitState == UNMATCH ; 85 | } 86 | /** 87 | * 88 | */ 89 | public void setUnmatch() { 90 | this.hitState = UNMATCH; 91 | } 92 | 93 | public DictSegment getMatchedDictSegment() { 94 | return matchedDictSegment; 95 | } 96 | 97 | public void setMatchedDictSegment(DictSegment matchedDictSegment) { 98 | this.matchedDictSegment = matchedDictSegment; 99 | } 100 | 101 | public int getBegin() { 102 | return begin; 103 | } 104 | 105 | public void setBegin(int begin) { 106 | this.begin = begin; 107 | } 108 | 109 | public int getEnd() { 110 | return end; 111 | } 112 | 113 | public void setEnd(int end) { 114 | this.end = end; 115 | } 116 | 117 | } 118 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/Users.java: -------------------------------------------------------------------------------- 1 | package weibo4j; 2 | 3 | import weibo4j.model.PostParameter; 4 | import weibo4j.model.User; 5 | import weibo4j.model.WeiboException; 6 | import weibo4j.org.json.JSONArray; 7 | import weibo4j.util.WeiboConfig; 8 | 9 | public class Users extends Weibo{ 10 | 11 | private static final long serialVersionUID = 4742830953302255953L; 12 | 13 | 14 | /*----------------------------用户接口----------------------------------------*/ 15 | /** 16 | * 根据用户ID获取用户信息 17 | * 18 | * @param uid 19 | * 需要查询的用户ID 20 | * @return User 21 | * @throws WeiboException 22 | * when Weibo service or network is unavailable 23 | * @version weibo4j-V2 1.0.1 24 | * @see users/show 25 | * @since JDK 1.5 26 | */ 27 | public User showUserById(String uid) throws WeiboException { 28 | return new User(client.get( 29 | WeiboConfig.getValue("baseURL") + "users/show.json", 30 | new PostParameter[] { new PostParameter("uid", uid) }) 31 | .asJSONObject()); 32 | } 33 | 34 | /** 35 | * 根据用户ID获取用户信息 36 | * 37 | * @param screen_name 38 | * 用户昵称 39 | * @return User 40 | * @throws WeiboException 41 | * when Weibo service or network is unavailable 42 | * @version weibo4j-V2 1.0.1 43 | * @see users/show 44 | * @since JDK 1.5 45 | */ 46 | public User showUserByScreenName(String screen_name) throws WeiboException { 47 | return new User(client.get( 48 | WeiboConfig.getValue("baseURL") + "users/show.json", 49 | new PostParameter[] { new PostParameter("screen_name", 50 | screen_name) }).asJSONObject()); 51 | } 52 | 53 | /** 54 | * 通过个性化域名获取用户资料以及用户最新的一条微博 55 | * 56 | * @param domain 57 | * 需要查询的个性化域名。 58 | * @return User 59 | * @throws WeiboException 60 | * when Weibo service or network is unavailable 61 | * @version weibo4j-V2 1.0.1 62 | * @see users/domain_show 64 | * @since JDK 1.5 65 | */ 66 | public User showUserByDomain(String domain) throws WeiboException { 67 | return new User(client.get( 68 | WeiboConfig.getValue("baseURL") + "users/domain_show.json", 69 | new PostParameter[] { new PostParameter("domain", domain) }) 70 | .asJSONObject()); 71 | } 72 | /** 73 | * 批量获取用户的粉丝数、关注数、微博数 74 | * 75 | * @param uids 76 | * 需要获取数据的用户UID,多个之间用逗号分隔,最多不超过100个 77 | * @return jsonobject 78 | * @throws WeiboException 79 | * when Weibo service or network is unavailable 80 | * @version weibo4j-V2 1.0.1 81 | * @see users/domain_show 83 | * @since JDK 1.5 84 | */ 85 | public JSONArray getUserCount(String uids) throws WeiboException{ 86 | return client.get(WeiboConfig.getValue("baseURL") + "users/counts.json", 87 | new PostParameter[] { new PostParameter("uids", uids)}).asJSONArray(); 88 | } 89 | } 90 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/TestCase/zplTest.java: -------------------------------------------------------------------------------- 1 | package TestCase; 2 | 3 | import static org.junit.Assert.*; 4 | 5 | import java.io.UnsupportedEncodingException; 6 | import java.sql.Connection; 7 | import java.sql.DriverManager; 8 | import java.sql.ResultSet; 9 | import java.sql.SQLException; 10 | import java.sql.Statement; 11 | 12 | import org.junit.Test; 13 | 14 | import weibo4j.Timeline; 15 | import weibo4j.model.Status; 16 | import weibo4j.model.StatusWapper; 17 | import weibo4j.model.WeiboException; 18 | 19 | import DataAnalyzer.dataAnalyzer; 20 | import DataMining.*; 21 | 22 | public class zplTest { 23 | 24 | //case1 测试数据获取模块 25 | @Test 26 | public void testMining() { 27 | // dataMining testdata = new dataMining(); 28 | // testdata.mainDataMining(); 29 | 30 | } 31 | 32 | //case2 微博中获取某一个人的全部微博 33 | @Test 34 | public void testGetAllDocbyOne(){ 35 | /* Global.dBer.connectDB(); 36 | Timeline tm = new Timeline(); 37 | tm.client.setToken(Global.access_token); 38 | try { 39 | //StatusWapper status = tm.getUserTimeline(); 40 | StatusWapper status=tm.getUserTimelineByUid(Global.uIDString); 41 | int i = 0; 42 | for(Status s : status.getStatuses()){ 43 | i++; 44 | String conString ; 45 | if (s.getRetweetedStatus() == null) 46 | conString = s.getText(); 47 | else { 48 | conString = (s.getRetweetedStatus().getText()); 49 | } 50 | System.out.println("old"+conString); 51 | Global.dBer.addDoc(conString,i); 52 | System.out.println("utf:"+Global.dBer.convertCharset(conString)); 53 | } 54 | } catch (WeiboException e) { 55 | e.printStackTrace(); 56 | } 57 | Global.dBer.closeDB(); 58 | */ 59 | } 60 | 61 | //case3 写入excel 62 | @Test 63 | public void testSplitDoc(){ 64 | 65 | } 66 | 67 | //case4 建立词典 68 | @Test 69 | public void testBuildLexicon(){ 70 | 71 | } 72 | 73 | //case4 建立倒排索引 74 | @Test 75 | public void testBuildPosting(){ 76 | 77 | } 78 | 79 | 80 | //case5 连接数据库 81 | @Test 82 | public void testConSQL(){ 83 | 84 | /* Global.dBer.connectDB(); 85 | Statement statement = null; 86 | try { 87 | statement = Global.dBer.getCon().createStatement(); 88 | } catch (SQLException e1) { 89 | // TODO Auto-generated catch block 90 | e1.printStackTrace(); 91 | } 92 | //更新数据库 93 | //String cmdString = "insert into doc(DocID,DocText) values(1,'"+new_conString+"');"; 94 | String cmdString = "select count(*) from doc"; 95 | //String cmdString = "insert into doc(DocID,DocText) values(1,'dasdad');"; 96 | try { 97 | //statement.executeUpdate(cmdString); 98 | ResultSet set = statement.executeQuery(cmdString); 99 | int a = 0; 100 | if(set.next()) 101 | a= set.getInt(1); 102 | System.out.println("a="+a); 103 | } catch (SQLException e) { 104 | // TODO Auto-generated catch block 105 | e.printStackTrace(); 106 | System.out.println(e.getErrorCode()); 107 | //e.printStackTrace(); 108 | 109 | } 110 | */ 111 | } 112 | } 113 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/http/AccessToken.java: -------------------------------------------------------------------------------- 1 | package weibo4j.http; 2 | 3 | import java.io.Serializable; 4 | 5 | import weibo4j.model.WeiboException; 6 | import weibo4j.model.WeiboResponse; 7 | import weibo4j.org.json.JSONException; 8 | import weibo4j.org.json.JSONObject; 9 | 10 | 11 | public class AccessToken extends WeiboResponse implements Serializable { 12 | 13 | private static final long serialVersionUID = 6986530164134648944L; 14 | private String accessToken; 15 | private String expireIn; 16 | private String refreshToken; 17 | private String uid; 18 | public AccessToken(Response res) throws WeiboException{ 19 | super(res); 20 | JSONObject json =res.asJSONObject(); 21 | try{ 22 | accessToken = json.getString("access_token"); 23 | expireIn = json.getString("expires_in"); 24 | refreshToken = json.getString("refresh_token"); 25 | uid = json.getString("uid"); 26 | } catch (JSONException je) { 27 | throw new WeiboException(je.getMessage() + ":" + json.toString(), je); 28 | } 29 | } 30 | AccessToken(String res) throws WeiboException,JSONException{ 31 | super(); 32 | JSONObject json =new JSONObject(res); 33 | accessToken = json.getString("access_token"); 34 | expireIn = json.getString("expires_in"); 35 | refreshToken = json.getString("refresh_token"); 36 | uid = json.getString("uid"); 37 | } 38 | public String getAccessToken() { 39 | return accessToken; 40 | } 41 | public String getExpireIn() { 42 | return expireIn; 43 | } 44 | public String getRefreshToken() { 45 | return refreshToken; 46 | } 47 | @Override 48 | public int hashCode() { 49 | final int prime = 31; 50 | int result = 1; 51 | result = prime * result 52 | + ((accessToken == null) ? 0 : accessToken.hashCode()); 53 | result = prime * result 54 | + ((expireIn == null) ? 0 : expireIn.hashCode()); 55 | result = prime * result 56 | + ((refreshToken == null) ? 0 : refreshToken.hashCode()); 57 | return result; 58 | } 59 | @Override 60 | public boolean equals(Object obj) { 61 | if (this == obj) 62 | return true; 63 | if (obj == null) 64 | return false; 65 | if (getClass() != obj.getClass()) 66 | return false; 67 | AccessToken other = (AccessToken) obj; 68 | if (accessToken == null) { 69 | if (other.accessToken != null) 70 | return false; 71 | } else if (!accessToken.equals(other.accessToken)) 72 | return false; 73 | if (expireIn == null) { 74 | if (other.expireIn != null) 75 | return false; 76 | } else if (!expireIn.equals(other.expireIn)) 77 | return false; 78 | if (refreshToken == null) { 79 | if (other.refreshToken != null) 80 | return false; 81 | } else if (!refreshToken.equals(other.refreshToken)) 82 | return false; 83 | return true; 84 | } 85 | @Override 86 | public String toString() { 87 | return "AccessToken [" + 88 | "accessToken=" + accessToken + 89 | ", expireIn=" + expireIn + 90 | ", refreshToken=" + refreshToken + 91 | ",uid="+uid+ 92 | "]"; 93 | } 94 | 95 | 96 | 97 | 98 | 99 | 100 | 101 | 102 | } 103 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/DataMining/splitSystem.java: -------------------------------------------------------------------------------- 1 | package DataMining; 2 | 3 | import java.io.IOException; 4 | import java.io.StringReader; 5 | import java.util.ArrayList; 6 | import java.util.List; 7 | 8 | import org.apache.lucene.analysis.Analyzer; 9 | import org.apache.lucene.analysis.TokenStream; 10 | import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; 11 | import org.wltea.analyzer.lucene.IKAnalyzer; 12 | 13 | public class splitSystem { 14 | 15 | public class wordCount{ 16 | public class wordAndCount{ 17 | public int count; 18 | public String word; 19 | public wordAndCount(String w,int c){ 20 | count = c; 21 | word = w; 22 | } 23 | } 24 | 25 | public List wordlist ; 26 | public wordCount(){ 27 | wordlist = new ArrayList(); 28 | } 29 | public void addValue(String word,int count){ 30 | wordlist.add(new wordAndCount(word, count)); 31 | } 32 | public void begin_analyzer(Doc doc){ 33 | //构建IK分词器,使用smart分词模式 34 | Analyzer analyzer = new IKAnalyzer(true); 35 | StringReader reader = new StringReader(doc.getDocCon()); 36 | List tmpList=new ArrayList(); 37 | //获取Lucene的TokenStream对象 38 | TokenStream ts = null; 39 | try { 40 | ts = analyzer.tokenStream("myfield", reader); 41 | 42 | //获取词元文本属性 43 | CharTermAttribute term = ts.addAttribute(CharTermAttribute.class); 44 | 45 | 46 | 47 | //重置TokenStream(重置StringReader) 48 | ts.reset(); 49 | //迭代获取分词结果,加入到tmplist中待处理 50 | while (ts.incrementToken()) { 51 | if(Global.markNolex(term.toString()) == false){ 52 | tmpList.add(term.toString()); 53 | } 54 | } 55 | 56 | //词频统计 57 | for(String word:tmpList) 58 | { 59 | boolean match=false; 60 | for(int i=0;i constructTags(Response res) throws WeiboException { 37 | try { 38 | JSONArray list = res.asJSONArray(); 39 | int size = list.length(); 40 | List tags = new ArrayList(size); 41 | for (int i = 0; i < size; i++) { 42 | tags.add(new FavoritesTag(list.getJSONObject(i))); 43 | } 44 | return tags; 45 | } catch (JSONException jsone) { 46 | throw new WeiboException(jsone); 47 | } catch (WeiboException te) { 48 | throw te; 49 | } 50 | } 51 | public static List constructTag(Response res) throws WeiboException { 52 | try { 53 | JSONArray list = res.asJSONObject().getJSONArray("tags"); 54 | int size = list.length(); 55 | List tags = new ArrayList(size); 56 | for (int i = 0; i < size; i++) { 57 | tags.add(new FavoritesTag(list.getJSONObject(i))); 58 | } 59 | return tags; 60 | } catch (JSONException jsone) { 61 | throw new WeiboException(jsone); 62 | } catch (WeiboException te) { 63 | throw te; 64 | } 65 | } 66 | 67 | 68 | 69 | @Override 70 | public int hashCode() { 71 | final int prime = 31; 72 | int result = 1; 73 | result = prime * result + ((id == null) ? 0 : id.hashCode()); 74 | return result; 75 | } 76 | 77 | 78 | @Override 79 | public boolean equals(Object obj) { 80 | if (this == obj) 81 | return true; 82 | if (obj == null) 83 | return false; 84 | if (getClass() != obj.getClass()) 85 | return false; 86 | FavoritesTag other = (FavoritesTag) obj; 87 | if (id == null) { 88 | if (other.id != null) 89 | return false; 90 | } else if (!id.equals(other.id)) 91 | return false; 92 | return true; 93 | } 94 | 95 | 96 | public String getId() { 97 | return id; 98 | } 99 | 100 | 101 | public void setId(String id) { 102 | this.id = id; 103 | } 104 | 105 | 106 | public String getTag() { 107 | return tag; 108 | } 109 | 110 | 111 | public void setTag(String tag) { 112 | this.tag = tag; 113 | } 114 | 115 | 116 | public int getCount() { 117 | return count; 118 | } 119 | 120 | 121 | public void setCount(int count) { 122 | this.count = count; 123 | } 124 | 125 | 126 | @Override 127 | public String toString() { 128 | return "FavoritesTag [id=" + id + ", tag=" + tag + ", count=" + count 129 | + "]"; 130 | } 131 | 132 | } 133 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/ShortUrl.java: -------------------------------------------------------------------------------- 1 | package weibo4j; 2 | 3 | import weibo4j.model.PostParameter; 4 | import weibo4j.model.WeiboException; 5 | import weibo4j.org.json.JSONObject; 6 | import weibo4j.util.WeiboConfig; 7 | 8 | public class ShortUrl extends Weibo{ 9 | /** 10 | * 11 | */ 12 | private static final long serialVersionUID = 1L; 13 | /** 14 | * 长链接转为短链接 15 | * 16 | * 17 | */ 18 | public JSONObject longToShortUrl (String url_long) throws WeiboException { 19 | return client.get(WeiboConfig.getValue("baseURL") + "short_url/shorten.json",new PostParameter[] { 20 | new PostParameter("url_long",url_long) 21 | }).asJSONObject(); 22 | } 23 | 24 | /** 25 | * 短链接转为长链接 26 | * 27 | */ 28 | public JSONObject shortToLongUrl (String url_short) throws WeiboException { 29 | return client.get(WeiboConfig.getValue("baseURL") + "short_url/expand.json",new PostParameter[] { 30 | new PostParameter("url_short",url_short) 31 | }).asJSONObject(); 32 | } 33 | 34 | /** 35 | * 获取短链接的总点击数 36 | * 37 | * 38 | */ 39 | public JSONObject clicksOfUrl (String url_short) throws WeiboException { 40 | return client.get(WeiboConfig.getValue("baseURL") + "short_url/clicks.json",new PostParameter[] { 41 | new PostParameter("url_short",url_short) 42 | }).asJSONObject(); 43 | } 44 | 45 | /** 46 | * 获取一个短链接点击的referer来源和数量 47 | * 48 | * 49 | */ 50 | public JSONObject referersOfUrl (String url_short) throws WeiboException { 51 | return client.get(WeiboConfig.getValue("baseURL") + "short_url/referers.json",new PostParameter[] { 52 | new PostParameter("url_short",url_short) 53 | }).asJSONObject(); 54 | } 55 | 56 | /** 57 | * 58 | * 获取一个短链接点击的地区来源和数量 59 | * 60 | */ 61 | public JSONObject locationsOfUrl (String url_short) throws WeiboException { 62 | return client.get(WeiboConfig.getValue("baseURL") + "short_url/locations.json",new PostParameter[] { 63 | new PostParameter("url_short",url_short) 64 | }).asJSONObject(); 65 | } 66 | 67 | /** 68 | * 获取短链接在微博上的微博分享数 69 | * 70 | * 71 | * 72 | */ 73 | public JSONObject shareCountsOfUrl (String url_short) throws WeiboException { 74 | return client.get(WeiboConfig.getValue("baseURL") + "short_url/share/counts.json",new PostParameter[] { 75 | new PostParameter("url_short",url_short) 76 | }).asJSONObject(); 77 | } 78 | /** 79 | * 获取包含指定单个短链接的最新微博内容 80 | * 81 | * 82 | */ 83 | public JSONObject statusesContentUrl (String url_short) throws WeiboException { 84 | return client.get(WeiboConfig.getValue("baseURL") + "short_url/share/statuses.json",new PostParameter[] { 85 | new PostParameter("url_short",url_short) 86 | }).asJSONObject(); 87 | } 88 | /** 89 | * 获取短链接在微博上的微博评论数 90 | * 91 | * 92 | */ 93 | public JSONObject commentCountOfUrl (String url_short) throws WeiboException { 94 | return client.get(WeiboConfig.getValue("baseURL") + "short_url/comment/counts.json",new PostParameter[] { 95 | new PostParameter("url_short",url_short) 96 | }).asJSONObject(); 97 | } 98 | /** 99 | * 获取包含指定单个短链接的最新微博评论 100 | * 101 | */ 102 | public JSONObject commentsContentUrl (String url_short) throws WeiboException { 103 | return client.get(WeiboConfig.getValue("baseURL") + "short_url/comment/comments.json",new PostParameter[] { 104 | new PostParameter("url_short",url_short) 105 | }).asJSONObject(); 106 | } 107 | } 108 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/org/wltea/analyzer/core/CharacterUtil.java: -------------------------------------------------------------------------------- 1 | /** 2 | * IK 中文分词 版本 5.0 3 | * IK Analyzer release 5.0 4 | * 5 | * Licensed to the Apache Software Foundation (ASF) under one or more 6 | * contributor license agreements. See the NOTICE file distributed with 7 | * this work for additional information regarding copyright ownership. 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 9 | * (the "License"); you may not use this file except in compliance with 10 | * the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * 源代码由林良益(linliangyi2005@gmail.com)提供 21 | * 版权声明 2012,乌龙茶工作室 22 | * provided by Linliangyi and copyright 2012 by Oolong studio 23 | * 24 | * 字符集识别工具类 25 | */ 26 | package org.wltea.analyzer.core; 27 | 28 | /** 29 | * 30 | * 字符集识别工具类 31 | */ 32 | class CharacterUtil { 33 | 34 | public static final int CHAR_USELESS = 0; 35 | 36 | public static final int CHAR_ARABIC = 0X00000001; 37 | 38 | public static final int CHAR_ENGLISH = 0X00000002; 39 | 40 | public static final int CHAR_CHINESE = 0X00000004; 41 | 42 | public static final int CHAR_OTHER_CJK = 0X00000008; 43 | 44 | 45 | /** 46 | * 识别字符类型 47 | * @param input 48 | * @return int CharacterUtil定义的字符类型常量 49 | */ 50 | static int identifyCharType(char input){ 51 | if(input >= '0' && input <= '9'){ 52 | return CHAR_ARABIC; 53 | 54 | }else if((input >= 'a' && input <= 'z') 55 | || (input >= 'A' && input <= 'Z')){ 56 | return CHAR_ENGLISH; 57 | 58 | }else { 59 | Character.UnicodeBlock ub = Character.UnicodeBlock.of(input); 60 | 61 | if(ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS 62 | || ub == Character.UnicodeBlock.CJK_COMPATIBILITY_IDEOGRAPHS 63 | || ub == Character.UnicodeBlock.CJK_UNIFIED_IDEOGRAPHS_EXTENSION_A){ 64 | //目前已知的中文字符UTF-8集合 65 | return CHAR_CHINESE; 66 | 67 | }else if(ub == Character.UnicodeBlock.HALFWIDTH_AND_FULLWIDTH_FORMS //全角数字字符和日韩字符 68 | //韩文字符集 69 | || ub == Character.UnicodeBlock.HANGUL_SYLLABLES 70 | || ub == Character.UnicodeBlock.HANGUL_JAMO 71 | || ub == Character.UnicodeBlock.HANGUL_COMPATIBILITY_JAMO 72 | //日文字符集 73 | || ub == Character.UnicodeBlock.HIRAGANA //平假名 74 | || ub == Character.UnicodeBlock.KATAKANA //片假名 75 | || ub == Character.UnicodeBlock.KATAKANA_PHONETIC_EXTENSIONS){ 76 | return CHAR_OTHER_CJK; 77 | 78 | } 79 | } 80 | //其他的不做处理的字符 81 | return CHAR_USELESS; 82 | } 83 | 84 | /** 85 | * 进行字符规格化(全角转半角,大写转小写处理) 86 | * @param input 87 | * @return char 88 | */ 89 | static char regularize(char input){ 90 | if (input == 12288) { 91 | input = (char) 32; 92 | 93 | }else if (input > 65280 && input < 65375) { 94 | input = (char) (input - 65248); 95 | 96 | }else if (input >= 'A' && input <= 'Z') { 97 | input += 32; 98 | } 99 | 100 | return input; 101 | } 102 | } 103 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/org/json/JSONStringer.java: -------------------------------------------------------------------------------- 1 | package weibo4j.org.json; 2 | 3 | /* 4 | Copyright (c) 2006 JSON.org 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | The Software shall be used for Good, not Evil. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | import java.io.StringWriter; 28 | 29 | /** 30 | * JSONStringer provides a quick and convenient way of producing JSON text. 31 | * The texts produced strictly conform to JSON syntax rules. No whitespace is 32 | * added, so the results are ready for transmission or storage. Each instance of 33 | * JSONStringer can produce one JSON text. 34 | *

35 | * A JSONStringer instance provides a value method for appending 36 | * values to the 37 | * text, and a key 38 | * method for adding keys before values in objects. There are array 39 | * and endArray methods that make and bound array values, and 40 | * object and endObject methods which make and bound 41 | * object values. All of these methods return the JSONWriter instance, 42 | * permitting cascade style. For example,

43 |  * myString = new JSONStringer()
44 |  *     .object()
45 |  *         .key("JSON")
46 |  *         .value("Hello, World!")
47 |  *     .endObject()
48 |  *     .toString();
which produces the string
49 |  * {"JSON":"Hello, World!"}
50 | *

51 | * The first method called must be array or object. 52 | * There are no methods for adding commas or colons. JSONStringer adds them for 53 | * you. Objects and arrays can be nested up to 20 levels deep. 54 | *

55 | * This can sometimes be easier than using a JSONObject to build a string. 56 | * @author JSON.org 57 | * @version 2008-09-18 58 | */ 59 | public class JSONStringer extends JSONWriter { 60 | /** 61 | * Make a fresh JSONStringer. It can be used to build one JSON text. 62 | */ 63 | public JSONStringer() { 64 | super(new StringWriter()); 65 | } 66 | 67 | /** 68 | * Return the JSON text. This method is used to obtain the product of the 69 | * JSONStringer instance. It will return null if there was a 70 | * problem in the construction of the JSON text (such as the calls to 71 | * array were not properly balanced with calls to 72 | * endArray). 73 | * @return The JSON text. 74 | */ 75 | public String toString() { 76 | return this.mode == 'd' ? this.writer.toString() : null; 77 | } 78 | } 79 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/WeiboException.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007-2009, Yusuke Yamamoto 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Yusuke Yamamoto nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Yusuke Yamamoto ``AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Yusuke Yamamoto BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package weibo4j.model; 28 | 29 | import weibo4j.org.json.JSONException; 30 | import weibo4j.org.json.JSONObject; 31 | 32 | /** 33 | * An exception class that will be thrown when WeiboAPI calls are failed.
34 | * In case the Weibo server returned HTTP error code, you can get the HTTP status code using getStatusCode() method. 35 | * @author Yusuke Yamamoto - yusuke at mac.com 36 | */ 37 | public class WeiboException extends Exception { 38 | private int statusCode = -1; 39 | private int errorCode = -1; 40 | private String request; 41 | private String error; 42 | private static final long serialVersionUID = -2623309261327598087L; 43 | 44 | public WeiboException(String msg) { 45 | super(msg); 46 | } 47 | 48 | public WeiboException(Exception cause) { 49 | super(cause); 50 | } 51 | 52 | public WeiboException(String msg , int statusCode) throws JSONException { 53 | super(msg); 54 | this.statusCode = statusCode; 55 | } 56 | 57 | public WeiboException(String msg , JSONObject json, int statusCode) throws JSONException { 58 | super(msg + "\n error:" + json.getString("error") +" error_code:" + json.getInt("error_code") + json.getString("request")); 59 | this.statusCode = statusCode; 60 | this.errorCode = json.getInt("error_code"); 61 | this.error = json.getString("error"); 62 | this.request = json.getString("request"); 63 | 64 | } 65 | 66 | public WeiboException(String msg, Exception cause) { 67 | super(msg, cause); 68 | } 69 | 70 | public WeiboException(String msg, Exception cause, int statusCode) { 71 | super(msg, cause); 72 | this.statusCode = statusCode; 73 | 74 | } 75 | 76 | public int getStatusCode() { 77 | return this.statusCode; 78 | } 79 | 80 | public int getErrorCode() { 81 | return errorCode; 82 | } 83 | 84 | public String getRequest() { 85 | return request; 86 | } 87 | 88 | public String getError() { 89 | return error; 90 | } 91 | 92 | } 93 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/org/json/CookieList.java: -------------------------------------------------------------------------------- 1 | package weibo4j.org.json; 2 | 3 | /* 4 | Copyright (c) 2002 JSON.org 5 | 6 | Permission is hereby granted, free of charge, to any person obtaining a copy 7 | of this software and associated documentation files (the "Software"), to deal 8 | in the Software without restriction, including without limitation the rights 9 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell 10 | copies of the Software, and to permit persons to whom the Software is 11 | furnished to do so, subject to the following conditions: 12 | 13 | The above copyright notice and this permission notice shall be included in all 14 | copies or substantial portions of the Software. 15 | 16 | The Software shall be used for Good, not Evil. 17 | 18 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 19 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 20 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 21 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 22 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, 23 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE 24 | SOFTWARE. 25 | */ 26 | 27 | import java.util.Iterator; 28 | 29 | /** 30 | * Convert a web browser cookie list string to a JSONObject and back. 31 | * @author JSON.org 32 | * @version 2008-09-18 33 | */ 34 | public class CookieList { 35 | 36 | /** 37 | * Convert a cookie list into a JSONObject. A cookie list is a sequence 38 | * of name/value pairs. The names are separated from the values by '='. 39 | * The pairs are separated by ';'. The names and the values 40 | * will be unescaped, possibly converting '+' and '%' sequences. 41 | * 42 | * To add a cookie to a cooklist, 43 | * cookielistJSONObject.put(cookieJSONObject.getString("name"), 44 | * cookieJSONObject.getString("value")); 45 | * @param string A cookie list string 46 | * @return A JSONObject 47 | * @throws JSONException 48 | */ 49 | public static JSONObject toJSONObject(String string) throws JSONException { 50 | JSONObject o = new JSONObject(); 51 | JSONTokener x = new JSONTokener(string); 52 | while (x.more()) { 53 | String name = Cookie.unescape(x.nextTo('=')); 54 | x.next('='); 55 | o.put(name, Cookie.unescape(x.nextTo(';'))); 56 | x.next(); 57 | } 58 | return o; 59 | } 60 | 61 | 62 | /** 63 | * Convert a JSONObject into a cookie list. A cookie list is a sequence 64 | * of name/value pairs. The names are separated from the values by '='. 65 | * The pairs are separated by ';'. The characters '%', '+', '=', and ';' 66 | * in the names and values are replaced by "%hh". 67 | * @param o A JSONObject 68 | * @return A cookie list string 69 | * @throws JSONException 70 | */ 71 | public static String toString(JSONObject o) throws JSONException { 72 | boolean b = false; 73 | Iterator keys = o.keys(); 74 | String s; 75 | StringBuffer sb = new StringBuffer(); 76 | while (keys.hasNext()) { 77 | s = keys.next().toString(); 78 | if (!o.isNull(s)) { 79 | if (b) { 80 | sb.append(';'); 81 | } 82 | sb.append(Cookie.escape(s)); 83 | sb.append("="); 84 | sb.append(Cookie.escape(o.getString(s))); 85 | b = true; 86 | } 87 | } 88 | return sb.toString(); 89 | } 90 | } 91 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/util/URLEncodeUtils.java: -------------------------------------------------------------------------------- 1 | package weibo4j.util; 2 | import java.io.UnsupportedEncodingException; 3 | import java.net.URLDecoder; 4 | import java.net.URLEncoder; 5 | import java.util.BitSet; 6 | /** 7 | * @author sinaWeibo 8 | * 9 | */ 10 | public class URLEncodeUtils { 11 | 12 | static BitSet dontNeedEncoding; 13 | 14 | static { 15 | 16 | /* 17 | * The list of characters that are not encoded has been determined as 18 | * follows: 19 | * 20 | * RFC 2396 states: ----- Data characters that are allowed in a URI but 21 | * do not have a reserved purpose are called unreserved. These include 22 | * upper and lower case letters, decimal digits, and a limited set of 23 | * punctuation marks and symbols. 24 | * 25 | * unreserved = alphanum | mark 26 | * 27 | * mark = "-" | "_" | "." | "!" | "~" | "*" | "'" | "(" | ")" 28 | * 29 | * Unreserved characters can be escaped without changing the semantics 30 | * of the URI, but this should not be done unless the URI is being used 31 | * in a context that does not allow the unescaped character to appear. 32 | * ----- 33 | * 34 | * It appears that both Netscape and Internet Explorer escape all 35 | * special characters from this list with the exception of "-", "_", 36 | * ".", "*". While it is not clear why they are escaping the other 37 | * characters, perhaps it is safest to assume that there might be 38 | * contexts in which the others are unsafe if not escaped. Therefore, we 39 | * will use the same list. It is also noteworthy that this is consistent 40 | * with O'Reilly's "HTML: The Definitive Guide" (page 164). 41 | * 42 | * As a last note, Intenet Explorer does not encode the "@" character 43 | * which is clearly not unreserved according to the RFC. We are being 44 | * consistent with the RFC in this matter, as is Netscape. 45 | */ 46 | 47 | dontNeedEncoding = new BitSet(256); 48 | int i; 49 | for (i = 'a'; i <= 'z'; i++) { 50 | dontNeedEncoding.set(i); 51 | } 52 | for (i = 'A'; i <= 'Z'; i++) { 53 | dontNeedEncoding.set(i); 54 | } 55 | for (i = '0'; i <= '9'; i++) { 56 | dontNeedEncoding.set(i); 57 | } 58 | dontNeedEncoding.set(' '); /* 59 | * encoding a space to a + is done in the 60 | * encode() method 61 | */ 62 | dontNeedEncoding.set('-'); 63 | dontNeedEncoding.set('_'); 64 | dontNeedEncoding.set('.'); 65 | dontNeedEncoding.set('*'); 66 | 67 | dontNeedEncoding.set('+'); 68 | dontNeedEncoding.set('%'); 69 | 70 | } 71 | 72 | /** 73 | * 判断段落文本是否被urlencode过 74 | * 75 | * @param str 76 | * @return 77 | */ 78 | public static final boolean isURLEncoded(String str) { 79 | if (str==null||"".equals(str)) { 80 | return false; 81 | } 82 | char[] chars = str.toCharArray(); 83 | boolean containsPercent = false; 84 | for (char c : chars) { 85 | if (Character.isWhitespace(c)) { 86 | return false; 87 | } 88 | if (!dontNeedEncoding.get(c)) { 89 | return false; 90 | } 91 | if(c == '%'){ 92 | containsPercent = true; 93 | } 94 | } 95 | if(!containsPercent){ 96 | return false; 97 | } 98 | return true; 99 | } 100 | 101 | public static final String encodeURL(String str) { 102 | try { 103 | return URLEncoder.encode(str, "utf-8"); 104 | } catch (UnsupportedEncodingException e) { 105 | throw new RuntimeException(e); 106 | } 107 | } 108 | public static final String decodeURL(String str) { 109 | try { 110 | return URLDecoder.decode(str, "utf-8"); 111 | } catch (UnsupportedEncodingException e) { 112 | throw new RuntimeException(e); 113 | } 114 | } 115 | 116 | } 117 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/Place.java: -------------------------------------------------------------------------------- 1 | package weibo4j; 2 | 3 | import weibo4j.model.PostParameter; 4 | import weibo4j.model.Status; 5 | import weibo4j.model.StatusWapper; 6 | import weibo4j.model.User; 7 | import weibo4j.model.WeiboException; 8 | import weibo4j.org.json.JSONObject; 9 | import weibo4j.util.WeiboConfig; 10 | 11 | public class Place extends Weibo{ 12 | 13 | /** 14 | * 15 | */ 16 | private static final long serialVersionUID = 1L; 17 | 18 | /****************动态读取************************/ 19 | /** 20 | * 注:没有写完 21 | * 22 | * 获取当前登录用户与其好友的位置动态 23 | */ 24 | public StatusWapper friendsTimeLine () throws WeiboException { 25 | return Status.constructWapperStatus(client.get(WeiboConfig.getValue("baseURL") + "place/friends_timeline.json")); 26 | } 27 | 28 | 29 | /****************用户读取************************/ 30 | /** 31 | * 获取LBS位置服务内的用户信息 32 | * 33 | * 34 | */ 35 | public JSONObject userInfoInLBS (String uid) throws WeiboException { 36 | return client.get(WeiboConfig.getValue("baseURL") + "place/users/show.json",new PostParameter[] { 37 | new PostParameter("uid", uid) 38 | }).asJSONObject(); 39 | } 40 | 41 | public JSONObject userInfoInLBS (String uid,int base_app) throws WeiboException { 42 | return client.get(WeiboConfig.getValue("baseURL") + "place/users/show.json",new PostParameter[] { 43 | new PostParameter("uid", uid), 44 | new PostParameter("base_app", base_app) 45 | }).asJSONObject(); 46 | } 47 | 48 | /** 49 | * 获取用户签到过的地点列表 50 | * 51 | * 注:没有写完 52 | */ 53 | public JSONObject checkinsList (String uid) throws WeiboException { 54 | return client.get(WeiboConfig.getValue("baseURL") + "place/users/checkins.json",new PostParameter[] { 55 | new PostParameter("uid", uid) 56 | }).asJSONObject(); 57 | } 58 | 59 | /** 60 | * 获取用户的照片列表 61 | * 62 | * 注:没有写完 63 | */ 64 | 65 | public JSONObject photoList (String uid) throws WeiboException { 66 | return client.get(WeiboConfig.getValue("baseURL") + "place/users/photos.json",new PostParameter[] { 67 | new PostParameter("uid", uid) 68 | }).asJSONObject(); 69 | } 70 | 71 | /** 72 | * 获取用户的点评列表 73 | * 74 | * 注:没有写完 75 | */ 76 | 77 | public JSONObject tipsList (String uid) throws WeiboException { 78 | return client.get(WeiboConfig.getValue("baseURL") + "place/users/tips.json",new PostParameter[] { 79 | new PostParameter("uid", uid) 80 | }).asJSONObject(); 81 | } 82 | 83 | /****************地点读取************************/ 84 | /** 85 | * 获取地点详情 86 | * 87 | * 88 | */ 89 | public JSONObject poisShow (String poiid) throws WeiboException { 90 | return client.get(WeiboConfig.getValue("baseURL") + "place/pois/show.json",new PostParameter[] { 91 | new PostParameter("poiid", poiid) 92 | }).asJSONObject(); 93 | } 94 | 95 | public JSONObject poisShow (String poiid,int base_app) throws WeiboException { 96 | return client.get(WeiboConfig.getValue("baseURL") + "place/pois/show.json",new PostParameter[] { 97 | new PostParameter("poiid", poiid), 98 | new PostParameter("base_app",base_app) 99 | }).asJSONObject(); 100 | } 101 | 102 | /** 103 | * 获取在某个地点签到的人的列表 104 | * 105 | * 注:没写完 106 | */ 107 | public JSONObject poisUsersList (String poiid) throws WeiboException { 108 | return client.get(WeiboConfig.getValue("baseURL") + "place/pois/show.json",new PostParameter[] { 109 | new PostParameter("poiid", poiid) }).asJSONObject(); 110 | } 111 | 112 | /** 113 | * 获取在某个地点点评的列表 114 | * 115 | * 注:没写完 116 | */ 117 | public User poisTipsList (String poiid) throws WeiboException { 118 | return new User(client.get(WeiboConfig.getValue("baseURL") + "place/pois/tips.json",new PostParameter[] { 119 | new PostParameter("poiid", poiid) }).asJSONObject()); 120 | } 121 | 122 | } 123 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/org/wltea/analyzer/lucene/IKTokenizer.java: -------------------------------------------------------------------------------- 1 | /** 2 | * IK 中文分词 版本 5.0.1 3 | * IK Analyzer release 5.0.1 4 | * 5 | * Licensed to the Apache Software Foundation (ASF) under one or more 6 | * contributor license agreements. See the NOTICE file distributed with 7 | * this work for additional information regarding copyright ownership. 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 9 | * (the "License"); you may not use this file except in compliance with 10 | * the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * 源代码由林良益(linliangyi2005@gmail.com)提供 21 | * 版权声明 2012,乌龙茶工作室 22 | * provided by Linliangyi and copyright 2012 by Oolong studio 23 | * 24 | 25 | * 26 | */ 27 | package org.wltea.analyzer.lucene; 28 | 29 | import java.io.IOException; 30 | import java.io.Reader; 31 | 32 | import org.apache.lucene.analysis.Tokenizer; 33 | import org.apache.lucene.analysis.tokenattributes.CharTermAttribute; 34 | import org.apache.lucene.analysis.tokenattributes.OffsetAttribute; 35 | import org.apache.lucene.analysis.tokenattributes.TypeAttribute; 36 | 37 | import org.wltea.analyzer.core.IKSegmenter; 38 | import org.wltea.analyzer.core.Lexeme; 39 | 40 | /** 41 | * IK分词器 Lucene Tokenizer适配器类 42 | * 兼容Lucene 4.0版本 43 | */ 44 | public final class IKTokenizer extends Tokenizer { 45 | 46 | //IK分词器实现 47 | private IKSegmenter _IKImplement; 48 | 49 | //词元文本属性 50 | private final CharTermAttribute termAtt; 51 | //词元位移属性 52 | private final OffsetAttribute offsetAtt; 53 | //词元分类属性(该属性分类参考org.wltea.analyzer.core.Lexeme中的分类常量) 54 | private final TypeAttribute typeAtt; 55 | //记录最后一个词元的结束位置 56 | private int endPosition; 57 | 58 | /** 59 | * Lucene 4.0 Tokenizer适配器类构造函数 60 | * @param in 61 | * @param useSmart 62 | */ 63 | public IKTokenizer(Reader in , boolean useSmart){ 64 | super(in); 65 | offsetAtt = addAttribute(OffsetAttribute.class); 66 | termAtt = addAttribute(CharTermAttribute.class); 67 | typeAtt = addAttribute(TypeAttribute.class); 68 | _IKImplement = new IKSegmenter(input , useSmart); 69 | } 70 | 71 | /* (non-Javadoc) 72 | * @see org.apache.lucene.analysis.TokenStream#incrementToken() 73 | */ 74 | @Override 75 | public boolean incrementToken() throws IOException { 76 | //清除所有的词元属性 77 | clearAttributes(); 78 | Lexeme nextLexeme = _IKImplement.next(); 79 | if(nextLexeme != null){ 80 | //将Lexeme转成Attributes 81 | //设置词元文本 82 | termAtt.append(nextLexeme.getLexemeText()); 83 | //设置词元长度 84 | termAtt.setLength(nextLexeme.getLength()); 85 | //设置词元位移 86 | offsetAtt.setOffset(nextLexeme.getBeginPosition(), nextLexeme.getEndPosition()); 87 | //记录分词的最后位置 88 | endPosition = nextLexeme.getEndPosition(); 89 | //记录词元分类 90 | typeAtt.setType(nextLexeme.getLexemeTypeString()); 91 | //返会true告知还有下个词元 92 | return true; 93 | } 94 | //返会false告知词元输出完毕 95 | return false; 96 | } 97 | 98 | /* 99 | * (non-Javadoc) 100 | * @see org.apache.lucene.analysis.Tokenizer#reset(java.io.Reader) 101 | */ 102 | @Override 103 | public void reset() throws IOException { 104 | super.reset(); 105 | _IKImplement.reset(input); 106 | } 107 | 108 | @Override 109 | public final void end() { 110 | // set final offset 111 | int finalOffset = correctOffset(this.endPosition); 112 | offsetAtt.setOffset(finalOffset, finalOffset); 113 | } 114 | } 115 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/Account.java: -------------------------------------------------------------------------------- 1 | package weibo4j; 2 | 3 | import java.util.List; 4 | import weibo4j.model.PostParameter; 5 | import weibo4j.model.RateLimitStatus; 6 | import weibo4j.model.School; 7 | import weibo4j.model.WeiboException; 8 | import weibo4j.org.json.JSONObject; 9 | import weibo4j.util.WeiboConfig; 10 | 11 | public class Account extends Weibo{ 12 | 13 | private static final long serialVersionUID = 3816005087976772682L; 14 | 15 | /** 16 | * OAuth授权之后,获取授权用户的UID 17 | * 18 | * @return uid 19 | * @throws WeiboException 20 | * when Weibo service or network is unavailable 21 | * @version weibo4j-V2 1.0.1 22 | * @see account/get_uid 24 | * @since JDK 1.5 25 | */ 26 | public JSONObject getUid() throws WeiboException { 27 | return client.get( 28 | WeiboConfig.getValue("baseURL") + "account/get_uid.json").asJSONObject(); 29 | } 30 | 31 | /** 32 | * 获取当前登录用户的隐私设置 33 | * 34 | * @param uid 35 | * @return User's privacy 36 | * @throws WeiboException 37 | * when Weibo service or network is unavailable 38 | * @version weibo4j-V2 1.0.1 39 | * @see account/get_privacy 41 | * @since JDK 1.5 42 | */ 43 | public JSONObject getAccountPrivacy() throws WeiboException { 44 | return client.get( 45 | WeiboConfig.getValue("baseURL") + "account/get_privacy.json") 46 | .asJSONObject(); 47 | } 48 | 49 | /** 50 | * 获取所有学校列表 51 | * 52 | * @return list of school 53 | * @throws WeiboException 54 | * when Weibo service or network is unavailable 55 | * @version weibo4j-V2 1.0.1 56 | * @see account/profile/school_list 58 | * @since JDK 1.5 59 | */ 60 | public List getAccountPrpfileSchoolList() throws WeiboException { 61 | return School.constructSchool(client.get(WeiboConfig 62 | .getValue("baseURL") + "account/profile/school_list.json")); 63 | } 64 | 65 | /** 66 | * 获取所有学校列表 67 | * 68 | * @param province 69 | * ,city,area,type,capital,keyword,count 70 | * @return list of school 71 | * @throws WeiboException 72 | * when Weibo service or network is unavailable 73 | * @version weibo4j-V2 1.0.1 74 | * @see account/profile/school_list 76 | * @since JDK 1.5 77 | */ 78 | public List getAccountPrpfileSchoolList(Integer province, 79 | Integer city, Integer area, Integer type, String capital, 80 | String keyword, Integer count) throws WeiboException { 81 | return School.constructSchool(client.get( 82 | WeiboConfig.getValue("baseURL") 83 | + "account/profile/school_list.json", 84 | new PostParameter[] { 85 | new PostParameter("province", province.toString()), 86 | new PostParameter("city", city.toString()), 87 | new PostParameter("area", area.toString()), 88 | new PostParameter("type", type.toString()), 89 | new PostParameter("capital", capital), 90 | new PostParameter("keyword", keyword), 91 | new PostParameter("count", count.toString()) })); 92 | } 93 | 94 | /** 95 | * 获取当前登录用户的API访问频率限制情况 96 | * 97 | * @return ratelimit 98 | * @throws WeiboException 99 | * when Weibo service or network is unavailable 100 | * @version weibo4j-V2 1.0.1 101 | * @see account/rate_limit_status 103 | * @since JDK 1.5 104 | */ 105 | public RateLimitStatus getAccountRateLimitStatus() throws WeiboException { 106 | return new RateLimitStatus(client.get(WeiboConfig 107 | .getValue("baseURL") + "account/rate_limit_status.json")); 108 | } 109 | } 110 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/Oauth.java: -------------------------------------------------------------------------------- 1 | package weibo4j; 2 | 3 | import java.io.IOException; 4 | import java.security.InvalidKeyException; 5 | import java.security.NoSuchAlgorithmException; 6 | 7 | import javax.crypto.Mac; 8 | import javax.crypto.SecretKey; 9 | import javax.crypto.spec.SecretKeySpec; 10 | 11 | import weibo4j.http.AccessToken; 12 | import weibo4j.http.BASE64Encoder; 13 | import weibo4j.model.PostParameter; 14 | import weibo4j.model.WeiboException; 15 | import weibo4j.org.json.JSONException; 16 | import weibo4j.org.json.JSONObject; 17 | import weibo4j.util.WeiboConfig; 18 | 19 | public class Oauth extends Weibo{ 20 | /** 21 | * 22 | */ 23 | private static final long serialVersionUID = 7003420545330439247L; 24 | // ----------------------------针对站内应用处理SignedRequest获取accesstoken---------------------------------------- 25 | public String access_token; 26 | public String user_id; 27 | 28 | public String getToken() { 29 | return access_token; 30 | } 31 | 32 | /* 33 | * 解析站内应用post的SignedRequest split为part1和part2两部分 34 | */ 35 | public String parseSignedRequest(String signed_request) throws IOException, 36 | InvalidKeyException, NoSuchAlgorithmException { 37 | String[] t = signed_request.split("\\.", 2); 38 | // 为了和 url encode/decode 不冲突,base64url 编码方式会将 39 | // '+','/'转换成'-','_',并且去掉结尾的'='。 因此解码之前需要还原到默认的base64编码,结尾的'='可以用以下算法还原 40 | int padding = (4 - t[0].length() % 4); 41 | for (int i = 0; i < padding; i++) 42 | t[0] += "="; 43 | String part1 = t[0].replace("-", "+").replace("_", "/"); 44 | 45 | SecretKey key = new SecretKeySpec(WeiboConfig 46 | .getValue("client_SERCRET").getBytes(), "hmacSHA256"); 47 | Mac m; 48 | m = Mac.getInstance("hmacSHA256"); 49 | m.init(key); 50 | m.update(t[1].getBytes()); 51 | String part1Expect = BASE64Encoder.encode(m.doFinal()); 52 | 53 | sun.misc.BASE64Decoder decode = new sun.misc.BASE64Decoder(); 54 | String s = new String(decode.decodeBuffer(t[1])); 55 | if (part1.equals(part1Expect)) { 56 | return ts(s); 57 | } else { 58 | return null; 59 | } 60 | } 61 | 62 | /* 63 | * 处理解析后的json解析 64 | */ 65 | public String ts(String json) { 66 | try { 67 | JSONObject jsonObject = new JSONObject(json); 68 | access_token = jsonObject.getString("oauth_token"); 69 | user_id = jsonObject.getString("user_id"); 70 | } catch (JSONException e) { 71 | e.printStackTrace(); 72 | } 73 | return access_token; 74 | 75 | } 76 | 77 | /*----------------------------Oauth接口--------------------------------------*/ 78 | 79 | public AccessToken getAccessTokenByCode(String code) throws WeiboException { 80 | return new AccessToken(client.post( 81 | WeiboConfig.getValue("accessTokenURL"), 82 | new PostParameter[] { 83 | new PostParameter("client_id", WeiboConfig 84 | .getValue("client_ID")), 85 | new PostParameter("client_secret", WeiboConfig 86 | .getValue("client_SERCRET")), 87 | new PostParameter("grant_type", "authorization_code"), 88 | new PostParameter("code", code), 89 | new PostParameter("redirect_uri", WeiboConfig 90 | .getValue("redirect_URI")) }, false)); 91 | } 92 | 93 | public String authorize(String response_type,String state) throws WeiboException { 94 | return WeiboConfig.getValue("authorizeURL").trim() + "?client_id=" 95 | + WeiboConfig.getValue("client_ID").trim() + "&redirect_uri=" 96 | + WeiboConfig.getValue("redirect_URI").trim() 97 | + "&response_type=" + response_type 98 | + "&state="+state; 99 | } 100 | public String authorize(String response_type,String state,String scope) throws WeiboException { 101 | return WeiboConfig.getValue("authorizeURL").trim() + "?client_id=" 102 | + WeiboConfig.getValue("client_ID").trim() + "&redirect_uri=" 103 | + WeiboConfig.getValue("redirect_URI").trim() 104 | + "&response_type=" + response_type 105 | + "&state="+state 106 | + "&scope="+scope; 107 | } 108 | } 109 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/Search.java: -------------------------------------------------------------------------------- 1 | package weibo4j; 2 | 3 | import weibo4j.model.PostParameter; 4 | import weibo4j.model.WeiboException; 5 | import weibo4j.org.json.JSONArray; 6 | import weibo4j.util.WeiboConfig; 7 | 8 | public class Search extends Weibo{ 9 | //---------------------------------搜索接口----------------------------------------------- 10 | 11 | /** 12 | * 13 | */ 14 | private static final long serialVersionUID = 1060145395982699914L; 15 | public JSONArray searchSuggestionsUsers(String q) throws WeiboException{ 16 | return client.get(WeiboConfig.getValue("baseURL")+"search/suggestions/users.json",new PostParameter[]{ 17 | new PostParameter("q", q) 18 | }).asJSONArray(); 19 | } 20 | public JSONArray searchSuggestionsUsers(String q,int count) throws WeiboException{ 21 | return client.get(WeiboConfig.getValue("baseURL")+"search/suggestions/users.json",new PostParameter[]{ 22 | new PostParameter("q", q), 23 | new PostParameter("count", count) 24 | }).asJSONArray(); 25 | } 26 | public JSONArray searchSuggestionsStatuses(String q) throws WeiboException{ 27 | return client.get(WeiboConfig.getValue("baseURL")+"search/suggestions/statuses.json",new PostParameter[]{ 28 | new PostParameter("q", q) 29 | }).asJSONArray(); 30 | } 31 | public JSONArray searchSuggestionsStatuses(String q,int count) throws WeiboException{ 32 | return client.get(WeiboConfig.getValue("baseURL")+"search/suggestions/statuses.json",new PostParameter[]{ 33 | new PostParameter("q", q), 34 | new PostParameter("count", count) 35 | }).asJSONArray(); 36 | } 37 | public JSONArray searchSuggestionsCompanies(String q) throws WeiboException{ 38 | return client.get(WeiboConfig.getValue("baseURL")+"search/suggestions/companies.json",new PostParameter[]{ 39 | new PostParameter("q", q) 40 | }).asJSONArray(); 41 | } 42 | public JSONArray searchSuggestionsCompanies(String q,int count) throws WeiboException{ 43 | return client.get(WeiboConfig.getValue("baseURL")+"search/suggestions/companies.json",new PostParameter[]{ 44 | new PostParameter("q", q), 45 | new PostParameter("count", count) 46 | }).asJSONArray(); 47 | } 48 | public JSONArray searchSuggestionsApps(String q) throws WeiboException{ 49 | return client.get(WeiboConfig.getValue("baseURL")+"search/suggestions/apps.json",new PostParameter[]{ 50 | new PostParameter("q", q) 51 | }).asJSONArray(); 52 | } 53 | public JSONArray searchSuggestionsApps(String q,int count) throws WeiboException{ 54 | return client.get(WeiboConfig.getValue("baseURL")+"search/suggestions/apps.json",new PostParameter[]{ 55 | new PostParameter("q", q), 56 | new PostParameter("count", count) 57 | }).asJSONArray(); 58 | } 59 | public JSONArray searchSuggestionsSchools(String q) throws WeiboException{ 60 | return client.get(WeiboConfig.getValue("baseURL")+"search/suggestions/schools.json",new PostParameter[]{ 61 | new PostParameter("q", q) 62 | }).asJSONArray(); 63 | } 64 | public JSONArray searchSuggestionsSchools(String q,int count,int type) throws WeiboException{ 65 | return client.get(WeiboConfig.getValue("baseURL")+"search/suggestions/schools.json",new PostParameter[]{ 66 | new PostParameter("q", q), 67 | new PostParameter("count", count), 68 | new PostParameter("type", type) 69 | }).asJSONArray(); 70 | } 71 | public JSONArray searchSuggestionsAt_users(String q,int type) throws WeiboException{ 72 | return client.get(WeiboConfig.getValue("baseURL")+"search/suggestions/at_users.json",new PostParameter[]{ 73 | new PostParameter("q", q), 74 | new PostParameter("type", type) 75 | }).asJSONArray(); 76 | } 77 | public JSONArray searchSuggestionsAt_users(String q,int count,int type,int range) throws WeiboException{ 78 | return client.get(WeiboConfig.getValue("baseURL")+"search/suggestions/at_users.json",new PostParameter[]{ 79 | new PostParameter("q", q), 80 | new PostParameter("count", count), 81 | new PostParameter("type", type), 82 | new PostParameter("range",range) 83 | }).asJSONArray(); 84 | } 85 | } 86 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/Trend.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007-2009, Yusuke Yamamoto 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Yusuke Yamamoto nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Yusuke Yamamoto ``AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Yusuke Yamamoto BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package weibo4j.model; 28 | 29 | import weibo4j.org.json.JSONException; 30 | import weibo4j.org.json.JSONObject; 31 | 32 | /** 33 | * A data class representing Treand. 34 | * 35 | * @author Yusuke Yamamoto - yusuke at mac.com 36 | * @since Weibo4J 1.2.1 37 | */ 38 | public class Trend implements java.io.Serializable{ 39 | private String name; 40 | private String query = null; 41 | private long amount; 42 | private long delta; 43 | private static final long serialVersionUID = 1925956704460743946L; 44 | 45 | public Trend(JSONObject json) throws JSONException { 46 | this.name = json.getString("name"); 47 | if (!json.isNull("query")) { 48 | this.query = json.getString("query"); 49 | } 50 | this.amount =json.getLong("amount"); 51 | this.delta = json.getLong("delta"); 52 | } 53 | 54 | public String getName() { 55 | return name; 56 | } 57 | 58 | 59 | public String getQuery() { 60 | return query; 61 | } 62 | 63 | public long getAmount() { 64 | return amount; 65 | } 66 | 67 | public void setAmount(long amount) { 68 | this.amount = amount; 69 | } 70 | 71 | public long getDelta() { 72 | return delta; 73 | } 74 | 75 | public void setDelta(long delta) { 76 | this.delta = delta; 77 | } 78 | 79 | public void setName(String name) { 80 | this.name = name; 81 | } 82 | 83 | public void setQuery(String query) { 84 | this.query = query; 85 | } 86 | 87 | @Override 88 | public boolean equals(Object o) { 89 | if (this == o) return true; 90 | if (!(o instanceof Trend)) return false; 91 | 92 | Trend trend = (Trend) o; 93 | 94 | if (!name.equals(trend.name)) return false; 95 | if (query != null ? !query.equals(trend.query) : trend.query != null) 96 | return false; 97 | 98 | return true; 99 | } 100 | 101 | @Override 102 | public int hashCode() { 103 | int result = name.hashCode(); 104 | result = 31 * result + (query != null ? query.hashCode() : 0); 105 | return result; 106 | } 107 | 108 | @Override 109 | public String toString() { 110 | return "Trend [name=" + name + ", query=" + query + ", amount=" 111 | + amount + ", delta=" + delta + "]"; 112 | } 113 | 114 | } 115 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/org/wltea/analyzer/core/CJKSegmenter.java: -------------------------------------------------------------------------------- 1 | 2 | /** 3 | * IK 中文分词 版本 5.0 4 | * IK Analyzer release 5.0 5 | * 6 | * Licensed to the Apache Software Foundation (ASF) under one or more 7 | * contributor license agreements. See the NOTICE file distributed with 8 | * this work for additional information regarding copyright ownership. 9 | * The ASF licenses this file to You under the Apache License, Version 2.0 10 | * (the "License"); you may not use this file except in compliance with 11 | * the License. You may obtain a copy of the License at 12 | * 13 | * http://www.apache.org/licenses/LICENSE-2.0 14 | * 15 | * Unless required by applicable law or agreed to in writing, software 16 | * distributed under the License is distributed on an "AS IS" BASIS, 17 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 18 | * See the License for the specific language governing permissions and 19 | * limitations under the License. 20 | * 21 | * 源代码由林良益(linliangyi2005@gmail.com)提供 22 | * 版权声明 2012,乌龙茶工作室 23 | * provided by Linliangyi and copyright 2012 by Oolong studio 24 | * 25 | */ 26 | package org.wltea.analyzer.core; 27 | 28 | import java.util.LinkedList; 29 | import java.util.List; 30 | 31 | import org.wltea.analyzer.dic.Dictionary; 32 | import org.wltea.analyzer.dic.Hit; 33 | 34 | 35 | /** 36 | * 中文-日韩文子分词器 37 | */ 38 | class CJKSegmenter implements ISegmenter { 39 | 40 | //子分词器标签 41 | static final String SEGMENTER_NAME = "CJK_SEGMENTER"; 42 | //待处理的分词hit队列 43 | private List tmpHits; 44 | 45 | 46 | CJKSegmenter(){ 47 | this.tmpHits = new LinkedList(); 48 | } 49 | 50 | /* (non-Javadoc) 51 | * @see org.wltea.analyzer.core.ISegmenter#analyze(org.wltea.analyzer.core.AnalyzeContext) 52 | */ 53 | public void analyze(AnalyzeContext context) { 54 | if(CharacterUtil.CHAR_USELESS != context.getCurrentCharType()){ 55 | 56 | //优先处理tmpHits中的hit 57 | if(!this.tmpHits.isEmpty()){ 58 | //处理词段队列 59 | Hit[] tmpArray = this.tmpHits.toArray(new Hit[this.tmpHits.size()]); 60 | for(Hit hit : tmpArray){ 61 | hit = Dictionary.getSingleton().matchWithHit(context.getSegmentBuff(), context.getCursor() , hit); 62 | if(hit.isMatch()){ 63 | //输出当前的词 64 | Lexeme newLexeme = new Lexeme(context.getBufferOffset() , hit.getBegin() , context.getCursor() - hit.getBegin() + 1 , Lexeme.TYPE_CNWORD); 65 | context.addLexeme(newLexeme); 66 | 67 | if(!hit.isPrefix()){//不是词前缀,hit不需要继续匹配,移除 68 | this.tmpHits.remove(hit); 69 | } 70 | 71 | }else if(hit.isUnmatch()){ 72 | //hit不是词,移除 73 | this.tmpHits.remove(hit); 74 | } 75 | } 76 | } 77 | 78 | //********************************* 79 | //再对当前指针位置的字符进行单字匹配 80 | Hit singleCharHit = Dictionary.getSingleton().matchInMainDict(context.getSegmentBuff(), context.getCursor(), 1); 81 | if(singleCharHit.isMatch()){//首字成词 82 | //输出当前的词 83 | Lexeme newLexeme = new Lexeme(context.getBufferOffset() , context.getCursor() , 1 , Lexeme.TYPE_CNWORD); 84 | context.addLexeme(newLexeme); 85 | 86 | //同时也是词前缀 87 | if(singleCharHit.isPrefix()){ 88 | //前缀匹配则放入hit列表 89 | this.tmpHits.add(singleCharHit); 90 | } 91 | }else if(singleCharHit.isPrefix()){//首字为词前缀 92 | //前缀匹配则放入hit列表 93 | this.tmpHits.add(singleCharHit); 94 | } 95 | 96 | 97 | }else{ 98 | //遇到CHAR_USELESS字符 99 | //清空队列 100 | this.tmpHits.clear(); 101 | } 102 | 103 | //判断缓冲区是否已经读完 104 | if(context.isBufferConsumed()){ 105 | //清空队列 106 | this.tmpHits.clear(); 107 | } 108 | 109 | //判断是否锁定缓冲区 110 | if(this.tmpHits.size() == 0){ 111 | context.unlockBuffer(SEGMENTER_NAME); 112 | 113 | }else{ 114 | context.lockBuffer(SEGMENTER_NAME); 115 | } 116 | } 117 | 118 | /* (non-Javadoc) 119 | * @see org.wltea.analyzer.core.ISegmenter#reset() 120 | */ 121 | public void reset() { 122 | //清空队列 123 | this.tmpHits.clear(); 124 | } 125 | 126 | } 127 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/Favorites.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Date; 5 | import java.util.List; 6 | 7 | import weibo4j.http.Response; 8 | import weibo4j.org.json.JSONArray; 9 | import weibo4j.org.json.JSONException; 10 | import weibo4j.org.json.JSONObject; 11 | 12 | public class Favorites extends WeiboResponse implements java.io.Serializable{ 13 | 14 | private static final long serialVersionUID = 3355536191107298448L; 15 | private Date favoritedTime; //添加收藏的时间 16 | private Status status; //收藏的status 17 | private List tags; //收藏的tags 18 | private static int totalNumber; 19 | public Favorites(Response res) throws WeiboException{ 20 | super(res); 21 | JSONObject json = null; 22 | try { 23 | json = res.asJSONObject(); 24 | favoritedTime = parseDate(json.getString("favorited_time"), "EEE MMM dd HH:mm:ss z yyyy"); 25 | if(!json.isNull("status")){ 26 | status = new Status(json.getJSONObject("status")); 27 | } 28 | if(!json.isNull("tags")){ 29 | JSONArray list = json.getJSONArray("tags"); 30 | int size = list.length(); 31 | List tag = new ArrayList(size); 32 | for (int i = 0;i< size;i++){ 33 | tag.add(new FavoritesTag(list.getJSONObject(i))); 34 | } 35 | } 36 | } catch (JSONException je) { 37 | throw new WeiboException(je.getMessage() + ":" + json.toString(), je); 38 | } 39 | } 40 | Favorites(JSONObject json) throws WeiboException, JSONException{ 41 | favoritedTime = parseDate(json.getString("favorited_time"), "EEE MMM dd HH:mm:ss z yyyy"); 42 | if(!json.isNull("status")){ 43 | status = new Status(json.getJSONObject("status")); 44 | } 45 | if(!json.isNull("tags")){ 46 | JSONArray list = json.getJSONArray("tags"); 47 | int size = list.length(); 48 | tags = new ArrayList(size); 49 | for (int i = 0;i< size;i++){ 50 | tags.add(new FavoritesTag(list.getJSONObject(i))); 51 | } 52 | } 53 | 54 | } 55 | public static List constructFavorites(Response res) throws WeiboException{ 56 | try { 57 | JSONArray list = res.asJSONObject().getJSONArray("favorites"); 58 | int size = list.length(); 59 | List favorites = new ArrayList(size); 60 | for (int i = 0; i < size; i++) { 61 | favorites.add(new Favorites(list.getJSONObject(i))); 62 | } 63 | totalNumber =res.asJSONObject().getInt("total_number"); 64 | return favorites; 65 | } catch (JSONException jsone) { 66 | throw new WeiboException(jsone); 67 | } 68 | } 69 | 70 | public Status getStatus() { 71 | return status; 72 | } 73 | 74 | public void setStatus(Status status) { 75 | this.status = status; 76 | } 77 | 78 | public List getTags() { 79 | return tags; 80 | } 81 | 82 | public void setTags(List tags) { 83 | this.tags = tags; 84 | } 85 | 86 | public Date getFavoritedTime() { 87 | return favoritedTime; 88 | } 89 | 90 | public void setFavoritedTime(Date favoritedTime) { 91 | this.favoritedTime = favoritedTime; 92 | } 93 | 94 | @Override 95 | public int hashCode() { 96 | final int prime = 31; 97 | int result = 1; 98 | result = prime * result 99 | + ((favoritedTime == null) ? 0 : favoritedTime.hashCode()); 100 | return result; 101 | } 102 | @Override 103 | public boolean equals(Object obj) { 104 | if (this == obj) 105 | return true; 106 | if (obj == null) 107 | return false; 108 | if (getClass() != obj.getClass()) 109 | return false; 110 | Favorites other = (Favorites) obj; 111 | if (favoritedTime == null) { 112 | if (other.favoritedTime != null) 113 | return false; 114 | } else if (!favoritedTime.equals(other.favoritedTime)) 115 | return false; 116 | return true; 117 | } 118 | @Override 119 | public String toString() { 120 | return "Favorites [" + 121 | "favorited_time=" + favoritedTime + 122 | ", status=" + status.toString() + 123 | ", FavoritesTag=" + ((tags==null)?"null":tags.toString()) + 124 | ", total_number = "+totalNumber+ 125 | "]"; 126 | } 127 | 128 | } 129 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/MySSLSocketFactory.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | import java.io.IOException; 4 | import java.net.InetAddress; 5 | import java.net.InetSocketAddress; 6 | import java.net.Socket; 7 | import java.net.SocketAddress; 8 | import java.net.UnknownHostException; 9 | import java.security.KeyManagementException; 10 | import java.security.NoSuchAlgorithmException; 11 | import java.security.cert.CertificateException; 12 | import java.security.cert.X509Certificate; 13 | 14 | import javax.net.SocketFactory; 15 | import javax.net.ssl.SSLContext; 16 | import javax.net.ssl.TrustManager; 17 | import javax.net.ssl.X509TrustManager; 18 | 19 | import org.apache.commons.httpclient.ConnectTimeoutException; 20 | import org.apache.commons.httpclient.params.HttpConnectionParams; 21 | import org.apache.commons.httpclient.protocol.ProtocolSocketFactory; 22 | 23 | /** 24 | Provide a custom socket factory that implements org.apache.commons.httpclient.protocol.ProtocolSocketFactory interface. 25 | The socket factory is responsible for opening a socket to the target server using either the standard or a third party 26 | SSL library and performing any required initialization such as performing the connection handshake. Generally the initialization 27 | is performed automatically when the socket is created. 28 | @author sinaWeibo 29 | */ 30 | public class MySSLSocketFactory implements ProtocolSocketFactory { 31 | private SSLContext sslcontext = null; 32 | private SSLContext createSSLContext() { 33 | SSLContext sslcontext = null; 34 | try { 35 | sslcontext = SSLContext.getInstance("SSL"); 36 | sslcontext.init(null, 37 | new TrustManager[] { new TrustAnyTrustManager() }, 38 | new java.security.SecureRandom()); 39 | } catch (NoSuchAlgorithmException e) { 40 | e.printStackTrace(); 41 | } catch (KeyManagementException e) { 42 | e.printStackTrace(); 43 | } 44 | return sslcontext; 45 | } 46 | 47 | private SSLContext getSSLContext() { 48 | if (this.sslcontext == null) { 49 | this.sslcontext = createSSLContext(); 50 | } 51 | return this.sslcontext; 52 | } 53 | 54 | public Socket createSocket(Socket socket, String host, int port, 55 | boolean autoClose) throws IOException, UnknownHostException { 56 | return getSSLContext().getSocketFactory().createSocket(socket, host, 57 | port, autoClose); 58 | } 59 | 60 | public Socket createSocket(String host, int port) throws IOException, 61 | UnknownHostException { 62 | return getSSLContext().getSocketFactory().createSocket(host, port); 63 | } 64 | 65 | public Socket createSocket(String host, int port, InetAddress clientHost, 66 | int clientPort) throws IOException, UnknownHostException { 67 | return getSSLContext().getSocketFactory().createSocket(host, port, 68 | clientHost, clientPort); 69 | } 70 | 71 | public Socket createSocket(String host, int port, InetAddress localAddress, 72 | int localPort, HttpConnectionParams params) throws IOException, 73 | UnknownHostException, ConnectTimeoutException { 74 | if (params == null) { 75 | throw new IllegalArgumentException("Parameters may not be null"); 76 | } 77 | int timeout = params.getConnectionTimeout(); 78 | SocketFactory socketfactory = getSSLContext().getSocketFactory(); 79 | if (timeout == 0) { 80 | return socketfactory.createSocket(host, port, localAddress, 81 | localPort); 82 | } else { 83 | Socket socket = socketfactory.createSocket(); 84 | SocketAddress localaddr = new InetSocketAddress(localAddress, 85 | localPort); 86 | SocketAddress remoteaddr = new InetSocketAddress(host, port); 87 | socket.bind(localaddr); 88 | socket.connect(remoteaddr, timeout); 89 | return socket; 90 | } 91 | } 92 | 93 | private static class TrustAnyTrustManager implements X509TrustManager { 94 | public void checkClientTrusted(X509Certificate[] chain, String authType) 95 | throws CertificateException { 96 | } 97 | 98 | public void checkServerTrusted(X509Certificate[] chain, String authType) 99 | throws CertificateException { 100 | } 101 | 102 | public X509Certificate[] getAcceptedIssuers() { 103 | return new X509Certificate[] {}; 104 | } 105 | } 106 | } 107 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/Emotion.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.List; 5 | 6 | import weibo4j.http.Response; 7 | import weibo4j.org.json.JSONArray; 8 | import weibo4j.org.json.JSONException; 9 | import weibo4j.org.json.JSONObject; 10 | 11 | /** 12 | * @author SinaWeibo 13 | * 14 | */ 15 | public class Emotion extends WeiboResponse { 16 | private static final long serialVersionUID = -4096813631691846494L; 17 | private String phrase; // 表情使用的替代文字 18 | private String type; // 表情类型,image为普通图片表情,magic为魔法表情 19 | private String url; // 表情图片存放的位置 20 | private boolean hot; // 是否为热门表情 21 | private boolean common; // 是否是常用表情 22 | private String value; 23 | private String category; // 表情分类 24 | private String picid; 25 | private String icon; 26 | 27 | public Emotion(Response res) throws WeiboException { 28 | super(res); 29 | JSONObject json = res.asJSONObject(); 30 | try { 31 | phrase = json.getString("phrase"); 32 | type = json.getString("type"); 33 | url = json.getString("url"); 34 | hot = json.getBoolean("hot"); 35 | category = json.getString("category"); 36 | common = json.getBoolean("common"); 37 | value = json.getString("value"); 38 | picid = json.getString("picid"); 39 | icon = json.getString("icon"); 40 | } catch (JSONException je) { 41 | throw new WeiboException(je.getMessage() + ":" + json.toString(), 42 | je); 43 | } 44 | } 45 | 46 | public Emotion(JSONObject json) throws WeiboException { 47 | try { 48 | phrase = json.getString("phrase"); 49 | type = json.getString("type"); 50 | url = json.getString("url"); 51 | hot = json.getBoolean("hot"); 52 | category = json.getString("category"); 53 | common = json.getBoolean("common"); 54 | value = json.getString("value"); 55 | picid = json.getString("picid"); 56 | icon = json.getString("icon"); 57 | } catch (JSONException je) { 58 | throw new WeiboException(je.getMessage() + ":" + json.toString(), 59 | je); 60 | } 61 | } 62 | 63 | public static List constructEmotions(Response res) 64 | throws WeiboException { 65 | try { 66 | JSONArray list = res.asJSONArray(); 67 | int size = list.length(); 68 | List emotions = new ArrayList(size); 69 | for (int i = 0; i < size; i++) { 70 | emotions.add(new Emotion(list.getJSONObject(i))); 71 | } 72 | return emotions; 73 | } catch (JSONException jsone) { 74 | throw new WeiboException(jsone); 75 | } catch (WeiboException te) { 76 | throw te; 77 | } 78 | 79 | } 80 | 81 | public Emotion() { 82 | super(); 83 | } 84 | 85 | public String getPhrase() { 86 | return phrase; 87 | } 88 | 89 | public void setPhrase(String phrase) { 90 | this.phrase = phrase; 91 | } 92 | 93 | public String getType() { 94 | return type; 95 | } 96 | 97 | public void setType(String type) { 98 | this.type = type; 99 | } 100 | 101 | public String getUrl() { 102 | return url; 103 | } 104 | 105 | public void setUrl(String url) { 106 | this.url = url; 107 | } 108 | 109 | public String getCategory() { 110 | return category; 111 | } 112 | 113 | public void setCategory(String category) { 114 | this.category = category; 115 | } 116 | 117 | public boolean isHot() { 118 | return hot; 119 | } 120 | 121 | public void setHot(boolean hot) { 122 | this.hot = hot; 123 | } 124 | 125 | public boolean isCommon() { 126 | return common; 127 | } 128 | 129 | public void setCommon(boolean common) { 130 | this.common = common; 131 | } 132 | 133 | public String getValue() { 134 | return value; 135 | } 136 | 137 | public void setValue(String value) { 138 | this.value = value; 139 | } 140 | 141 | public String getPicid() { 142 | return picid; 143 | } 144 | 145 | public void setPicid(String picid) { 146 | this.picid = picid; 147 | } 148 | 149 | public String getIcon() { 150 | return icon; 151 | } 152 | 153 | public void setIcon(String icon) { 154 | this.icon = icon; 155 | } 156 | 157 | @Override 158 | public String toString() { 159 | return "Emotion [phrase=" + phrase + ", type=" + type + ", url=" + url 160 | + ", hot=" + hot + ", common=" + common + ", value=" + value 161 | + ", category=" + category + ", picid=" + picid + ", icon=" 162 | + icon + "]"; 163 | } 164 | 165 | } 166 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/http/BASE64Encoder.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007-2009, Yusuke Yamamoto 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Yusuke Yamamoto nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Yusuke Yamamoto ``AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Yusuke Yamamoto BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package weibo4j.http; 28 | /** 29 | * A utility class encodes byte array into String using Base64 encoding scheme. 30 | * @see weibo4j.http.HttpClient 31 | * @author Yusuke Yamamoto - yusuke at mac.com 32 | */ 33 | public class BASE64Encoder { 34 | private static final char last2byte = (char) Integer.parseInt("00000011", 2); 35 | private static final char last4byte = (char) Integer.parseInt("00001111", 2); 36 | private static final char last6byte = (char) Integer.parseInt("00111111", 2); 37 | private static final char lead6byte = (char) Integer.parseInt("11111100", 2); 38 | private static final char lead4byte = (char) Integer.parseInt("11110000", 2); 39 | private static final char lead2byte = (char) Integer.parseInt("11000000", 2); 40 | private static final char[] encodeTable = new char[]{'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z', 'a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '+', '/'}; 41 | 42 | public BASE64Encoder() { 43 | } 44 | 45 | public static String encode(byte[] from) { 46 | StringBuffer to = new StringBuffer((int) (from.length * 1.34) + 3); 47 | int num = 0; 48 | char currentByte = 0; 49 | for (int i = 0; i < from.length; i++) { 50 | num = num % 8; 51 | while (num < 8) { 52 | switch (num) { 53 | case 0: 54 | currentByte = (char) (from[i] & lead6byte); 55 | currentByte = (char) (currentByte >>> 2); 56 | break; 57 | case 2: 58 | currentByte = (char) (from[i] & last6byte); 59 | break; 60 | case 4: 61 | currentByte = (char) (from[i] & last4byte); 62 | currentByte = (char) (currentByte << 2); 63 | if ((i + 1) < from.length) { 64 | currentByte |= (from[i + 1] & lead2byte) >>> 6; 65 | } 66 | break; 67 | case 6: 68 | currentByte = (char) (from[i] & last2byte); 69 | currentByte = (char) (currentByte << 4); 70 | if ((i + 1) < from.length) { 71 | currentByte |= (from[i + 1] & lead4byte) >>> 4; 72 | } 73 | break; 74 | } 75 | to.append(encodeTable[currentByte]); 76 | num += 6; 77 | } 78 | } 79 | if (to.length() % 4 != 0) { 80 | for (int i = 4 - to.length() % 4; i > 0; i--) { 81 | to.append("="); 82 | } 83 | } 84 | return to.toString(); 85 | } 86 | } 87 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/Tag.java: -------------------------------------------------------------------------------- 1 | package weibo4j.model; 2 | 3 | import java.util.ArrayList; 4 | import java.util.Iterator; 5 | import java.util.List; 6 | import weibo4j.Weibo; 7 | import weibo4j.http.Response; 8 | import weibo4j.org.json.JSONArray; 9 | import weibo4j.org.json.JSONException; 10 | import weibo4j.org.json.JSONObject; 11 | 12 | /** 13 | * @author sinaWeibo 14 | * 15 | */ 16 | public class Tag extends WeiboResponse implements java.io.Serializable { 17 | 18 | private static final long serialVersionUID = 2177657076940291492L; 19 | 20 | private String id; //标签id 21 | 22 | private String value; //标签value 23 | 24 | private String weight; 25 | 26 | public Tag(JSONObject json) throws WeiboException, JSONException { 27 | if (!json.getString("id").isEmpty()) { 28 | id = json.getString("id"); 29 | } 30 | if(!json.getString("value").isEmpty()) { 31 | value = json.getString("value"); 32 | }else { 33 | Iterator keys = json.sortedKeys(); 34 | if (keys.hasNext()) { 35 | id = keys.next(); 36 | value = json.getString(id); 37 | } 38 | } 39 | weight= json.getString("weight"); 40 | } 41 | public Tag(JSONObject json , Weibo weibo) throws WeiboException,JSONException { 42 | System.out.println(json); 43 | id = json.getString("id"); 44 | value = json.getString("count"); 45 | weight= json.getString("weight"); 46 | } 47 | 48 | 49 | public static List constructTags(Response res) throws WeiboException { 50 | try { 51 | JSONArray list = res.asJSONArray(); 52 | int size = list.length(); 53 | List tags = new ArrayList(size); 54 | for (int i = 0; i < size; i++) { 55 | tags.add(new Tag(list.getJSONObject(i))); 56 | } 57 | return tags; 58 | } catch (JSONException jsone) { 59 | throw new WeiboException(jsone); 60 | } catch (WeiboException te) { 61 | throw te; 62 | } 63 | } 64 | public static TagWapper constructTagWapper(Response res){ 65 | try { 66 | JSONArray tags = res.asJSONArray(); 67 | List tagList = new ArrayList(); 68 | for(int i=0;i constructTag(Response res) throws WeiboException { 81 | try { 82 | JSONArray list = res.asJSONObject().getJSONArray("tags"); 83 | int size = list.length(); 84 | List tags = new ArrayList(size); 85 | for (int i = 0; i < size; i++) { 86 | tags.add(new FavoritesTag(list.getJSONObject(i))); 87 | } 88 | return tags; 89 | } catch (JSONException jsone) { 90 | throw new WeiboException(jsone); 91 | } catch (WeiboException te) { 92 | throw te; 93 | } 94 | } 95 | 96 | @Override 97 | public int hashCode() { 98 | final int prime = 31; 99 | int result = 1; 100 | result = prime * result + ((id == null) ? 0 : id.hashCode()); 101 | result = prime * result + ((value == null) ? 0 : value.hashCode()); 102 | return result; 103 | } 104 | 105 | @Override 106 | public boolean equals(Object obj) { 107 | if (this == obj) 108 | return true; 109 | if (obj == null) 110 | return false; 111 | if (getClass() != obj.getClass()) 112 | return false; 113 | Tag other = (Tag) obj; 114 | if (id == null) { 115 | if (other.id != null) 116 | return false; 117 | } else if (!id.equals(other.id)) 118 | return false; 119 | if (value == null) { 120 | if (other.value != null) 121 | return false; 122 | } else if (!value.equals(other.value)) 123 | return false; 124 | return true; 125 | } 126 | 127 | /** 128 | * @return the id 129 | */ 130 | public String getId() { 131 | return id; 132 | } 133 | 134 | public String getWeight() { 135 | return weight; 136 | } 137 | public void setWeight(String weight) { 138 | this.weight = weight; 139 | } 140 | public void setId(String id) { 141 | this.id = id; 142 | } 143 | public void setValue(String value) { 144 | this.value = value; 145 | } 146 | /** 147 | * @return the value 148 | */ 149 | public String getValue() { 150 | return value; 151 | } 152 | @Override 153 | public String toString() { 154 | return "Tag [id=" + id + ", value=" + value + ", weight=" + weight 155 | + "]"; 156 | } 157 | 158 | } 159 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/model/IDs.java: -------------------------------------------------------------------------------- 1 | /* 2 | Copyright (c) 2007-2009, Yusuke Yamamoto 3 | All rights reserved. 4 | 5 | Redistribution and use in source and binary forms, with or without 6 | modification, are permitted provided that the following conditions are met: 7 | * Redistributions of source code must retain the above copyright 8 | notice, this list of conditions and the following disclaimer. 9 | * Redistributions in binary form must reproduce the above copyright 10 | notice, this list of conditions and the following disclaimer in the 11 | documentation and/or other materials provided with the distribution. 12 | * Neither the name of the Yusuke Yamamoto nor the 13 | names of its contributors may be used to endorse or promote products 14 | derived from this software without specific prior written permission. 15 | 16 | THIS SOFTWARE IS PROVIDED BY Yusuke Yamamoto ``AS IS'' AND ANY 17 | EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED 18 | WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE 19 | DISCLAIMED. IN NO EVENT SHALL Yusuke Yamamoto BE LIABLE FOR ANY 20 | DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES 21 | (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; 22 | LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND 23 | ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 24 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS 25 | SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 26 | */ 27 | package weibo4j.model; 28 | 29 | import java.util.Arrays; 30 | 31 | import weibo4j.Weibo; 32 | import weibo4j.http.Response; 33 | import weibo4j.org.json.JSONArray; 34 | import weibo4j.org.json.JSONException; 35 | import weibo4j.org.json.JSONObject; 36 | 37 | /** 38 | * A data class representing array of numeric IDs. 39 | * 40 | * @author Yusuke Yamamoto - yusuke at mac.com 41 | * @editor SinaWeibo 42 | */ 43 | public class IDs extends WeiboResponse { 44 | private long[] ids; //ids 45 | private long previousCursor; //当前cursor 46 | private long nextCursor; //下一个cursor 47 | private static final long serialVersionUID = -6585026560164704953L; 48 | /*package*/ IDs(Response res,Weibo w) throws WeiboException { 49 | super(res); 50 | if("[]\n".equals(res.asString())){ 51 | previousCursor=0; 52 | nextCursor=0; 53 | ids= new long[0]; 54 | return; 55 | } 56 | JSONObject json= res.asJSONObject(); 57 | try { 58 | previousCursor = json.getLong("previous_cursor"); 59 | nextCursor = json.getLong("next_cursor"); 60 | 61 | if(!json.isNull("ids")){ 62 | JSONArray jsona= json.getJSONArray("ids"); 63 | int size=jsona.length(); 64 | ids =new long[ size]; 65 | for (int i = 0; i < size; i++) { 66 | ids[i] =jsona.getLong(i); 67 | } 68 | } 69 | 70 | } catch (JSONException jsone) { 71 | throw new WeiboException(jsone); 72 | } 73 | 74 | } 75 | 76 | public long[] getIDs() { 77 | return ids; 78 | } 79 | 80 | /** 81 | * 82 | * @since weibo4j-V2 1.0.0 83 | */ 84 | public boolean hasPrevious(){ 85 | return 0 != previousCursor; 86 | } 87 | 88 | /** 89 | * 90 | * @since weibo4j-V2 1.0.0 91 | */ 92 | public long getPreviousCursor() { 93 | return previousCursor; 94 | } 95 | 96 | /** 97 | * 98 | * @since weibo4j-V2 1.0.0 99 | */ 100 | public boolean hasNext(){ 101 | return 0 != nextCursor; 102 | } 103 | 104 | /** 105 | * 106 | * @since weibo4j-V2 1.0.0 107 | */ 108 | public long getNextCursor() { 109 | return nextCursor; 110 | } 111 | 112 | @Override 113 | public boolean equals(Object o) { 114 | if (this == o) return true; 115 | if (!(o instanceof IDs)) return false; 116 | 117 | IDs iDs = (IDs) o; 118 | 119 | if (!Arrays.equals(ids, iDs.ids)) return false; 120 | 121 | return true; 122 | } 123 | 124 | @Override 125 | public int hashCode() { 126 | return ids != null ? Arrays.hashCode(ids) : 0; 127 | } 128 | 129 | @Override 130 | public String toString() { 131 | return "IDs{" + 132 | "ids=" + ids + 133 | ", previousCursor=" + previousCursor + 134 | ", nextCursor=" + nextCursor + 135 | '}'; 136 | } 137 | } -------------------------------------------------------------------------------- /WeiboAnalyzer/src/org/wltea/analyzer/core/IKArbitrator.java: -------------------------------------------------------------------------------- 1 | /** 2 | * IK 中文分词 版本 5.0 3 | * IK Analyzer release 5.0 4 | * 5 | * Licensed to the Apache Software Foundation (ASF) under one or more 6 | * contributor license agreements. See the NOTICE file distributed with 7 | * this work for additional information regarding copyright ownership. 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 9 | * (the "License"); you may not use this file except in compliance with 10 | * the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * 源代码由林良益(linliangyi2005@gmail.com)提供 21 | * 版权声明 2012,乌龙茶工作室 22 | * provided by Linliangyi and copyright 2012 by Oolong studio 23 | * 24 | */ 25 | package org.wltea.analyzer.core; 26 | 27 | import java.util.Stack; 28 | import java.util.TreeSet; 29 | 30 | /** 31 | * IK分词歧义裁决器 32 | */ 33 | class IKArbitrator { 34 | 35 | IKArbitrator(){ 36 | 37 | } 38 | 39 | /** 40 | * 分词歧义处理 41 | * @param orgLexemes 42 | * @param useSmart 43 | */ 44 | void process(AnalyzeContext context , boolean useSmart){ 45 | QuickSortSet orgLexemes = context.getOrgLexemes(); 46 | Lexeme orgLexeme = orgLexemes.pollFirst(); 47 | 48 | LexemePath crossPath = new LexemePath(); 49 | while(orgLexeme != null){ 50 | if(!crossPath.addCrossLexeme(orgLexeme)){ 51 | //找到与crossPath不相交的下一个crossPath 52 | if(crossPath.size() == 1 || !useSmart){ 53 | //crossPath没有歧义 或者 不做歧义处理 54 | //直接输出当前crossPath 55 | context.addLexemePath(crossPath); 56 | }else{ 57 | //对当前的crossPath进行歧义处理 58 | QuickSortSet.Cell headCell = crossPath.getHead(); 59 | LexemePath judgeResult = this.judge(headCell, crossPath.getPathLength()); 60 | //输出歧义处理结果judgeResult 61 | context.addLexemePath(judgeResult); 62 | } 63 | 64 | //把orgLexeme加入新的crossPath中 65 | crossPath = new LexemePath(); 66 | crossPath.addCrossLexeme(orgLexeme); 67 | } 68 | orgLexeme = orgLexemes.pollFirst(); 69 | } 70 | 71 | 72 | //处理最后的path 73 | if(crossPath.size() == 1 || !useSmart){ 74 | //crossPath没有歧义 或者 不做歧义处理 75 | //直接输出当前crossPath 76 | context.addLexemePath(crossPath); 77 | }else{ 78 | //对当前的crossPath进行歧义处理 79 | QuickSortSet.Cell headCell = crossPath.getHead(); 80 | LexemePath judgeResult = this.judge(headCell, crossPath.getPathLength()); 81 | //输出歧义处理结果judgeResult 82 | context.addLexemePath(judgeResult); 83 | } 84 | } 85 | 86 | /** 87 | * 歧义识别 88 | * @param lexemeCell 歧义路径链表头 89 | * @param fullTextLength 歧义路径文本长度 90 | * @param option 候选结果路径 91 | * @return 92 | */ 93 | private LexemePath judge(QuickSortSet.Cell lexemeCell , int fullTextLength){ 94 | //候选路径集合 95 | TreeSet pathOptions = new TreeSet(); 96 | //候选结果路径 97 | LexemePath option = new LexemePath(); 98 | 99 | //对crossPath进行一次遍历,同时返回本次遍历中有冲突的Lexeme栈 100 | Stack lexemeStack = this.forwardPath(lexemeCell , option); 101 | 102 | //当前词元链并非最理想的,加入候选路径集合 103 | pathOptions.add(option.copy()); 104 | 105 | //存在歧义词,处理 106 | QuickSortSet.Cell c = null; 107 | while(!lexemeStack.isEmpty()){ 108 | c = lexemeStack.pop(); 109 | //回滚词元链 110 | this.backPath(c.getLexeme() , option); 111 | //从歧义词位置开始,递归,生成可选方案 112 | this.forwardPath(c , option); 113 | pathOptions.add(option.copy()); 114 | } 115 | 116 | //返回集合中的最优方案 117 | return pathOptions.first(); 118 | 119 | } 120 | 121 | /** 122 | * 向前遍历,添加词元,构造一个无歧义词元组合 123 | * @param LexemePath path 124 | * @return 125 | */ 126 | private Stack forwardPath(QuickSortSet.Cell lexemeCell , LexemePath option){ 127 | //发生冲突的Lexeme栈 128 | Stack conflictStack = new Stack(); 129 | QuickSortSet.Cell c = lexemeCell; 130 | //迭代遍历Lexeme链表 131 | while(c != null && c.getLexeme() != null){ 132 | if(!option.addNotCrossLexeme(c.getLexeme())){ 133 | //词元交叉,添加失败则加入lexemeStack栈 134 | conflictStack.push(c); 135 | } 136 | c = c.getNext(); 137 | } 138 | return conflictStack; 139 | } 140 | 141 | /** 142 | * 回滚词元链,直到它能够接受指定的词元 143 | * @param lexeme 144 | * @param l 145 | */ 146 | private void backPath(Lexeme l , LexemePath option){ 147 | while(option.checkCross(l)){ 148 | option.removeTail(); 149 | } 150 | 151 | } 152 | 153 | } 154 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/weibo4j/PublicService.java: -------------------------------------------------------------------------------- 1 | package weibo4j; 2 | 3 | import weibo4j.model.PostParameter; 4 | import weibo4j.model.WeiboException; 5 | import weibo4j.org.json.JSONArray; 6 | import weibo4j.org.json.JSONObject; 7 | import weibo4j.util.WeiboConfig; 8 | 9 | public class PublicService extends Weibo{ 10 | 11 | private static final long serialVersionUID = 1L; 12 | 13 | /** 14 | * 通过地址编码获取地址名称 15 | * 16 | * 17 | */ 18 | public JSONArray getLocationByCode (String codes) throws WeiboException { 19 | return client.get(WeiboConfig.getValue("baseURL") + "common/code_to_location.json",new PostParameter[] { 20 | new PostParameter("codes", codes) 21 | }).asJSONArray(); 22 | } 23 | /** 24 | * 获取省份列表 25 | * 26 | * 27 | */ 28 | public JSONArray provinceList (String country) throws WeiboException { 29 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_province.json",new PostParameter[] { 30 | new PostParameter("country", country) 31 | }).asJSONArray(); 32 | } 33 | 34 | public JSONArray provinceListOfCapital (String country,String capital) throws WeiboException { 35 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_province.json",new PostParameter[] { 36 | new PostParameter("country", country), 37 | new PostParameter("capital", capital) 38 | }).asJSONArray(); 39 | } 40 | 41 | public JSONArray provinceList (String country,String language) throws WeiboException { 42 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_province.json",new PostParameter[] { 43 | new PostParameter("country", country), 44 | new PostParameter("language", language) 45 | }).asJSONArray(); 46 | } 47 | 48 | public JSONArray provinceList (String country,String capital,String language) throws WeiboException { 49 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_province.json",new PostParameter[] { 50 | new PostParameter("country", country), 51 | new PostParameter("capital", capital), 52 | new PostParameter("language", language) 53 | }).asJSONArray(); 54 | } 55 | /** 56 | * 获取城市列表 57 | * 58 | * 59 | */ 60 | public JSONArray cityList (String province) throws WeiboException { 61 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_city.json",new PostParameter[] { 62 | new PostParameter("province", province) 63 | }).asJSONArray(); 64 | } 65 | 66 | public JSONArray cityListOfCapital (String province,String capital) throws WeiboException { 67 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_city.json",new PostParameter[] { 68 | new PostParameter("province", province), 69 | new PostParameter("capital", capital) 70 | }).asJSONArray(); 71 | } 72 | 73 | public JSONArray cityList (String province,String language) throws WeiboException { 74 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_city.json",new PostParameter[] { 75 | new PostParameter("province", province), 76 | new PostParameter("language", language) 77 | }).asJSONArray(); 78 | } 79 | 80 | public JSONArray cityList (String province,String capital,String language) throws WeiboException { 81 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_city.json",new PostParameter[] { 82 | new PostParameter("province", province), 83 | new PostParameter("capital", capital), 84 | new PostParameter("language", language) 85 | }).asJSONArray(); 86 | } 87 | /** 88 | * 获取国家列表 89 | * 90 | * 91 | */ 92 | public JSONArray countryList () throws WeiboException { 93 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_country.json").asJSONArray(); 94 | } 95 | 96 | public JSONArray countryListOfCapital (String capital) throws WeiboException { 97 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_country.json",new PostParameter[] { 98 | new PostParameter("capital", capital) 99 | }).asJSONArray(); 100 | } 101 | 102 | public JSONArray countryList (String language) throws WeiboException { 103 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_country.json",new PostParameter[] { 104 | new PostParameter("language", language) 105 | }).asJSONArray(); 106 | } 107 | 108 | public JSONArray countryList (String capital,String language) throws WeiboException { 109 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_country.json",new PostParameter[] { 110 | new PostParameter("capital", capital), 111 | new PostParameter("language", language) 112 | }).asJSONArray(); 113 | } 114 | 115 | /** 116 | * 获取时区配置表 117 | * 118 | */ 119 | public JSONObject getTomeZone () throws WeiboException { 120 | return client.get(WeiboConfig.getValue("baseURL") + "common/get_timezone.json").asJSONObject(); 121 | } 122 | 123 | } 124 | -------------------------------------------------------------------------------- /WeiboAnalyzer/src/org/wltea/analyzer/core/IKSegmenter.java: -------------------------------------------------------------------------------- 1 | /** 2 | * IK 中文分词 版本 5.0 3 | * IK Analyzer release 5.0 4 | * 5 | * Licensed to the Apache Software Foundation (ASF) under one or more 6 | * contributor license agreements. See the NOTICE file distributed with 7 | * this work for additional information regarding copyright ownership. 8 | * The ASF licenses this file to You under the Apache License, Version 2.0 9 | * (the "License"); you may not use this file except in compliance with 10 | * the License. You may obtain a copy of the License at 11 | * 12 | * http://www.apache.org/licenses/LICENSE-2.0 13 | * 14 | * Unless required by applicable law or agreed to in writing, software 15 | * distributed under the License is distributed on an "AS IS" BASIS, 16 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 17 | * See the License for the specific language governing permissions and 18 | * limitations under the License. 19 | * 20 | * 源代码由林良益(linliangyi2005@gmail.com)提供 21 | * 版权声明 2012,乌龙茶工作室 22 | * provided by Linliangyi and copyright 2012 by Oolong studio 23 | */ 24 | package org.wltea.analyzer.core; 25 | 26 | import java.io.IOException; 27 | import java.io.Reader; 28 | import java.util.ArrayList; 29 | import java.util.List; 30 | 31 | import org.wltea.analyzer.cfg.Configuration; 32 | import org.wltea.analyzer.cfg.DefaultConfig; 33 | import org.wltea.analyzer.dic.Dictionary; 34 | 35 | /** 36 | * IK分词器主类 37 | * 38 | */ 39 | public final class IKSegmenter { 40 | 41 | //字符窜reader 42 | private Reader input; 43 | //分词器配置项 44 | private Configuration cfg; 45 | //分词器上下文 46 | private AnalyzeContext context; 47 | //分词处理器列表 48 | private List segmenters; 49 | //分词歧义裁决器 50 | private IKArbitrator arbitrator; 51 | 52 | 53 | /** 54 | * IK分词器构造函数 55 | * @param input 56 | * @param useSmart 为true,使用智能分词策略 57 | * 58 | * 非智能分词:细粒度输出所有可能的切分结果 59 | * 智能分词: 合并数词和量词,对分词结果进行歧义判断 60 | */ 61 | public IKSegmenter(Reader input , boolean useSmart){ 62 | this.input = input; 63 | this.cfg = DefaultConfig.getInstance(); 64 | this.cfg.setUseSmart(useSmart); 65 | this.init(); 66 | } 67 | 68 | /** 69 | * IK分词器构造函数 70 | * @param input 71 | * @param cfg 使用自定义的Configuration构造分词器 72 | * 73 | */ 74 | public IKSegmenter(Reader input , Configuration cfg){ 75 | this.input = input; 76 | this.cfg = cfg; 77 | this.init(); 78 | } 79 | 80 | /** 81 | * 初始化 82 | */ 83 | private void init(){ 84 | //初始化词典单例 85 | Dictionary.initial(this.cfg); 86 | //初始化分词上下文 87 | this.context = new AnalyzeContext(this.cfg); 88 | //加载子分词器 89 | this.segmenters = this.loadSegmenters(); 90 | //加载歧义裁决器 91 | this.arbitrator = new IKArbitrator(); 92 | } 93 | 94 | /** 95 | * 初始化词典,加载子分词器实现 96 | * @return List 97 | */ 98 | private List loadSegmenters(){ 99 | List segmenters = new ArrayList(4); 100 | //处理字母的子分词器 101 | segmenters.add(new LetterSegmenter()); 102 | //处理中文数量词的子分词器 103 | segmenters.add(new CN_QuantifierSegmenter()); 104 | //处理中文词的子分词器 105 | segmenters.add(new CJKSegmenter()); 106 | return segmenters; 107 | } 108 | 109 | /** 110 | * 分词,获取下一个词元 111 | * @return Lexeme 词元对象 112 | * @throws IOException 113 | */ 114 | public synchronized Lexeme next()throws IOException{ 115 | Lexeme l = null; 116 | while((l = context.getNextLexeme()) == null ){ 117 | /* 118 | * 从reader中读取数据,填充buffer 119 | * 如果reader是分次读入buffer的,那么buffer要 进行移位处理 120 | * 移位处理上次读入的但未处理的数据 121 | */ 122 | int available = context.fillBuffer(this.input); 123 | if(available <= 0){ 124 | //reader已经读完 125 | context.reset(); 126 | return null; 127 | 128 | }else{ 129 | //初始化指针 130 | context.initCursor(); 131 | do{ 132 | //遍历子分词器 133 | for(ISegmenter segmenter : segmenters){ 134 | segmenter.analyze(context); 135 | } 136 | //字符缓冲区接近读完,需要读入新的字符 137 | if(context.needRefillBuffer()){ 138 | break; 139 | } 140 | //向前移动指针 141 | }while(context.moveCursor()); 142 | //重置子分词器,为下轮循环进行初始化 143 | for(ISegmenter segmenter : segmenters){ 144 | segmenter.reset(); 145 | } 146 | } 147 | //对分词进行歧义处理 148 | this.arbitrator.process(context, this.cfg.useSmart()); 149 | //将分词结果输出到结果集,并处理未切分的单个CJK字符 150 | context.outputToResult(); 151 | //记录本次分词的缓冲区位移 152 | context.markBufferOffset(); 153 | } 154 | return l; 155 | } 156 | 157 | /** 158 | * 重置分词器到初始状态 159 | * @param input 160 | */ 161 | public synchronized void reset(Reader input) { 162 | this.input = input; 163 | context.reset(); 164 | for(ISegmenter segmenter : segmenters){ 165 | segmenter.reset(); 166 | } 167 | } 168 | } 169 | --------------------------------------------------------------------------------