Git Product home page Git Product logo

fingles's Introduction

fingles

A functional rewrite of the schindel library, the goal is to make the library more extensible and open. The perfomance is at the first place, i just don't think that such a simple library should have a lot of boilerplate

For the algorithm description refer to the original repository README

NOTE: The crate can only be built with Nightly Rust because it's using const generics inference, which is currently only available in the Nightly Rust

TODO:

  • Saner hashing(functions-based), multiple hashing algorithm support

Example:

#![feature(generic_arg_infer)]
use fingles::*;

const HASH_LEN: usize = 100;
const NGRAM_LEN: usize = 5;

fn main() {
    let original = "\
        “My sight is failing,” she said finally. “Even when I was young I could not have read what was written there. \
        But it appears to me that that wall looks different. Are the Seven Commandments the same as they used to be, \
        Benjamin?” For once Benjamin consented to break his rule, and he read out to her what was written on the wall. \
        There was nothing there now except a single Commandment. It ran:\
        ALL ANIMALS ARE EQUAL BUT SOME ANIMALS ARE MORE EQUAL THAN OTHERS";

    let plagiarism = "\
        “My sight is failing,” she said finally. “When I was young I could not have read what was written there. \
        But it appears to me that that wall looks different. Are the Seven Commandments the same as they used to be” \
        Benjamin read out to her what was written. There was nothing there now except a single Commandment. \
        It ran: ALL ANIMALS ARE EQUAL BUT SOME ANIMALS ARE MORE EQUAL THAN OTHERS";

    let other = "\
        Throughout the spring and summer they worked a sixty-hour week, and in August Napoleon announced that there \
        would be work on Sunday afternoons as well. This work was strictly voluntary, but any animal who absented \
        himself from it would have his rations reduced by half. Even so, it was found necessary to leave certain \
        tasks undone. The harvest was a little less successful than in the previous year, and two fields which \
        should have been sown with roots in the early summer were not sown because the ploughing had not been \
        completed early enough. It was possible to foresee that the coming winter would be a hard one.";

    let original_hash = hash_from_string::<HASH_LEN, NGRAM_LEN>(original.chars());

    let plagiarism_hash = hash_from_string::<HASH_LEN, NGRAM_LEN>(plagiarism.chars());
    println!("plagiarism similarity: {}", compare_hashes::<_, NGRAM_LEN>(&original_hash, &plagiarism_hash));

    let other_hash = hash_from_string::<HASH_LEN, NGRAM_LEN>(other.chars());
    println!("other text similarity: {}", compare_hashes::<_, NGRAM_LEN>(&original_hash, &other_hash));
}

fingles's People

Contributors

unsafe-andrew-old avatar

Stargazers

Matthias Zepper avatar Uriadov Aleksey avatar

Watchers

 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.