IMP

import java.util.regex.Matcher;

import java.util.regex.Pattern;


public class Sort {

public Sort(String sentence) 

{

String questions = "(what |when |why |which |who |how |whose |whom |where )";

String helpingVerbs = "(is |am |are |was |were |being |been |be |have |has |had |do |does |did |will |would |shall |should |may |might |must |can |could )";

String normalPersons = "(i |me |my |mine |he |she |it |his |her |its |we |us |our |ours |they |them |their |theirs)";

String devicePersons = "(you |your |yours)";

String unknown = "((([a-zA-Z\\s]+)?+)?|([a-zA-Z\\s]+)?)?";

String regexToSearch = unknown + questions + helpingVerbs + normalPersons+ unknown;

String regexToMe = unknown + questions + helpingVerbs + devicePersons+ unknown;

Pattern checkRegex = Pattern.compile(regexToSearch);

Matcher regexMatcher = checkRegex.matcher(sentence);

if(sentence.matches(regexToSearch)) 

{

System.out.println("Search");

}else if(sentence.matches(regexToMe)) 

{

System.out.println("Me");

}

/* while(regexMatcher.find()) 

{

if(regexMatcher.group().length() != 0) 

{

System.out.println(regexMatcher.group().trim());

}

}*/

}

}

Comments

Popular posts from this blog

PyCharm Project

Android Eclipse Project L.O.R.A

APP