Toggle navigation
Toggle navigation
This project
Loading...
Sign in
윤창신
/
searchGuide
Go to a project
Toggle navigation
Toggle navigation pinning
Projects
Groups
Snippets
Help
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Snippets
Network
Create a new issue
Builds
Commits
Issue Boards
Authored by
김서영
2019-11-25 11:48:48 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
79b2ec74e3eefabef46cca711ba73f283d7b993e
79b2ec74
1 parent
59c7661f
complete textAnalystic
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
1 deletions
api/textAnalystic.js
api/textAnalystic.js
View file @
79b2ec7
...
...
@@ -76,7 +76,33 @@ const divideMorpbyMean = ( tempMorps ) => {
}
/**
* 수정중...
* @param {String} result - 결과 담던거
* @param {{text : string, begin : number, end : number }[]} words 단어 분석 결과를 담는 어레이
* @param {{lemma:string, position:number, type:string, id : number}[][]} needMorp - 공백 단위로 묶어둠 ex) [[{감기}],[{걸리},{었},{을}],[{때}]]
* @returns {String} 필요한 단어만 남겨둔 문장입니다.
* @description 필요한 morp와 원문 텍스트를 이용해 문장에서의 키워드를 분석해 문장으로 만들어 줍니다.
*/
const
makeKeyword
=
(
result
,
words
,
needMorp
)
=>
{
let
keywordText
=
""
;
needMorp
.
forEach
(
(
morps
)
=>
{
words
.
forEach
(
(
word
)
=>
{
if
(
word
.
begin
===
morps
[
0
].
id
){
let
tempByte
=
morps
[
morps
.
length
-
1
].
position
-
morps
[
0
].
position
+
Buffer
.
byteLength
(
morps
[
morps
.
length
-
1
].
lemma
);
for
(
let
ch
of
word
.
text
)
{
if
(
tempByte
>
0
)
{
keywordText
+=
ch
;
tempByte
-=
Buffer
.
byteLength
(
ch
)
}
}
}
});
keywordText
+=
" "
;
});
result
.
keywordText
=
keywordText
.
trim
();
}
/**
* @param {String} result - 결과 담던거
* @param {{NE : {}[], Morp : {}[]}} analysisResult 분석 결과가 담겼습니다.
* @description morp를 처리하는 함수 입니다 ^^
...
...
@@ -96,6 +122,11 @@ const divideMorp = async ( result, analysisResult ) => {
analysisResult
.
word
.
forEach
(
(
word
)
=>
{
tempMorps
.
push
(
analysisResult
.
morp
.
slice
(
word
.
begin
,
word
.
end
+
1
)
);
});
tempResult
.
originalMorp
=
analysisResult
.
morp
;
[
tempResult
.
needMorp
,
tempResult
.
noNeedMorp
]
=
await
divideMorpbyMean
(
tempMorps
);
await
makeKeyword
(
result
,
analysisResult
.
word
,
tempResult
.
needMorp
);
result
.
morps
=
tempResult
;
}
/**
...
...
Please
register
or
login
to post a comment