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-22 21:32:38 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
922b86e4ebf8fa5286238347a9da06ae12e7c1c0
922b86e4
1 parent
4e4c65c3
add textAnalystic.js/ compleate fix spelling check / proceed anlystic text
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
52 additions
and
0 deletions
api/textAnalystic.js
api/textAnalystic.js
0 → 100644
View file @
922b86e
const
apiRequest
=
require
(
'./apiRequest'
);
/**
* 수정중...
* @param {String} result - 결과 담던거
* @param {{NE : {}[], Morp : {}[]}} analysisResult 분석 결과가 담겼습니다.
* @description morp를 처리하는 함수 입니다 ^^
*/
const
divideMorp
=
async
(
result
,
analysisResult
)
=>
{
let
tempResult
=
{},
tempMorps
=
[];
analysisResult
.
NE
.
forEach
(
(
word
)
=>
{
analysisResult
.
morp
.
forEach
(
(
morp
,
index
)
=>
{
if
(
word
.
begin
<=
index
&&
word
.
end
>=
index
)
{
morp
.
type
=
"NOG"
;
}
});
});
analysisResult
.
word
.
forEach
(
(
word
)
=>
{
tempMorps
.
push
(
analysisResult
.
morp
.
slice
(
word
.
begin
,
word
.
end
+
1
)
);
});
}
/**
* @param {Object} clientData - 클라이언트에서 받아온 데이터
* @param {String} clientData.text - 분석할 텍스트
* @returns {Object} 분석 결과 데이터
* @description 클라이언트 데이터를 받아 의미를 분석하고 맞춤법을 교정해 돌려줍니다.
*/
const
textAnalystic
=
async
(
clientData
)
=>
{
let
result
=
{
"originalText"
:
clientData
.
text
},
fixedClientData
,
textAnalystic
;
fixedClientData
=
await
apiRequest
.
Korean
(
result
.
originalText
);
result
.
korean
=
fixedClientData
;
result
.
fixedText
=
result
.
korean
.
notag_html
;
try
{
textAnalystic
=
await
apiRequest
.
ETRI
(
"WiseNLU"
,
{
"analysis_code"
:
"ner"
,
"text"
:
result
.
fixedText
}
);
}
catch
(
err
)
{
throw
new
Error
(
err
.
message
);
}
await
divideMorp
(
result
,
textAnalystic
.
return_object
.
sentence
[
0
]
);
return
result
;
}
module
.
exports
=
textAnalystic
;
\ No newline at end of file
Please
register
or
login
to post a comment