public void run ( R row , String value , int distinctCount ) { final List < Token > tokens ; boolean match = false ; try { tokens = _tokenizer . tokenize ( value ) ; } catch ( RuntimeException e ) { throw new IllegalStateException ( "Error occurred while tokenizing value: " + value , e ) ; } final String patternCode = getPatternCode ( tokens ) ; Set < TokenPattern > patterns ; synchronized ( this ) { patterns = _patterns . get ( patternCode ) ; if ( patterns == null ) { patterns = new HashSet < TokenPattern > ( ) ; _patterns . put ( patternCode , patterns ) ; } for ( TokenPattern pattern : patterns ) { if ( pattern . match ( tokens ) ) { storeMatch ( pattern , row , value , distinctCount ) ; match = true ; } } if ( ! match ) { final TokenPattern pattern ; try { pattern = new TokenPatternImpl ( value , tokens , _configuration ) ; } catch ( RuntimeException e ) { throw new IllegalStateException ( "Error occurred while creating pattern for: " + tokens , e ) ; } storeNewPattern ( pattern , row , value , distinctCount ) ; patterns . add ( pattern ) ; } } }
This method should be invoked by the user of the PatternFinder . Invoke it for each value in your dataset . Repeated values are handled correctly but if available it is more effecient to handle only the distinct values and their corresponding distinct counts .