Thanks to visit codestin.com
Credit goes to github.com

Skip to content

gorimaaa/Aho-Corasick

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

4 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Aho-Corasick Algorithm Implementation

This repository provides an implementation of the Aho-Corasick string matching algorithm using two data structures:

  • Hash Table
  • Transition Matrix

Both implementations are designed to efficiently find all occurrences of multiple patterns within a given text.

Usage

Compiling the Project

Navigate to the main directory and run:

make

This will generate the following executables:

  1. genere-texte: Generates random texts.
  2. genere-mots: Generates random words.
  3. ac-hachage: Executes the Aho-Corasick algorithm using a hash table.
  4. ac-matrice: Executes the Aho-Corasick algorithm using a transition matrix.

Running the Programs

Generating Random Text

./genere-texte <text_length> <alphabet_size> > text.txt

Generating Random Words

./genere-mots <word_count> <min_length> <max_length> <alphabet_size> > words.txt

Running the Aho-Corasick Algorithm

Hash Table Implementation:

./ac-hachage words.txt text.txt

Transition Matrix Implementation:

./ac-matrice words.txt text.txt

Example Usage

  1. Generate a text of length 5,000,000 with an alphabet of size 4:
    ./genere-texte 5000000 4 > text.txt
  2. Generate 100 words with lengths between 5 and 15:
    ./genere-mots 100 5 15 4 > words.txt
  3. Run the Aho-Corasick algorithm:
    ./ac-hachage words.txt text.txt
    ./ac-matrice words.txt text.txt

Video Demonstration

Capture.video.du.2025-01-14.16-54-26.webm

About

Algorithm of Aho-Corasick in C implemented with hashtable and matrice

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published