Skip to content
体验新版
项目
组织
正在加载...
登录
切换导航
打开侧边栏
ghsby
o2oa
提交
df44e448
o2oa
项目概览
ghsby
/
o2oa
落后 Fork 源项目 2880 个版本
Fork自
浙江兰德纵横网络技术股份有限公司 / o2oa
通知
1
Star
1
Fork
0
代码
文件
提交
分支
Tags
贡献者
分支图
Diff
Issue
0
列表
看板
标记
里程碑
合并请求
0
DevOps
流水线
流水线任务
计划
Wiki
0
Wiki
分析
仓库
DevOps
项目成员
Pages
o2oa
项目概览
项目概览
详情
发布
仓库
仓库
文件
提交
分支
标签
贡献者
分支图
比较
Issue
0
Issue
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
Pages
DevOps
DevOps
流水线
流水线任务
计划
分析
分析
仓库分析
DevOps
Wiki
0
Wiki
成员
成员
收起侧边栏
关闭侧边栏
动态
分支图
创建新Issue
流水线任务
提交
Issue看板
体验新版 GitCode,发现更多精彩内容 >>
提交
df44e448
编写于
7月 06, 2021
作者:
Z
zhourui
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
增加pickPersonWithName设置
上级
1e49e430
变更
3
隐藏空白更改
内联
并排
Showing
3 changed file
with
169 addition
and
4 deletion
+169
-4
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Organization.java
...ain/java/com/x/base/core/project/config/Organization.java
+10
-1
o2server/x_base_core_project/src/main/java/com/x/base/core/project/nlp/NaturalLanguageProcessing.java
...om/x/base/core/project/nlp/NaturalLanguageProcessing.java
+154
-0
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/PersonFactory.java
.../organization/assemble/express/factory/PersonFactory.java
+5
-3
未找到文件。
o2server/x_base_core_project/src/main/java/com/x/base/core/project/config/Organization.java
浏览文件 @
df44e448
...
@@ -3,6 +3,7 @@ package com.x.base.core.project.config;
...
@@ -3,6 +3,7 @@ package com.x.base.core.project.config;
import
java.io.File
;
import
java.io.File
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.io.FileUtils
;
import
org.apache.commons.lang3.BooleanUtils
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.annotation.FieldDescribe
;
import
com.x.base.core.project.gson.XGsonBuilder
;
import
com.x.base.core.project.gson.XGsonBuilder
;
...
@@ -14,7 +15,8 @@ public class Organization extends ConfigObject {
...
@@ -14,7 +15,8 @@ public class Organization extends ConfigObject {
private
static
final
long
serialVersionUID
=
-
2193428649985413384L
;
private
static
final
long
serialVersionUID
=
-
2193428649985413384L
;
public
final
static
Integer
DEFAULT_UNITLEVELORDERNUMBERDIGITS
=
10
;
public
static
final
Integer
DEFAULT_UNITLEVELORDERNUMBERDIGITS
=
10
;
public
static
final
Boolean
DEFAULT_PICKPERSONWITHNAME
=
false
;
public
static
Organization
defaultInstance
()
{
public
static
Organization
defaultInstance
()
{
return
new
Organization
();
return
new
Organization
();
...
@@ -23,11 +25,18 @@ public class Organization extends ConfigObject {
...
@@ -23,11 +25,18 @@ public class Organization extends ConfigObject {
@FieldDescribe
(
"unit中unitLevelOrderNumber扩充位数,<=0不扩充."
)
@FieldDescribe
(
"unit中unitLevelOrderNumber扩充位数,<=0不扩充."
)
private
Integer
unitLevelOrderNumberDigits
=
DEFAULT_UNITLEVELORDERNUMBERDIGITS
;
private
Integer
unitLevelOrderNumberDigits
=
DEFAULT_UNITLEVELORDERNUMBERDIGITS
;
@FieldDescribe
(
"人员识别过程中过程为先查找 distinguishedName 再查找中间的 unique 如果还是没有查找到是否要通过那么进行查找."
)
private
Boolean
pickPersonWithName
=
DEFAULT_PICKPERSONWITHNAME
;
public
Integer
getUnitLevelOrderNumberDigits
()
{
public
Integer
getUnitLevelOrderNumberDigits
()
{
return
NumberTools
.
nullOrLessThan
(
this
.
unitLevelOrderNumberDigits
,
1
)
?
DEFAULT_UNITLEVELORDERNUMBERDIGITS
return
NumberTools
.
nullOrLessThan
(
this
.
unitLevelOrderNumberDigits
,
1
)
?
DEFAULT_UNITLEVELORDERNUMBERDIGITS
:
this
.
unitLevelOrderNumberDigits
;
:
this
.
unitLevelOrderNumberDigits
;
}
}
public
Boolean
getPickPersonWithName
()
{
return
BooleanUtils
.
isTrue
(
this
.
pickPersonWithName
);
}
public
void
save
()
throws
Exception
{
public
void
save
()
throws
Exception
{
File
file
=
new
File
(
Config
.
base
(),
Config
.
PATH_CONFIG_ORGANIZATION
);
File
file
=
new
File
(
Config
.
base
(),
Config
.
PATH_CONFIG_ORGANIZATION
);
FileUtils
.
write
(
file
,
XGsonBuilder
.
toJson
(
this
),
DefaultCharset
.
charset
);
FileUtils
.
write
(
file
,
XGsonBuilder
.
toJson
(
this
),
DefaultCharset
.
charset
);
...
...
o2server/x_base_core_project/src/main/java/com/x/base/core/project/nlp/NaturalLanguageProcessing.java
0 → 100644
浏览文件 @
df44e448
package
com.x.base.core.project.nlp
;
import
java.util.ArrayList
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.function.Function
;
import
java.util.stream.Collectors
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.math.NumberUtils
;
import
com.hankcs.hanlp.HanLP
;
import
com.hankcs.hanlp.seg.common.Term
;
import
com.x.base.core.project.gson.GsonPropertyObject
;
public
class
NaturalLanguageProcessing
{
public
static
String
[]
SKIP_START_WITH
=
new
String
[]
{
"~"
,
"!"
,
"#"
,
"$"
,
"%"
,
"^"
,
"&"
,
"*"
,
"("
,
")"
,
"<"
,
">"
,
"["
,
"]"
,
"{"
,
"}"
,
"\\"
,
"?"
};
public
static
String
[]
SKIP_END_WITH
=
new
String
[]
{
"~"
,
"!"
,
"#"
,
"$"
,
"%"
,
"^"
,
"&"
,
"*"
,
"("
,
")"
,
"<"
,
">"
,
"["
,
"]"
,
"{"
,
"}"
,
"\\"
,
"?"
};
public
List
<
Item
>
word
(
String
content
)
{
List
<
Item
>
items
=
new
ArrayList
<>();
if
(
StringUtils
.
isNotBlank
(
content
))
{
for
(
Term
t
:
HanLP
.
segment
(
content
))
{
Item
item
=
new
Item
();
item
.
setLabel
(
t
.
nature
.
toString
());
/* 去掉中文空格和空格 */
item
.
setValue
(
StringUtils
.
trimToEmpty
(
StringUtils
.
replace
(
t
.
word
,
" "
,
" "
)));
if
(!
skip
(
item
))
{
items
.
add
(
item
);
}
}
}
/*
* b 区别词 c 连词 d 副词 e 叹词 f 方位词 h 前缀 k 后缀 o 拟声词 p 介词 q 量词 r 代词 u 组词 w 标点
*/
items
=
items
.
stream
()
// .filter(o -> (StringUtils.length(o.getValue()) > 1)
// && (!StringUtils.startsWithAny(o.getValue(), SKIP_START_WITH))
// && (!StringUtils.endsWithAny(o.getValue(), SKIP_END_WITH))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "b"))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "c"))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "d"))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "e"))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "f"))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "h"))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "k"))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "o"))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "p"))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "q"))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "r"))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "u"))
// && (!StringUtils.startsWithIgnoreCase(o.getLabel(), "w")) && (!label_skip_m(o)))
.
collect
(
Collectors
.
toList
());
Map
<
Item
,
Long
>
map
=
items
.
stream
().
collect
(
Collectors
.
groupingBy
(
Function
.
identity
(),
Collectors
.
counting
()));
List
<
Item
>
list
=
new
ArrayList
<>();
map
.
entrySet
().
stream
().
sorted
(
Map
.
Entry
.<
Item
,
Long
>
comparingByValue
().
reversed
()).
forEach
(
o
->
{
Item
t
=
o
.
getKey
();
t
.
setCount
(
o
.
getValue
());
list
.
add
(
t
);
});
return
list
;
}
private
boolean
skip
(
Item
o
)
{
if
((
StringUtils
.
length
(
o
.
getValue
())
>
1
)
&&
(!
StringUtils
.
startsWithAny
(
o
.
getValue
(),
SKIP_START_WITH
))
&&
(!
StringUtils
.
endsWithAny
(
o
.
getValue
(),
SKIP_END_WITH
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"b"
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"c"
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"d"
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"e"
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"f"
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"h"
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"k"
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"o"
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"p"
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"q"
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"r"
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"u"
))
&&
(!
StringUtils
.
startsWithIgnoreCase
(
o
.
getLabel
(),
"w"
))
&&
(!
label_skip_m
(
o
)))
{
return
false
;
}
return
true
;
}
private
boolean
label_skip_m
(
Item
item
)
{
if
(!
StringUtils
.
startsWithIgnoreCase
(
item
.
getLabel
(),
"m"
))
{
return
false
;
}
else
{
return
NumberUtils
.
isParsable
(
item
.
getValue
());
}
}
public
static
class
Item
extends
GsonPropertyObject
{
private
String
value
;
private
String
label
;
private
Long
count
;
public
String
getValue
()
{
return
value
;
}
public
void
setValue
(
String
value
)
{
this
.
value
=
value
;
}
public
String
getLabel
()
{
return
label
;
}
public
void
setLabel
(
String
label
)
{
this
.
label
=
label
;
}
public
Long
getCount
()
{
return
count
;
}
public
void
setCount
(
Long
count
)
{
this
.
count
=
count
;
}
@Override
public
int
hashCode
()
{
final
int
prime
=
31
;
int
result
=
1
;
result
=
prime
*
result
+
((
value
==
null
)
?
0
:
value
.
hashCode
());
return
result
;
}
@Override
public
boolean
equals
(
Object
obj
)
{
if
(
this
==
obj
)
return
true
;
if
(
obj
==
null
)
return
false
;
if
(
getClass
()
!=
obj
.
getClass
())
return
false
;
Item
other
=
(
Item
)
obj
;
if
(
value
==
null
)
{
if
(
other
.
value
!=
null
)
return
false
;
}
else
if
(!
value
.
equals
(
other
.
value
))
return
false
;
return
true
;
}
}
}
\ No newline at end of file
o2server/x_organization_assemble_express/src/main/java/com/x/organization/assemble/express/factory/PersonFactory.java
浏览文件 @
df44e448
...
@@ -13,12 +13,14 @@ import javax.persistence.criteria.CriteriaQuery;
...
@@ -13,12 +13,14 @@ import javax.persistence.criteria.CriteriaQuery;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Predicate
;
import
javax.persistence.criteria.Root
;
import
javax.persistence.criteria.Root
;
import
org.apache.commons.lang3.BooleanUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
org.apache.commons.lang3.StringUtils
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.entity.JpaObject
;
import
com.x.base.core.project.cache.Cache.CacheCategory
;
import
com.x.base.core.project.cache.Cache.CacheCategory
;
import
com.x.base.core.project.cache.Cache.CacheKey
;
import
com.x.base.core.project.cache.Cache.CacheKey
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.cache.CacheManager
;
import
com.x.base.core.project.config.Config
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.base.core.project.tools.ListTools
;
import
com.x.organization.assemble.express.AbstractFactory
;
import
com.x.organization.assemble.express.AbstractFactory
;
import
com.x.organization.assemble.express.Business
;
import
com.x.organization.assemble.express.Business
;
...
@@ -69,7 +71,7 @@ public class PersonFactory extends AbstractFactory {
...
@@ -69,7 +71,7 @@ public class PersonFactory extends AbstractFactory {
this
.
entityManagerContainer
().
get
(
Person
.
class
).
detach
(
o
);
this
.
entityManagerContainer
().
get
(
Person
.
class
).
detach
(
o
);
}
}
}
}
if
(
null
==
o
)
{
if
(
(
null
==
o
)
&&
BooleanUtils
.
isTrue
(
Config
.
organization
().
getPickPersonWithName
())
)
{
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Person
.
class
);
EntityManager
em
=
this
.
entityManagerContainer
().
get
(
Person
.
class
);
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaBuilder
cb
=
em
.
getCriteriaBuilder
();
CriteriaQuery
<
Person
>
cq
=
cb
.
createQuery
(
Person
.
class
);
CriteriaQuery
<
Person
>
cq
=
cb
.
createQuery
(
Person
.
class
);
...
@@ -169,8 +171,8 @@ public class PersonFactory extends AbstractFactory {
...
@@ -169,8 +171,8 @@ public class PersonFactory extends AbstractFactory {
CriteriaQuery
<
String
>
cq
=
cb
.
createQuery
(
String
.
class
);
CriteriaQuery
<
String
>
cq
=
cb
.
createQuery
(
String
.
class
);
Root
<
Person
>
root
=
cq
.
from
(
Person
.
class
);
Root
<
Person
>
root
=
cq
.
from
(
Person
.
class
);
Predicate
p
=
cb
.
equal
(
root
.
get
(
Person_
.
superior
),
person
.
getId
());
Predicate
p
=
cb
.
equal
(
root
.
get
(
Person_
.
superior
),
person
.
getId
());
list
=
em
.
createQuery
(
cq
.
select
(
root
.
get
(
Person_
.
id
)).
where
(
p
))
list
=
em
.
createQuery
(
cq
.
select
(
root
.
get
(
Person_
.
id
)).
where
(
p
))
.
getResultList
().
stream
().
distinct
()
.
getResultList
().
stream
().
distinct
().
collect
(
Collectors
.
toList
());
.
collect
(
Collectors
.
toList
());
return
list
;
return
list
;
}
}
...
...
编辑
预览
Markdown
is supported
0%
请重试
或
添加新附件
.
添加附件
取消
You are about to add
0
people
to the discussion. Proceed with caution.
先完成此消息的编辑!
取消
想要评论请
注册
或
登录