Skip to content
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation
This project
Loading...
Sign in
石磊
/
cihai
Go to a project
Project
Repository
Issues
0
Merge Requests
0
Pipelines
Wiki
Settings
Activity
Graph
Charts
Create a new issue
Jobs
Commits
Issue Boards
Files
Commits
Branches
Tags
Contributors
Graph
Compare
Charts
Commit 0d7a1a14
authored
Dec 07, 2017
by
侯昆
Browse Files
Options
Browse Files
Tag
Download
Email Patches
Plain Diff
图谱信息
1 parent
5d4f5306
Show whitespace changes
Inline
Side-by-side
Showing
4 changed files
with
44 additions
and
15 deletions
serverside/cihai-core/src/main/java/com/dookay/cihai/core/aip/AipUtilBean.java
serverside/cihai-core/src/main/java/com/dookay/cihai/core/aip/WordRelation.java
serverside/cihai-core/src/main/java/com/dookay/cihai/core/aip/WordSequence.java
serverside/cihai-core/src/test/java/com/dookay/cihai/core/BaiduTest.java
serverside/cihai-core/src/main/java/com/dookay/cihai/core/aip/AipUtilBean.java
View file @
0d7a1a1
...
@@ -211,9 +211,10 @@ public final class AipUtilBean {
...
@@ -211,9 +211,10 @@ public final class AipUtilBean {
double
score
=
doSimnet
(
word1
,
word
);
double
score
=
doSimnet
(
word1
,
word
);
if
(
score
>
RELATE_CRITICAL_VALUE
)
{
if
(
score
>
RELATE_CRITICAL_VALUE
)
{
WordRelation
relation
=
new
WordRelation
();
WordRelation
relation
=
new
WordRelation
();
relation
.
setWord1
(
word1
);
int
from
=
words
.
indexOf
(
word1
);
relation
.
setWord2
(
word
);
int
to
=
words
.
indexOf
(
word
);
relation
.
setScore
(
score
);
relation
.
setFrom
(
from
);
relation
.
setTo
(
to
);
wordRelations
.
add
(
relation
);
wordRelations
.
add
(
relation
);
}
}
}
}
...
...
serverside/cihai-core/src/main/java/com/dookay/cihai/core/aip/WordRelation.java
View file @
0d7a1a1
...
@@ -24,7 +24,6 @@ import lombok.Data;
...
@@ -24,7 +24,6 @@ import lombok.Data;
*/
*/
@Data
@Data
public
class
WordRelation
{
public
class
WordRelation
{
private
String
word1
;
private
int
from
;
private
String
word2
;
private
int
to
;
private
double
score
;
}
}
serverside/cihai-core/src/main/java/com/dookay/cihai/core/aip/WordSequence.java
0 → 100644
View file @
0d7a1a1
package
com
.
dookay
.
cihai
.
core
.
aip
;
/*****************************************
* *
* @dookay.com Internet make it happen *
* ----------- ----------------------- *
* dddd ddddd Internet make it happen *
* o o o Internet make it happen *
* k k k Internet make it happen *
* a a a Internet make it happen *
* yyyy yyyyy Internet make it happen *
* ----------- ----------------------- *
* @dookay.com Internet make it happen *
* *
****************************************/
import
lombok.Data
;
/**
* @author houkun
* @date 2017/12/7
*/
@Data
public
class
WordSequence
{
private
int
id
;
private
String
label
;
public
WordSequence
(
int
id
,
String
label
)
{
this
.
id
=
id
;
this
.
label
=
label
;
}
}
serverside/cihai-core/src/test/java/com/dookay/cihai/core/BaiduTest.java
View file @
0d7a1a1
...
@@ -17,6 +17,9 @@ package com.dookay.cihai.core;
...
@@ -17,6 +17,9 @@ package com.dookay.cihai.core;
import
com.alibaba.fastjson.JSON
;
import
com.alibaba.fastjson.JSON
;
import
com.dookay.cihai.core.aip.AipUtilBean
;
import
com.dookay.cihai.core.aip.AipUtilBean
;
import
com.dookay.cihai.core.aip.WordRelation
;
import
com.dookay.cihai.core.aip.WordRelation
;
import
com.dookay.cihai.core.aip.WordSequence
;
import
jdk.nashorn.internal.ir.annotations.Immutable
;
import
org.apache.commons.lang3.tuple.ImmutablePair
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.apache.commons.lang3.tuple.Pair
;
import
org.junit.Assert
;
import
org.junit.Assert
;
import
org.junit.Test
;
import
org.junit.Test
;
...
@@ -29,6 +32,7 @@ import java.io.File;
...
@@ -29,6 +32,7 @@ import java.io.File;
import
java.io.FileReader
;
import
java.io.FileReader
;
import
java.util.List
;
import
java.util.List
;
import
java.util.Map
;
import
java.util.Map
;
import
java.util.stream.Collectors
;
/**
/**
* @author houkun
* @author houkun
...
@@ -73,18 +77,11 @@ public class BaiduTest extends CihaiCoreApplicationTests {
...
@@ -73,18 +77,11 @@ public class BaiduTest extends CihaiCoreApplicationTests {
FileReader
reader
=
new
FileReader
(
file
);
FileReader
reader
=
new
FileReader
(
file
);
String
text
=
FileCopyUtils
.
copyToString
(
reader
);
String
text
=
FileCopyUtils
.
copyToString
(
reader
);
List
<
String
>
list
=
aipUtilBean
.
extractKeyWords
(
"中国共产党第十九次全国代表大会"
,
text
,
15
);
List
<
String
>
list
=
aipUtilBean
.
extractKeyWords
(
"中国共产党第十九次全国代表大会"
,
text
,
15
);
System
.
out
.
println
(
JSON
.
toJSONString
(
list
));
List
<
WordSequence
>
wordSequences
=
list
.
stream
().
map
(
l
->
new
WordSequence
(
list
.
indexOf
(
l
),
l
)).
collect
(
Collectors
.
toList
());
// Map<Pair<String, String>, Double> map = aipUtilBean.calcKeywordsRelated("中国共产党第十九次全国代表大会", list);
// System.out.println(map);
// for (String s : list) {
// Map<Pair<String, String>, Double> map1 = aipUtilBean.calcKeywordsRelated(s, list);
// System.out.println(map1);
// }
List
<
WordRelation
>
wordRelations
=
aipUtilBean
.
generateWordsMap
(
list
);
List
<
WordRelation
>
wordRelations
=
aipUtilBean
.
generateWordsMap
(
list
);
System
.
out
.
println
(
wordSequences
);
System
.
out
.
println
(
wordRelations
);
System
.
out
.
println
(
wordRelations
);
System
.
out
.
println
(
wordRelations
.
size
());
System
.
out
.
println
(
wordRelations
.
size
());
// Map<String, Long> map = aipUtilBean.extractNounWordsWithCount(text);
// System.out.print(map.toString());
}
}
}
}
Write
Preview
Markdown
is supported
Attach a file
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to post a comment