Skip to content
This repository has been archived by the owner on Jul 31, 2023. It is now read-only.

Commit

Permalink
0.1.0
Browse files Browse the repository at this point in the history
  • Loading branch information
zhuweiyou committed Feb 19, 2018
1 parent f1fae0a commit c936c86
Show file tree
Hide file tree
Showing 3 changed files with 10 additions and 8 deletions.
14 changes: 7 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,18 +1,16 @@
# answer

基于搜索引擎的简单答题模块,暂时只使用了百度搜索
基于搜索引擎的问答匹配度查询,暂时只使用了百度搜索

> 用于 [game-helper/weixin](https://github.com/game-helper/weixin) 答题类辅助没有正确答案时,搜索备用答案
> 目前用于 [game-helper/weixin](https://github.com/game-helper/weixin) 答题类辅助没有正确答案时,提交匹配度最高的选项
## 使用

安装
## 安装

```bash
npm i game-helper/answer
```

示例
## 示例

```js
const answer = require('answer')
Expand All @@ -26,6 +24,8 @@ const answer = require('answer')
'曹雪芹',
'罗贯中'
]
})) // [0, 0, 13,0] 数值越大的表示搜索结果越匹配,但不保证答案正确性
}))
// [0, 0, 13,0] 数值越大的表示搜索结果越匹配,理论上该选项为正确答案的几率更高,但不保证 100% 正确
})()
```

2 changes: 2 additions & 0 deletions package.json
Original file line number Diff line number Diff line change
@@ -1,4 +1,6 @@
{
"name": "answer",
"version": "0.1.0",
"main": "src/index.js",
"scripts": {
"test": "node test"
Expand Down
2 changes: 1 addition & 1 deletion src/baidu.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,5 +12,5 @@ module.exports = async ({question, options}) => {
}
})
data = cheerio.load(data)('#content_left').text()
return options.map(option => ((data.match(new RegExp(escapeRegExp(option), 'img')) || {length: 0}).length))
return options.map(option => (data.match(new RegExp(escapeRegExp(option), 'img')) || {length: 0}).length)
}

0 comments on commit c936c86

Please sign in to comment.