Giter Club home page Giter Club logo

test_pattern_recognition's Introduction

Let we have 3 kinds of characters:

  • letters;
  • digits;
  • others.

You can add more types. For example, divide the letters into uppercase and lowercase. To do this, you will need to change regex_int_mask_relations in file recognition.py

You can specify the initial data for analysis as list input_array in file recognition.py

The analysis process is divided into stages:

Stage 1:

Map all symbols in input data to internal mask presentation (letters/digits/others) Example: "A--1012332/1" -> "loodddddddod"

Stage 2:

Group internal mask presentation by removing duplicate symbols. This masks we will use for searching errors in the input data. Example: "loodddddddod" -> "lodod" Plus counting duplicate symbols: "loodddddddod" -> "lo{2}d{7}od"

Stage 3

Calc the popularity of all short masks to find the most popular. Other masks are considered erroneous. Example: 'lodod' - most popular. Suitable for 80% of input data

Stage 4:

We get all the groups of all input array, remove duplicates by set(). Consider only objects with the most popular mask. Example: list of groups: [{'S', 'A'}, {'--'}, {'1012332', '1231142'}, {'/'}, {'1', '2', '11'}] Length of this list = length of the most popular mask

Stage 5:

Analyze each group to find a mutual beginning or end. If found - move it to a separate group. This will make it possible to specify the format more accurately. Example: Set {'1012332', '1231142'} has mutual parts - "1" at the begining and "2" at the end. So it will be divided into 3 groups {'1'}, {'01233', '23114'} and {'2'}. Result list of groups: [{'S', 'A'}, {'--'}, {'1'}, {'01233', '23114'}, {'2'}, {'/'}, {'1', '2', '11'}]

Stage 6:

Сollect from the resulting groups an array for the formation of regex Available cases:

  • specific value ({'--'});
  • any char from set ({'S', 'A'});
  • string of one type (from regex_int_mask_relations) with len range ({'1', '2', '11'}).

Example: result: ^[SA]--1\d{5}2/\d{1,2}$

test_pattern_recognition's People

Contributors

mkud avatar

Stargazers

 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.