Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
myguguang
elasticsearch-analysis-ik
提交
f9977456
E
elasticsearch-analysis-ik
项目概览
myguguang
/
elasticsearch-analysis-ik
与 Fork 源项目一致
从无法访问的项目Fork
通知
5
Star
0
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
E
elasticsearch-analysis-ik
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
提交
Issue看板
前往新版Gitcode,体验更适合开发者的 AI 搜索 >>
提交
f9977456
编写于
1月 10, 2016
作者:
weixin_43283383
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
move config files stay with plugin
上级
5b95ceb2
变更
5
隐藏空白更改
内联
并排
Showing
5 changed file
with
40 addition
and
34 deletion
+40
-34
pom.xml
pom.xml
+2
-2
src/main/assemblies/plugin.xml
src/main/assemblies/plugin.xml
+7
-1
src/main/java/org/elasticsearch/plugin/analysis/ik/AnalysisIkPlugin.java
...rg/elasticsearch/plugin/analysis/ik/AnalysisIkPlugin.java
+0
-8
src/main/java/org/wltea/analyzer/cfg/Configuration.java
src/main/java/org/wltea/analyzer/cfg/Configuration.java
+13
-7
src/main/java/org/wltea/analyzer/dic/Dictionary.java
src/main/java/org/wltea/analyzer/dic/Dictionary.java
+18
-16
未找到文件。
pom.xml
浏览文件 @
f9977456
...
...
@@ -6,10 +6,10 @@
<modelVersion>
4.0.0
</modelVersion>
<groupId>
org.elasticsearch
</groupId>
<artifactId>
elasticsearch-analysis-ik
</artifactId>
<version>
1.
6.2
</version>
<version>
1.
7.0
</version>
<packaging>
jar
</packaging>
<description>
IK Analyzer for ElasticSearch
</description>
<inceptionYear>
20
09
</inceptionYear>
<inceptionYear>
20
11
</inceptionYear>
<properties>
<elasticsearch.version>
2.1.1
</elasticsearch.version>
...
...
src/main/assemblies/plugin.xml
浏览文件 @
f9977456
<?xml version="1.0"?>
<assembly>
<id></id>
<formats>
<format>
zip
</format>
</formats>
<includeBaseDirectory>
false
</includeBaseDirectory>
<fileSets>
<fileSet>
<directory>
${project.basedir}/config
</directory>
<outputDirectory>
/config
</outputDirectory>
</fileSet>
</fileSets>
<files>
<file>
<source>
${project.basedir}/src/main/resources/plugin-descriptor.properties
</source>
...
...
src/main/java/org/elasticsearch/plugin/analysis/ik/AnalysisIkPlugin.java
浏览文件 @
f9977456
...
...
@@ -23,11 +23,6 @@ import static java.rmi.Naming.bind;
public
class
AnalysisIkPlugin
extends
Plugin
{
private
final
Settings
settings
;
@Inject
public
AnalysisIkPlugin
(
Settings
settings
){
this
.
settings
=
settings
;
}
@Override
public
String
name
()
{
return
"analysis-ik"
;
...
...
@@ -43,7 +38,4 @@ public class AnalysisIkPlugin extends Plugin {
return
Collections
.<
Module
>
singletonList
(
new
IKIndicesAnalysisModule
());
}
// public void onModule(AnalysisModule module) {
// module.addProcessor(new IkAnalysisBinderProcessor());
// }
}
src/main/java/org/wltea/analyzer/cfg/Configuration.java
浏览文件 @
f9977456
...
...
@@ -4,11 +4,15 @@
package
org.wltea.analyzer.cfg
;
import
org.elasticsearch.common.inject.Inject
;
import
org.elasticsearch.common.io.PathUtils
;
import
org.elasticsearch.common.logging.ESLogger
;
import
org.elasticsearch.common.logging.Loggers
;
import
org.elasticsearch.env.Environment
;
import
org.elasticsearch.plugin.analysis.ik.AnalysisIkPlugin
;
import
java.io.*
;
import
java.net.URL
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.InvalidPropertiesFormatException
;
import
java.util.List
;
...
...
@@ -31,12 +35,12 @@ public class Configuration {
environment
=
env
;
File
fileConfig
=
new
File
(
environment
.
configFile
().
toFile
(),
FILE_NAME
);
Path
fileConfig
=
PathUtils
.
get
(
getDictRoot
(),
FILE_NAME
);
InputStream
input
=
null
;
try
{
input
=
new
FileInputStream
(
fileConfig
);
input
=
new
FileInputStream
(
fileConfig
.
toFile
()
);
}
catch
(
FileNotFoundException
e
)
{
logger
.
error
(
"ik-analyzer"
,
e
);
}
...
...
@@ -60,7 +64,7 @@ public class Configuration {
if
(
filePaths
!=
null
){
for
(
String
filePath
:
filePaths
){
if
(
filePath
!=
null
&&
!
""
.
equals
(
filePath
.
trim
())){
File
file
=
new
File
(
"ik"
,
filePath
.
trim
());
Path
file
=
PathUtils
.
get
(
"ik"
,
filePath
.
trim
());
extDictFiles
.
add
(
file
.
toString
());
}
...
...
@@ -97,7 +101,7 @@ public class Configuration {
if
(
filePaths
!=
null
){
for
(
String
filePath
:
filePaths
){
if
(
filePath
!=
null
&&
!
""
.
equals
(
filePath
.
trim
())){
File
file
=
new
File
(
"ik"
,
filePath
.
trim
());
Path
file
=
PathUtils
.
get
(
"ik"
,
filePath
.
trim
());
extStopWordDictFiles
.
add
(
file
.
toString
());
}
...
...
@@ -121,11 +125,13 @@ public class Configuration {
}
}
}
}
}
return
remoteExtStopWordDictFiles
;
}
public
File
getDictRoot
()
{
return
environment
.
configFile
().
toFile
();
public
String
getDictRoot
()
{
return
PathUtils
.
get
(
new
File
(
AnalysisIkPlugin
.
class
.
getProtectionDomain
().
getCodeSource
().
getLocation
().
getPath
()).
getParent
(),
"config"
)
.
toAbsolutePath
().
toString
();
}
}
src/main/java/org/wltea/analyzer/dic/Dictionary.java
浏览文件 @
f9977456
...
...
@@ -32,6 +32,7 @@ import java.io.FileNotFoundException;
import
java.io.IOException
;
import
java.io.InputStream
;
import
java.io.InputStreamReader
;
import
java.nio.file.Path
;
import
java.util.ArrayList
;
import
java.util.Collection
;
import
java.util.List
;
...
...
@@ -45,6 +46,7 @@ import org.apache.http.client.methods.CloseableHttpResponse;
import
org.apache.http.client.methods.HttpGet
;
import
org.apache.http.impl.client.CloseableHttpClient
;
import
org.apache.http.impl.client.HttpClients
;
import
org.elasticsearch.common.io.PathUtils
;
import
org.elasticsearch.common.logging.ESLogger
;
import
org.elasticsearch.common.logging.Loggers
;
import
org.wltea.analyzer.cfg.Configuration
;
...
...
@@ -220,11 +222,11 @@ public class Dictionary {
_MainDict
=
new
DictSegment
((
char
)
0
);
//读取主词典文件
File
file
=
new
File
(
configuration
.
getDictRoot
(),
Dictionary
.
PATH_DIC_MAIN
);
Path
file
=
PathUtils
.
get
(
configuration
.
getDictRoot
(),
Dictionary
.
PATH_DIC_MAIN
);
InputStream
is
=
null
;
try
{
is
=
new
FileInputStream
(
file
);
is
=
new
FileInputStream
(
file
.
toFile
()
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -269,9 +271,9 @@ public class Dictionary {
for
(
String
extDictName
:
extDictFiles
){
//读取扩展词典文件
logger
.
info
(
"[Dict Loading]"
+
extDictName
);
File
file
=
new
File
(
configuration
.
getDictRoot
(),
extDictName
);
Path
file
=
PathUtils
.
get
(
configuration
.
getDictRoot
(),
extDictName
);
try
{
is
=
new
FileInputStream
(
file
);
is
=
new
FileInputStream
(
file
.
toFile
()
);
}
catch
(
FileNotFoundException
e
)
{
logger
.
error
(
"ik-analyzer"
,
e
);
}
...
...
@@ -385,11 +387,11 @@ public class Dictionary {
_StopWords
=
new
DictSegment
((
char
)
0
);
//读取主词典文件
File
file
=
new
File
(
configuration
.
getDictRoot
(),
Dictionary
.
PATH_DIC_STOP
);
Path
file
=
PathUtils
.
get
(
configuration
.
getDictRoot
(),
Dictionary
.
PATH_DIC_STOP
);
InputStream
is
=
null
;
try
{
is
=
new
FileInputStream
(
file
);
is
=
new
FileInputStream
(
file
.
toFile
()
);
}
catch
(
FileNotFoundException
e
)
{
e
.
printStackTrace
();
}
...
...
@@ -427,9 +429,9 @@ public class Dictionary {
logger
.
info
(
"[Dict Loading]"
+
extStopWordDictName
);
//读取扩展词典文件
file
=
new
File
(
configuration
.
getDictRoot
(),
extStopWordDictName
);
file
=
PathUtils
.
get
(
configuration
.
getDictRoot
(),
extStopWordDictName
);
try
{
is
=
new
FileInputStream
(
file
);
is
=
new
FileInputStream
(
file
.
toFile
()
);
}
catch
(
FileNotFoundException
e
)
{
logger
.
error
(
"ik-analyzer"
,
e
);
}
...
...
@@ -493,10 +495,10 @@ public class Dictionary {
//建立一个量词典实例
_QuantifierDict
=
new
DictSegment
((
char
)
0
);
//读取量词词典文件
File
file
=
new
File
(
configuration
.
getDictRoot
(),
Dictionary
.
PATH_DIC_QUANTIFIER
);
Path
file
=
PathUtils
.
get
(
configuration
.
getDictRoot
(),
Dictionary
.
PATH_DIC_QUANTIFIER
);
InputStream
is
=
null
;
try
{
is
=
new
FileInputStream
(
file
);
is
=
new
FileInputStream
(
file
.
toFile
()
);
}
catch
(
FileNotFoundException
e
)
{
logger
.
error
(
"ik-analyzer"
,
e
);
}
...
...
@@ -529,10 +531,10 @@ public class Dictionary {
private
void
loadSurnameDict
(){
_SurnameDict
=
new
DictSegment
((
char
)
0
);
File
file
=
new
File
(
configuration
.
getDictRoot
(),
Dictionary
.
PATH_DIC_SURNAME
);
Path
file
=
PathUtils
.
get
(
configuration
.
getDictRoot
(),
Dictionary
.
PATH_DIC_SURNAME
);
InputStream
is
=
null
;
try
{
is
=
new
FileInputStream
(
file
);
is
=
new
FileInputStream
(
file
.
toFile
()
);
}
catch
(
FileNotFoundException
e
)
{
logger
.
error
(
"ik-analyzer"
,
e
);
}
...
...
@@ -566,10 +568,10 @@ public class Dictionary {
private
void
loadSuffixDict
(){
_SuffixDict
=
new
DictSegment
((
char
)
0
);
File
file
=
new
File
(
configuration
.
getDictRoot
(),
Dictionary
.
PATH_DIC_SUFFIX
);
Path
file
=
PathUtils
.
get
(
configuration
.
getDictRoot
(),
Dictionary
.
PATH_DIC_SUFFIX
);
InputStream
is
=
null
;
try
{
is
=
new
FileInputStream
(
file
);
is
=
new
FileInputStream
(
file
.
toFile
()
);
}
catch
(
FileNotFoundException
e
)
{
logger
.
error
(
"ik-analyzer"
,
e
);
}
...
...
@@ -602,10 +604,10 @@ public class Dictionary {
private
void
loadPrepDict
(){
_PrepDict
=
new
DictSegment
((
char
)
0
);
File
file
=
new
File
(
configuration
.
getDictRoot
(),
Dictionary
.
PATH_DIC_PREP
);
Path
file
=
PathUtils
.
get
(
configuration
.
getDictRoot
(),
Dictionary
.
PATH_DIC_PREP
);
InputStream
is
=
null
;
try
{
is
=
new
FileInputStream
(
file
);
is
=
new
FileInputStream
(
file
.
toFile
()
);
}
catch
(
FileNotFoundException
e
)
{
logger
.
error
(
"ik-analyzer"
,
e
);
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录