GithubHelp home page GithubHelp logo

isabella232 / text-duplicates-detector Goto Github PK

View Code? Open in Web Editor NEW

This project forked from harmoniedev/text-duplicates-detector

0.0 0.0 0.0 351 KB

Detects duplication in text

JavaScript 99.11% Batchfile 0.89%

text-duplicates-detector's Introduction

text-duplicates-detector codecov

Detects duplication in text

In a nutshell

Our purpose is to be able to count the number of unique occurences of a phrase in a corpus. The challenge is to be able to define what we mean exactly by unique.

This module provides a set of functions that detects whether occurences of a phrase in some texts are duplicate. By duplicate, we mean similar texts up to irrelevant modifications.

For instance, if we look at two pieces of text:

After a long period of inactivity, an intersting opportunity for IBM occurred last week.

The last period was not exciting due to the negociations that lead nowhere, until an intersting opportunity for Google occurred last week.

In the neighborhood of period, the texts are not similar while in the neighborhood of opportunity, the texts are similar.

We say that the occurences of period are not duplicate while the occurrences of opportunity are duplicate.

Usage

Node

Install:

npm install @harmon.ie/duplicate-text-detector

or

yarn add @harmon.ie/duplicate-text-detector
const dup = require('@harmon.ie/duplicate-text-detector');

const text1 = `After a long period of inactivity, an intersting opportunity for IBM occurred last week.`;
const text2 = `The last period was not exciting due to the negociations that lead nowhere, until an intersting opportunity for Google occurred last week.`;

dup.isDuplicate(text1, text2, 'period'); // returns false
dup.isDuplicate(text1, text2, 'opportunity'); // returns true

Browser

TBD

API Reference

Limitations and known issues

Limitations

  • Only the english language is supported.

Known issues

  • Only the first instance of the phrase in the texts are taken into account.

How does it work ?

The library implements a simple algorithm to detect lines that are candidate for being the start of a signature, and score each candidate by examining the lines following the start.

Example of trigger candidates:

  • name of the email sender
  • words such as Thanks and Regards

The score of each candidate is determined by the likelihood of the following lines to be part of the signature. Each of the lines that follow a trigger candidiate is given a score that relates to this likelihood.

Example of lines with high score:

  • phone number
  • email address
  • url
  • sender name.

Also, we implement some heuristics, for instance:

  • long lines should not appear too much in signature
  • signatures should not have too many lines

Note: The detectors of phone numbers, email addresses and urls are simple and their purpose is to support the signature scoring. They shouldn't be used standalone. Please refer to a specialized detector and validation libraries for that.

Roadmap and Contributions

text-duplicates-detector's People

Contributors

harmoniedev avatar viebel 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.