Code Monkey home page Code Monkey logo

paras-lehana / porter2 Goto Github PK

View Code? Open in Web Editor NEW

This project forked from markfullmer/porter2

1.0 2.0 0.0 272 KB

A PHP implementation of the English (Porter 2) Stemmer [added Protected words support]

Home Page: https://stemmer.markfullmer.com/demo/

License: MIT License

PHP 100.00%
stemmer stemming stemming-algorithm stemming-porters porter-stemmer-algorithm porter-stemmer-v2 porter-stemmer php php-library snowball composer composer-support

porter2's Introduction

Porter 2 Stemmer for PHP

Circle CI GitHub license

A PHP library for stemming words using the English Porter 2 algorithm.

Screenshot of Conversion

Background

A stemmer takes a given word and follows a set of rules to reduce this word to search-index-usable stem (as opposed to the actual word root). For example, aggravate, aggravated, and aggravates all reduce to "aggrav," thus creating a commonality between those words.

Martin Porter's English (Porter 2) Algorithm improves on the original Porter stemmer as described here.

Basic Usage

The included /demo/index.php file contains a conversion form demonstration.

Make your code aware of the Porter2 class via your favorite method (e.g., use or require)

Then pass a string of text into the class:

$text = Porter2::stem('consistently');
echo $text; // consist

$text = Porter2::stem('consisting');
echo $text; // consist

$text = Porter2::stem('consistency');
echo $text; // consist

Stemmer Resources

Tests

A verification list of 29,000 words and their expected stems can be run (after composer install via phpunit).

Contributions (Paras Lehana)

  • External file support for protected words: Now you can add protected words to this stemmer. Protected words won't be stemmed. For example, I have added 'training' as protected word so that it doesn't get stemmed to 'train'. Add words in newline in file src/protwords.txt (more instructions in protwords.txt file).

porter2's People

Contributors

markfullmer avatar paras-lehana avatar

Stargazers

 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.