Giter VIP home page Giter VIP logo

tokenizer's Introduction

PHP Math Tokenizer

Integrity check codecov Latest Stable Version Latest Unstable Version License: MIT PHPStan Enabled

Mathematicator Tokenizer is a simple library for converting string math formulas to a stream of tokens with LaTeX support.

Installation

composer require mathematicator-core/tokenizer

Features

  • Convert all your math formulas to a stream of tokens
  • Convert user math input to LaTeX
  • Render the tokens tree map for debug

Usage

Inject the Tokenizer service via DI and tokenize your query.

use \Mathematicator\Tokenizer\Tokenizer;

$tokenizer = new Tokenizer(/* some dependencies */);

// Convert math formula to an array of tokens:
$tokens = $tokenizer->tokenize('(5+3)*(2/(7+3))');

// Now you can convert tokens to a more useful format:
$objectTokens = $tokenizer->tokensToObject($tokens);

var_dump($objectTokens); // Return typed tokens with meta data

// Render to LaTeX
echo $tokenizer->tokensToLatex($objectTokens);

// Render to debug tree (extremely fast):
echo $tokenizer->renderTokensTree($objectTokens);

Configuration

The tokenizer uses automatic configuration based on DI. Just use the DI container and the service will be fully available.

Mathematicator Framework tools structure

The biggest advantage is that you can choose which layer best fits your needs and start build on the top of it, immediately, without the need to create everything by yourself. Our tools are tested for bugs and tuned for performance, so you can save a significant amount of your time, money, and effort.

Framework tend to be modular as much as possible, so you should be able to create an extension on each layer and its sublayers.

Mathematicator framework layers ordered from the most concrete one to the most abstract one:

Search Modular search engine layer that calls its sublayers and creates user interface.
Vizualizator Elegant graphic visualizer that can render to SVG, PNG, JPG and Base64.
Extensions: Mandelbrot set generator
Calculator Modular advance calculations layer.
Extensions: Integral Solver , Statistics
Engine Core logic layer that maintains basic controllers, DAOs, translator, common exceptions, routing etc.
Tokenizer Tokenizer that can convert string (user input / LaTeX) to numbers and operators.
Numbers Fast & secure storage for numbers with arbitrary precision. It supports Human string and LaTeX output and basic conversions.

Third-party packages:

โš ๏ธ Not guaranteed!

REST API Install the whole pack as a REST API service on your server (Docker ready) or access it via public cloud REST API.

Contribution

Please help to improve this documentation by sending a Pull request.

Tests

All new contributions should have its unit tests in /tests directory.

Before you send a PR, please, check all tests pass.

This package uses Nette Tester. You can run tests via command:

composer test

For benchmarking, we use phpbench. You can run benchmarks this way:

composer global require phpbench/phpbench @dev # only the first time
phpbench run

Before PR, please run complete code check via command:

composer cs:install # only first time
composer fix # otherwise pre-commit hook can fail

tokenizer's People

Contributors

dependabot-preview[bot] avatar idome89 avatar janbarasek avatar miloshavlicek 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.