java - How to determine if a string is English sentence or code? -
java - How to determine if a string is English sentence or code? -
consider next 2 strings, first 1 code, sec 1 english language sentence (phrase precise). how can observe first 1 code , sec not.
1. (int = 0; < b.size(); i++) { 2. in english language (not necessary sentence).
i'm thinking counting special characters (such "=", ";", "++", etc ), , set if threshold. there improve ways this? java libraries?
note code may not parsable, because not finish method/statement/expression.
my assumption english language sentences pretty regular, contains ",", ".", "_", "(", ")", etc. not contains this: write("the whole lot of text");
the basic thought convert string set tokens. example, code line above may become "key,separator,id,assign,number,separator,...". , can utilize simple rules separate code english.
check out code here
java string nlp
Comments
Post a Comment