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-23 15:15:24 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
60dfc9bc43c9350cf480e5f952252ba606666b08
60dfc9bc
1 parent
49017438
check morp and add divide morp by MAG tag
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
42 additions
and
1 deletions
api/textAnalystic.js
api/textAnalystic.js
View file @
60dfc9b
const
apiRequest
=
require
(
'./apiRequest'
);
const
allowMorpChecklist
=
[
"NNG"
,
"NNP"
,
"NNB"
,
"VA"
,
"MM"
,
"MAG"
,
"SL"
,
"SH"
,
"SN"
,
"XPN"
,
"XSN"
,
"XSA"
,
"ETM"
,
"NOG"
];
const
vvMorpChecklist
=
[
"ETM"
,
"ETN"
];
// 명사형 전성어미(ex) '-(으)ㅁ', '-기'), 관형사형 전성어미(ex) '-ㄴ', '-', '-던', '-ㄹ'), 지정자(VCP,VCN, ex) '-이다', '-아니다')
const
npMorpCecklist
=
[
'어디'
,
'언제'
];
// 필요한 의문사 리스트
/**
* @param {{lemma:string, position:number, type:string}[]} word - 한 단어의 형태소 ex) [{걸리},{었},{을}]
* @param {{lemma:string, position:number, type:string}[][]} needMorp - 공백 단위로 묶어둠 ex) [[{감기}],[{걸리},{었},{을}],[{때}]
* @param {{lemma:string, position:number, type:string}[][]} noNeedMorp - 공백 단위로 묶어둠 ex) [[{감기}],[{걸리},{었},{을}],[{때}]
* @description word의 각 형태소의 type이 allowMorpChecklist에 있는지 확인하고 있으면 needMorp, 없으면 noNeedMorp에 추가합니다.
*/
const
checkMorp
=
(
word
,
needMorp
,
noNeedMorp
)
=>
{
let
needMorpTemp
=
[],
noNeedMorpTemp
=
[];
word
.
forEach
(
(
morp
)
=>
{
if
(
allowMorpChecklist
.
indexOf
(
morp
.
type
)
!==
-
1
)
{
needMorpTemp
.
push
(
morp
);
}
else
if
(
npMorpCecklist
.
indexOf
(
morp
.
lemma
)
!==
-
1
)
{
needMorpTemp
.
push
(
morp
);
}
else
{
noNeedMorpTemp
.
push
(
morp
);
}
});
if
(
noNeedMorpTemp
.
length
>
0
)
{
noNeedMorp
.
push
(
noNeedMorpTemp
);
}
if
(
needMorpTemp
.
length
>
0
)
{
needMorp
.
push
(
needMorpTemp
);
}
}
/**
* @param {{lemma:string, position:number, type:string}[][]} tempMorps - 공백 단위로 묶어둠 ex) [[{감기}],[{걸리},{었},{을}],[{때}]]
* @returns {{needMorp : {}[][], noNeedMorp : {}[][]}} morp를 needMorp와 noNeedMorp로 나눴습니다.
...
...
@@ -12,7 +43,8 @@ const divideMorpbyMean = ( tempMorps ) => {
tempMorps
.
forEach
(
(
word
,
j
)
=>
{
if
(
word
[
0
].
type
===
"VV"
||
word
[
0
].
type
===
"VA"
||
word
[
0
].
type
===
"MAG"
)
{
// 동사, 형용사, 부사
let
checkV
=
true
let
checkV
=
true
,
checkM
=
true
;
word
.
find
(
(
Morp
)
=>
{
if
(
Morp
.
type
===
"EF"
)
{
// 종결어미
checkV
=
false
;
...
...
@@ -24,8 +56,17 @@ const divideMorpbyMean = ( tempMorps ) => {
}
});
}
}
else
if
(
word
[
0
].
type
===
"MAG"
)
{
if
(
Morp
.
type
===
"XSV"
)
{
// 동사파생 접미사 ex) -하다
checkM
=
false
;
}
}
});
if
(
checkV
&&
checkM
)
{
needMorp
.
push
(
word
);
}
else
{
noNeedMorp
.
push
(
word
);
}
}
else
{
checkMorp
(
word
,
needMorp
,
noNeedMorp
);
...
...
Please
register
or
login
to post a comment