Modified Aho Corasick Algorithm Satish Dechu Sandeep Dechu ID: 997-19-7980 ID: xxx-xx- 3940 [email protected] [email protected]

Vamshi Pampati ID:xxx-xx-5582 [email protected]

1. Introduction In many information retrieval and text-editing applications it is necessary to be able to locate quickly some or all occurrences of user-specified patterns of words and phrases in text. This paper describes a simple, efficient algorithm to locate all occurrences of any of a finite number of keywords and phrases in an arbitrary text string. The approach should be familiar to those acquainted with finite automata. The algorithm consists of two parts. In the first part we construct from the set of keywords a finite state pattern matching machine; in the second part we apply the text string as input to the pattern matching machine. The machine signals whenever it has found a match for a keyword. Using finite state machines in pattern matching applications is not new, but their use seems to be frequently shunned by programmers. Part of the reason for this reluctance on the part of programmers may be due to the complexity of programming the conventional algorithms for constructing finite automata from regular expressions, particularly if state minimization techniques are needed. This paper shows that an efficient finite state pattern matching machine can be constructed quickly and simply from a restricted class of regular expressions, namely those consisting of finite sets of keywords. Our approach combines the ideas in the Knuth-Morris-Pratt algorithm with those of finite state machines. Perhaps the most interesting aspect of this paper the amount of improvement the finite state algorithm gives over more conventional approaches. We used the finite state pattern matching algorithm in a library bibliographic search program. The purpose of the program is to allow a bibliographer to find in a citation index all titles satisfying some Boolean function of keywords and phrases. The search program was first implemented with a straightforward string matching algorithm. Replacing this algorithm with the finite state approach resulted in a program whose running time was a fifth to a tenth of the original program on typical inputs.

Failure function in aho corasick algorithm: Construction for failure function

2.EXPERIMENTATION

Modified Aho Chorasic Algorithm: Objective: Removing Failure function in aho_corasick algorithm by ‘goto-queue’.

In general aho chorasic method; As explained earlier, a database for failure pointers is maintained in order to link to a new node when fail transition occurs, which increases the space complexity. So here we propose a new methodology where in we try to reduce the storage problem by introducing a different way of pattern matching procedure after constructing the database with the given key words. The modified machine works as fallows Consider the example given above, in which the text “ushers” has to be matched with the keywords set {“she”, “he”, “hers”, “his”}. First an FSM is created with the given keywords same as explained above. Then it starts a goto function g(0,a)=s, where s is valid if a={h,s}.then this function makes a transition from State 0 to state 1 or 3 depending on the symbol. In the current example first symbol is ‘u’ and g(0,u) = 0, then the next symbol to match is ‘s’, and g(0,s) = 3, and the current state becomes 3. while matching the next symbol which is ‘h’ here , it traverses from the state 3 and proceeds. Simultaneously a new process is created whenever a valid transition occurs which repeats the same procedure from the root node. This process is repeated for all the symbols until they encounter a failure or the bottom state in that branch is reached, then that process is finished. Whenever it finds an output that output and its index is emitted out. process 1: g(0,u) = 0 -> g(0,s) = 3 -> g(3,h) = 4 -> g(4,e) = 5 (output state) -> g(5,r) = fail process 2: g(0,h) = 1 -> g(1,e) = 2 ( output state ) -> g(2,r) = 8 -> g(8,s) (output state) process 3: g(0,e) = fail process 4: g(0,r) = fail process 5: g(0,s)=3 (end of text)

From the above table of processes it can be inferred that even by starting from root node every time almost all of the processes ends at the same time so with this parallel processing implementation the speed may decrease a little bit but doesn’t become worse. Pseudo code for this implementation is explained below.

Pseudo Code: Input: text Output: emit the outputs and index position. 1.sÅ0; 2. while(text) { while ({“goto” queue}!=empty) { // for all gi in “goto” queue

if (gi(s,a) == fail) {goto queue}Å{goto queue} – gi(s,a); else if (gi(s,a) = = s’ && output(s’)!=empty) { {“goto” queue}Å {“goto” queue} - gi(s,a) ; emit output; } }

if(gi(s,a)Æ s’ !=fail) {

{“goto” queue} Å {“goto” queue} U gi+1(0,a);

} }

Pseudo code for goto function Input : set of keywords k={y1,y2..yk} Output: goto function and partially compute output function output Method: we assume output(s) is empty when state s is first created And g(s,a)=fail ,if a is undefined or if g(s,a) has not yet Been defined.The procedure enter(y) insterts into goto Graph a path spell out y ;

Basic aho_corsasick structure

struct aho_state { struct aho_state * next_state[256]; struct rule * rule_list; struct aho_state * fail_ptr; }

Modified aho_corasick structure

Struct aho_state { Struct aho_state * next_state[256]; Struct rule * rule_list }

goto queue gi(s,a) gi-1(s,a) gi-2(s,a)

g0(s,a)

Because in aho corasick algorithm each node points to failure pointer of type aho corasick node so it will take the same number of bytes as the basic aho corasick node.This extra memory overhead is eliminated by our Modified aho corasick algorithm. So we can say that the reduction in memory is reduced by 20-30% atleast.

Flow chart for FSM machine

Flow chart for Aho_goto_queue function

Results: We implemented the goto queue for Aho Corasick Algorithm. We maintained multi ‘goto’ pointers in ‘goto’ queue which moves with the text character if it matches the pattern character. We initialize a new goto pointer when this happens. So in this stage we have two goto pointers. Like this we can have multiple goto pointers at any stage. Our idea is we will initiate a new goto pointer at the header when previous goto pointer moves. In this scheme we no need maintain failure function. When the one of the pattern matches or when goto pointer fails to move to next state that goto pointer stopped. By above method it is obvious that there is less memory usage is done as compared with normal aho corasick ,because there is no failure function. Failure function requires a lot of memory to maintain as the number of patterns which have common prefixes increases. So the unmodified aho_corasick algorithm has memory overhead. In these days the gap between memory and processing speed is a bottleneck the processor takes lot of penalty cycles when it access memory. By above technique we can reduce the space complexity.

rule 10

Rule 500

rule 1000

Aho corasick

60(kb)

1550(kb)

3825(kb)

Modified aho Corasick

46(kb)

1116(kb)

2795(kb)

4000 3000 aho corasick 2000 modified aho corasick

1000 0 10

500 1000

Problems Encountered: Actually we can implement this algorithm by using goto-threads instead of goto pointers .If we implement with threads we can further reduce the memory .But we did our code in C ,the threads in C are not flexible . If we implement this algorithm in java we could show you this algorithm in better way as a pipeline model,because threads in java are user friendly than C pthreads. Another problem we faced is we could not able to measure the memory it is taking in dynamically .We can know this if we run this bench program in simplescalar tool .But we are not familiar with the simple scalar tool and how to convert a normal ‘c’ file into a bench mark program which simple scalar can take as an input. Project Summary: Pros : The best part of our algorithm is we reduce the memory overhead which is the main disadvantage in normal aho corasick algorithm. Cons: Speed of over algorithm might be little bit slow. Because of parallel processing this slow compared with normal aho corasick is negligible

References: [1]. "Efficient string matching: An aid to bibliographic search". Aho, Alfred V., Margaret J. Corasick (June 1975) [2]. “Efficient multi-attribute pattern matching using the extended Aho-Corasick method” Ando, K.; Okada, M.; Shishibori, M.; Jun-Ichi Aoe

[3]. Speed-up of aho-corasick pattern matching machines by rearranging states” Nishimura, T.; Fukamachi, S.; Shinohara, T.;

Modified Aho Corasick Algorithm - Semantic Scholar

goto function g(0,a)=s, where s is valid if a={h,s}.then this function makes a transition from State 0 to state 1 or 3 depending on the symbol. In the current example ...

129KB Sizes 62 Downloads 336 Views

Recommend Documents

Modified Aho Corasick Algorithm - Semantic Scholar
apply the text string as input to the pattern matching machine. ... Replacing this algorithm with the finite state approach resulted in a program whose running.

Lightpath Protection using Genetic Algorithm ... - Semantic Scholar
connectivity between two nodes in the network following a failure by mapping ... applications and high speed computer networks because of huge bandwidth of ...

Lightpath Protection using Genetic Algorithm ... - Semantic Scholar
virtual topology onto the physical topology so as to minimize the failure ... applications and high speed computer networks because of huge bandwidth of optical ...

The MarkIII microphone array: the modified version ... - Semantic Scholar
Nov 11, 2004 - points are reported (although they could be considered as trivial) ..... A first solution we envisaged was putting an LC cell after each .... worth noting that the foreseen power supply system may imply more noise than what.

Fixed-Point DSP Algorithm Implementation, SF 2002 - Semantic Scholar
Embedded Systems Conference ... The source of these signals can be audio, image-based or ... elements. Figure 1 shows a typical DSP system implementation.

Fixed-Point DSP Algorithm Implementation, SF 2002 - Semantic Scholar
Developing an understanding of which applications are appropriate for floating point ... The code development process is also less architecture aware. Thus,.

A Unified Framework and Algorithm for Channel ... - Semantic Scholar
with frequency hopping signalling," Proceedings of the IEEE, vol 75, No. ... 38] T. Nishizeki and N. Chiba, \"Planar Graphs : Theory and Algorithms (Annals of ...

Variation of the Balanced POD Algorithm for Model ... - Semantic Scholar
is transformation-free, i.e., the balanced reduced order model ... over the spatial domain Ω = [0, 1] × [0, 1], with Dirichlet boundary ..... 9.07 × 100. 2.91 × 100. MA.

Supposed advantages of the proposed algorithm ... - Semantic Scholar
Page 1. An Optimization Based Fast Multi-level Thresholding Technique. Jayadev ... Optimization (PSO) is then proposed which works much faster than the ...

A Lightweight Algorithm for Dynamic If-Conversion ... - Semantic Scholar
Jan 14, 2010 - Checking Memory Coalesing. Converting non-coalesced accesses into coalesced ones. Checking data sharing patterns. Thread & thread block merge for memory reuse. Data Prefetching. Optimized kernel functions & invocation parameters float

Variation of the Balanced POD Algorithm for Model ... - Semantic Scholar
is transformation-free, i.e., the balanced reduced order model is approximated directly ... one dimensional hyperbolic PDE system that has a transfer function that can be ... y)wy +b(x, y)u(t), over the spatial domain Ω = [0, 1] × [0, 1], with Diri

A Randomized Algorithm for Finding a Path ... - Semantic Scholar
Dec 24, 1998 - Integrated communication networks (e.g., ATM) o er end-to-end ... suming speci c service disciplines, they cannot be used to nd a path subject ...

Fixed-Point DSP Algorithm Implementation, SF 2002 - Semantic Scholar
Digital Signal Processors are a natural choice for cost-sensitive, computationally intensive .... analog domain and digital domain in a fixed length binary word.

Supposed advantages of the proposed algorithm ... - Semantic Scholar
1Indian Institute Of Technology Kharagpur. 2Schlumberger Technology Corporation. Abstract: ... the number of classes of an image, there is an exponential.

A Fast and Efficient Algorithm for Low-rank ... - Semantic Scholar
The Johns Hopkins University [email protected]. Thong T. .... time O(Md + (n + m)d2) where M denotes the number of non-zero ...... Computer Science, pp. 143–152 ...

A Fast and Efficient Algorithm for Low-rank ... - Semantic Scholar
republish, to post on servers or to redistribute to lists, requires prior specific permission ..... For a fair comparison, we fix the transform matrix to be. Hardarmard and set .... The next theorem is dedicated for showing the bound of d upon which

a niche based genetic algorithm for image ... - Semantic Scholar
Image registration can be regarded as an optimization problem, where the goal is to maximize a ... genetic algorithms can address this problem. However ..... This is akin to computing the cosine ... Also partial occlusions (e.g. clouds) can occur ...

An efficient blind modulation detection algorithm ... - Semantic Scholar
distance is proposed for OFDM based wireless communication systems. ... sub-carriers are grouped together, and adaptation is performed on the entire ...

An Entropy-based Weighted Clustering Algorithm ... - Semantic Scholar
Email: forrest.bao @ gmail.com ... network, a good dominant set that each clusterhead handles .... an award to good candidates, preventing loss of promising.

1 feature subset selection using a genetic algorithm - Semantic Scholar
Department of Computer Science. 226 Atanaso Hall. Iowa State ...... He holds a B.S. in Computer Science from Sogang University (Seoul, Korea), and an M.S. in ...

A Fast Greedy Algorithm for Outlier Mining - Semantic Scholar
Thus, mining for outliers is an important data mining research with numerous applications, including credit card fraud detection, discovery of criminal activities in.

Modified Contrast Compensation Algorithm for Noisy ...
Noel Thomas,IJRIT ... Noel Thomas1, Shajin Prince2 ..... [5] B. R. Lim, R. H. Park, and S. H. Kim, “High Dynamic Range for Contrast Enhancement,” IEEE Trans.

Modified Model Reference Adaptive Control Algorithm ...
Sep 30, 2004 - The modified algorithm is firstly tested on the MCS system in a ... MRAC system (based on the Lyapunov rule) has the same problem of gain 'wind up' ...... H. K., 1992, Nonlinear Systems (Macmillan: New York). [31] BROGAN, L. W., 1991,