Giter Site home page Giter Site logo

wordmatcher-1's Introduction

关键字匹配

1. 安装

分词器:Jieba

安装依赖:(查看依赖用 pip freeze)

pip install -r requirements.txt

启动:

python service.py

2. 接口

2.1 匹配接口

对输入内容进行内容分词和词包匹配。 输出结果包含词包名和匹配的内容。

请求:

post /match HTTP/1.1
{
    "text": "用科技让复杂的世界更简单"
}

响应:

{
    "data": {
        "A": [
            "办公",
            "简单",
            "科技"
        ],
        "B": []
    },
    "status": "success"
}

2.2 reload接口

调用该接口会重新加载分词器和所有的词包。

请求:

PUT /reload HTTP/1.1

响应:

{
    "message": "reload done.",
    "status": "success"
}

3. 测试

jieba官方分词数据:

  • 1.5 MB / Second in Full Mode
  • 400 KB / Second in Default Mode

Intel(R) Core(TM) i7-2600 CPU @ 3.4GHz

3.1 方案效果

分词方法 总条数 通过条数 准确性 分词耗时(s) 匹配耗时(s) 分词速度
数据集 35843(4161KB) 0 100% - - -
jieba-precision 35843 9670 73.0% 19.779 1.128 552ms/个(210KB/s)
jieba-full 35843 9670 73.0% 18.141 1.017 506ms/个(229KB/s)
jieba-search 35843 3838-497 89.3%(90.68%) 22.117 1.136 617ms/个(188KB/s)

3.2 性能测试

工具: apache benchmark
CPU: 2.3 GHz Intel Core i5 命令:ab -c 10 -n 1000 -T 'application/json' -p req.json http://127.0.0.1:5000/match

并发数 请求数 QPS TPR(ms)
10 500 67.38 14.841
10 1000 81.23 12.311
10 2000 57.13 17.505
50 500 65.44 15.282
50 1000 67.63 14.786
50 2000 61.47 16.267
100 500 73.70 13.568
100 1000 75.62 13.225
100 2000 67.10 14.903
100 3000 67.10 14.903

wordmatcher-1's People

Contributors

haluomao avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.