Giter Club home page Giter Club logo

php-mss's Introduction

README

一个实现多关键字的文本精确匹配搜的PHP扩展。

Quick Start

Build

$ git clone git://github.com/erning/php-mss.git
$ cd php-mss
$ phpize
$ ./configure
$ make

Run

$ cat sample.php | php -d "extension=modules/mss.so"

Round: 1
[
  (安居客, 公司名称, 0)
  (安居客, 公司名称, 15)
  (二手房, 通用名词, 57)
  (安居客, 公司名称, 122)
  (二手房, 通用名词, 149)
  (二手房, 通用名词, 263)
  (安居客, 公司名称, 380)
]
...

Features

  • Aho-Corasick算法
  • 实例可选持久化,即在多次请求间使用同一个实例,避免重复加载关键字。
  • 持久实例自动过期
  • 客户程序主动控制实例生命周期
  • 可选Closure作为回调函数,匹配到关键字时立即调用。回调函数可中断查找过程。

Example

启动网络服务

$ php -S 0.0.0.0:6060 -d "extension=modules/mss.so"

第一次访问

$ curl http://127.0.0.1:6060/example/example.php

Load dict
mss_creation: 2012-10-18 12:37:52
...

第二次访问

$ curl http://127.0.0.1:6060/example/example.php

mss_creation: 2012-10-18 12:37:52
...

第二次访问Load dict没有了,mss_creation不变。

当我们更新字典文件后再访问

$ touch example/example.dic
$ curl http://127.0.0.1:6060/example/example.php

Load dict
mss_creation: 2012-10-18 12:47:08
...

可以看到此时重新加载了字典,实例创建时间也是新的。

详见示例文件example/example.php

License

Licensed under the Apache License, Version 2.0

Copyright 2012 Anjuke Inc.

MultiFast

C library of Aho-Corasick Algorithm by multifast (LGPLv3).

php-mss's People

Contributors

erning avatar

Watchers

 avatar  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.