Coder Social home page Coder Social logo

yuanyufeng1008 / keywordfilteringservice Goto Github PK

View Code? Open in Web Editor NEW

This project forked from wosiwo/keywordfilteringservice

0.0 2.0 0.0 483 KB

A PHP HTTPServer that you can use to filter keywords. It depends on a php extension named Swoole.

PHP 99.34% HTML 0.23% ApacheConf 0.01% CSS 0.04% Smarty 0.30% C 0.08% Shell 0.01%

keywordfilteringservice's Introduction

KeywordFilteringService

  • A PHP HTTPServer that you can use to filter keywords. It depons on a php extension named Swoole.

  • 以HTTP方式提供关键词过滤服务,这个服务依赖php swoole扩展。

  • swoole扩展让PHP有了直接提供HTTP服务的能力,使得庞大的字典可以常驻内存,避免原生php每次访问都需要重新载入字典所耗费的时间(随着字典条目的增加这个时间会越来越长)。

    时间主要耗费在将字符串反序列化成数组上,这是由于php数组在内核的实现机制

  • 这里使用HTTP方式的原因主要是考虑到通用性,可以参考swoole官方的example修改成socket接口来实现同样的功能。

  • 具体的过滤实现代码则是从phpwind中提取出来

Requirements

  • php swoole extension
  • swooleFramework
  • phpwind filter class
  • PHP 5.3.10 at least

Usage

  • step 1 install swoole extension
    pecl install swoole
    vim /etc/php.ini 
    #add extension=swoole.so  
  • step 2 dowload KeywordFilteringServie
git clone [email protected]:wosiwo/KeywordFilteringService.git
  • step 3 create binary dict

    this step will read original dict from /server/dict_all.txt ,then convert Plaintext into ASCII code and use it to build array with a struct which is conducive to search

cd KeywordFilteringService/dict
php createBinaryDict.php
  • step 4 start the httpserver
php server.php start
  • step 5 now you can call it by service client

    php tests/keyword_service.php

    if the page show a [["wosiwo","0.8"]] , it shows that the service is running successfully.

##Tip:

To increase the transmission limit ,You may need to change your kernel parameters of your computer. In FreeBSD/MacOS:

sysctl -w net.local.dgram.maxdgram=8192
sysctl -w net.local.dgram.recvspace=200000 修改Unix Socket的buffer区尺寸

other to see http://wiki.swoole.com/wiki/page/11.html

keywordfilteringservice's People

Contributors

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