src/controller/WebSearchEngine.java
/*using regex to find similar string to pattern */
using regex to find similar string to pattern
using regex to find similar string to pattern
private static void alternativeWord(String p1) {
		try {
			String line = " ";
			String pattern3 = "[a-zA-Z0-9]+";
			Pattern r3 = Pattern.compile(pattern3);
			Matcher m3 = r3.matcher(line);
			int _fileNumber=0;
			File _directory = new File(System.getProperty("user.dir")+"\\src\\ConvertedTextFiles\\");
			File[] _fileArray = _directory.listFiles();
			for(int i=0;i<100;i++)
			{
				findData(_fileArray[i],_fileNumber,m3,p1);
				_fileNumber++;
			}
			Set<?> keys = new HashSet<Object>();
			Integer value =1;
			Integer val = 0;
			System.out.print(">>Did you mean?\n>>");
			for(Map.Entry entry: numbers.entrySet()){
				if(val == entry.getValue()) {
					break;
				}
				else {
					if(value==entry.getValue()){
						System.out.print(entry.getKey()+"  ");
					}
				}
			}
		}
		catch(Exception e){
			System.out.println(">>Exception on alternativeWord: "+e);
		}
	}
private static void alternativeWord ( String p1 ) { try { String line = " " ; String pattern3 = "[a-zA-Z0-9]+" ; Pattern r3 = Pattern . compile ( pattern3 ) ; Matcher m3 = r3 . matcher ( line ) ; int _fileNumber = 0 ; File _directory = new File ( System . getProperty ( "user.dir" ) + "\\src\\ConvertedTextFiles\\" ) ; File [ ] _fileArray = _directory . listFiles ( ) ; for ( int i = 0 ; i < 100 ; i ++ ) { findData ( _fileArray [ i ] , _fileNumber , m3 , p1 ) ; _fileNumber ++ ; } Set < ? > keys = new HashSet < Object > ( ) ; Integer value = 1 ; Integer val = 0 ; System . out . print ( ">>Did you mean?\n>>" ) ; for ( Map . Entry entry : numbers . entrySet ( ) ) { if ( val == entry . getValue ( ) ) { break ; } else { if ( value == entry . getValue ( ) ) { System . out . print ( entry . getKey ( ) + "  " ) ; } } } } catch ( Exception e ) { System . out . println ( ">>Exception on alternativeWord: " + e ) ; } }
using regex to find similar string to pattern
using regex to find similar string to pattern
// String to be scanned to find the pattern. // Create a Pattern object. // Now create matcher object.