Toggle navigation
Toggle navigation
This project
Loading...
Sign in
bluejoyq
/
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-12-03 19:03:55 +0900
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
c2e7e9479e0d645aa7be17ede8230ec260ca810c
c2e7e947
1 parent
a3b6fc42
add machineRead.js
Show whitespace changes
Inline
Side-by-side
Showing
1 changed file
with
32 additions
and
0 deletions
api/machineRead.js
api/machineRead.js
0 → 100644
View file @
c2e7e94
const
apiRequest
=
require
(
'./apiRequest'
);
/**
* @param {{url:string,title:string,passage:string}[]} searchResults 검색 결과 정리한것.
* @param {string} keywordText 기계독해 시킬 질문의 텍스트
* @returns {{url:string,title:string,passage:string,confidence:number}[]} searchResults의 각 object에 confidence 속성을 추가해 돌려준다.
* @description 기계독해를 사용하는 함수
*/
const
machineRead
=
async
(
searchResults
,
keywordText
)
=>
{
let
keyNum
=
6
,
ResultArray
=
[],
divideSearchResults
=
[];
for
(
let
i
=
0
;
i
<=
searchResults
.
length
;
i
+=
keyNum
)
{
divideSearchResults
.
push
(
searchResults
.
slice
(
i
,
i
+
keyNum
)
);
}
for
(
let
divideSearchResult
of
divideSearchResults
)
{
try
{
await
apiRequest
.
multiETRI
(
divideSearchResult
,
keywordText
);
}
catch
(
err
)
{
throw
new
Error
(
err
.
message
);
}
ResultArray
=
ResultArray
.
concat
(
divideSearchResult
);
}
searchResults
=
ResultArray
;
return
searchResults
;
}
module
.
exports
=
machineRead
;
Please
register
or
login
to post a comment