Pattern Matching : The match will be accomplished by comparing the the two structures and testing for equality among the corresponding parts. Pattern matching is used to find the pattern p is present to given string or not. Pattern matching using the Matching Substring: Matching Substring : Many of the representation structures are just character strings, a basic function required in many match algorithm is that a substring s2 consisting of m characters . Where as string s1 of n characters where m<=n.
Approach to solving pattern matching: A direct approach to solving this problem is to compare the two stings character by character , starting with the first character of both s1 and s2. If any two characters disagree then process is repeated and starting with the second character of s1 and matching again against s2 character by character until a match found or disagreement occurs. This process continues until a Match occurs or s1 has no more characters.
Example:- Main String: DATASTRUCTURE Substring : STRU Here matching S With D doesn’t match move main string one position ahead compare S with A doesn’t match move main string ahead…..so on.
Partial Matching : For many AI applications complete matching between two or more structures is inappropriate. In partial matching meaning is same but terminology is different. For eg. Input representation of speech waveforms or visual scenes may have been corrupted by the noise or other unwanted distortions. Partial matching may require finding a match between certain key elements.
Eg. Of partial Matching: “I prefer low –calorie choice”. “I want the low-calorie Item”. “The low –calorie one please” In above all statements meaning same but terminology different.