Giter VIP home page Giter VIP logo

yatrie's Introduction

codecov Build Status GitHub license Twitter

Yatrie v0.1.0

Yet another PHP Trie Library

SETUP

git clone https://github.com/legale/yatrie

DEMO

  • search word in demo dictionary run: php demo.php человек to find word 'человек'

  • search speed measure run: php demo.php bmark 1000000 человек to perform a search a million times and show the execution time

OVERVIEW

This library is built almost without native PHP data structures. The dictionary stored in memory as a binary string. Current version speed is 1 millon words in 13.067 second (76528 wps).

Binary data storage structure before version 0.1.0:

node 154 bytes
  6 bytes to store bitmap (in the current codepage 47 bits are used)
  3 bytes * 46 chars = 148 bytes for references
node 154 bytes
  6 bytes to store bitmap (in the current codepage 47 bits are used)
  3 bytes * 46 chars = 148 bytes for references
etc

Binary data storage structure since version 0.1.0:

Nodes memory block:

node 0 (10 bytes)
  6 bytes to store bitmap (in the current codepage 47 bits are used)
  3 bytes reference id
node 1 (10 bytes)
  6 bytes to store bitmap (in the current codepage 47 bits are used)
  3 bytes reference id
etc

References memory block:

node 0 references (variable size)
  3 bytes reference to the next node
  3 bytes reference to the next node
  3 bytes reference to the next node
node 1 references (variable size)
  3 bytes reference to the next node
node 2 references (variable size)
  3 bytes reference to the next node
  3 bytes reference to the next node
etc

Basic methods for working with the library

  • add a word to the trie: $trie->trie_add('word');
  • remove a word from the trie: $trie->trie_remove('word');
  • check the existence of a word in the trie: $trie->trie_check('word');

yatrie's People

Contributors

legale avatar

Stargazers

 avatar

Watchers

James Cloos 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.