Coder Social home page Coder Social logo

simila's Introduction

NuGet version

Installing via NuGet

Install-Package Bit.Simila

What is Simila?

Are Color and Colour equal? No!

if ("Color" == "Coluor")
   // Always false

if ("The Candy Shop" == "The Kandi Schap")
   // Always false

But they are Similar in Simila!

if (simila.AreSimilar("Color", "Colour"))
   // It's true now!

if (simila.AreSimilar("The Candy Shop", "The Kandi Schap"));
   // It's true now!

How to use

var simila = new Simila();

// Comparing Words
simila.AreSimilar("Lamborghini", "Lanborgini"); // True


// Comparing Expressions
simila.AreSimilar("Lamborghini is some great car", "Lanborgini is some graet kar"); // True

Customizing Simila

Treshold

You set the sensivity of similarity by setting Treshold. If not set, default value is 0.6 which means it considers similar if they are 60% similar

// Are similar if their at least 50% similar.
var similaEasy = new Simila()
{
    Treshold = 0.5 
};

// considered as similar.
similaEasy.IsSimilar("Lamborghini", "Lanborgni"); // True, They are 50% similar.

// Are similar if their at least 80% similar.
var similaTough = new Simila() 
{ 
    Treshold = 0.8 
};

// considered as NOT similar!
similaEasy.AreSimilar("Lamborghini", "Lanborgni"); // False, Not 80% similar.

Similarity Resolver

Similarity Resolvers are different algorithms which Simila can use for similarity checking. Each algorithm works fine it is being used in its proper scenario.

There are 3 types of similarity resolvers available in Simila:

  • Levenshtein (Default): It works good if we need them to look similar. You can read more about Levenshtein here: Levenshtein Algorithm
  • Soundex: It works good if we need them to sound similar. You can read more about Soundex here: Soundex Algorithm
  • SharedPair: It works good if we need them to structured similar.

You can configure simila to use a specific algorithm. We call them Resolvers.

Using Soudex Resolver

var similaSounedx = new Simila()
{
   Resolver = new SoundexSimilarityResolver()
};

Using SharedPair Resolver

var similaSharedPair = new Simila()
{
    Resolver = new SharedPairSimilarityResolver()
};

Using Levenshtein Resolver

Levenshtein is even more configurable. You can set the accepted mistakes both character level and word level. In this example we told Simila to consider color and colour words similar.

 var simila = new Simila()
 {
     Resolver = new PhraseSimilarityResolver(
                  new WordSimilarityResolver(
                     new MistakeRepository<Word>(new Mistake<Word>[]
                     {
                         ("color", "colour", 1)
                     })
                 )
    )
};

Also you can add some character level accepted mistakes. In this example we told Simila to not only consider color and colour similar, but also consider c and k similar too.

 var simila = new Simila()
 {
     Resolver = new PhraseSimilarityResolver(
                  new WordSimilarityResolver(
                     new MistakeRepository<Word>(new Mistake<Word>[]
                     {
                         ("color", "colour", 1)
                     }),
                     new CharacterSimilarityResolver(
                        new MistakeRepository<char>(new Mistake<char>[]
                        {
                           ('c', 'k', 1)
                        })
                     )
                 )
    )
};

simila's People

Contributors

amirhosseinab avatar mehrandvd avatar msynk avatar ysmoradi avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar

simila's Issues

Contact Me

Salam jenab mohandes darbare memari systemi mekhastsm nazarton ra beporsam , darsorat tamayol lotfan be man dar telegram payam bedid .
id: Asra6080
Eradatmandm.

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.