Skip to content

Commit

Permalink
if answer has same rating in two or three answer it wont guess you wi…
Browse files Browse the repository at this point in the history
…ll guess the answer

removed "." from option for better matching (it might mis behave )
  • Loading branch information
rollychop committed Mar 29, 2020
1 parent fc63f6d commit eea6217
Show file tree
Hide file tree
Showing 5 changed files with 56 additions and 20 deletions.
44 changes: 30 additions & 14 deletions app/src/main/java/ai/loko/hk/ui/answers/Engine.java
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ synchronized public String search() {

Document doc = Jsoup.connect(BASE_URL + URLEncoder.encode(question, "UTF-8") + "&num=20").userAgent(Data.USER_AGENT).get();

String text = doc.body().text().toLowerCase();
String text = doc.body().text().toLowerCase().replace("."," ");
String optionAsplit[] = optionA.split(" ");
aSize = optionAsplit.length;

Expand Down Expand Up @@ -284,7 +284,10 @@ private String fallbackSearch(boolean isNeg) {

private String setAnswer(boolean isNeg) {
if (!isNeg) {
if (a > b) {
if (a==b&&b==c){
optionRed = "abc";//if answer has same rating answer color will be black
}
else if (a > b) {
if (c > a) {
optionRed = "c";
} else {
Expand All @@ -298,21 +301,34 @@ private String setAnswer(boolean isNeg) {
optionRed = "c";
}
} else {
if (a < b) {
if (c < a) {
//c is most least
optionRed = "c";
if (a==b && b==c){
optionRed="abc";/* if a,b and c has same rating means no ans*/
}
else if (a==b && a<c){
optionRed="ab";/* a and b has same rating but less than c ans may be a or b*/
}else if (a==c && a<b){
optionRed="ac";/* a and c has same rating but less than b*/
}else if(b==c && b<a){
optionRed="bc";/* b and c has same rating but less than a*/
}
else {
if (a < b) {
if (c < a) {
//c is most least
optionRed = "c";
} else {
//a is most least
optionRed = "a";
}
} else if (b < c) {
//b is least
optionRed = "b";
} else {
//a is most least
optionRed = "a";
//c is least
optionRed = "c";
}
} else if (b < c) {
//b is least
optionRed = "b";
} else {
//c is least
optionRed = "c";
}

}

return optionRed;
Expand Down
6 changes: 3 additions & 3 deletions app/src/main/java/ai/loko/hk/ui/model/Question.java
Original file line number Diff line number Diff line change
Expand Up @@ -52,9 +52,9 @@ public Question(String questionText, String optionA, String optionB, String opti
this.questionText = questionText.substring(0, questionText.length() - 1).toLowerCase();
} else
this.questionText = questionText.toLowerCase();
this.optionA = optionA.toLowerCase();
this.optionB = optionB.toLowerCase();
this.optionC = optionC.toLowerCase();
this.optionA = optionA.toLowerCase().replace(".","");
this.optionB = optionB.toLowerCase().replace(".","");
this.optionC = optionC.toLowerCase().replace(".","");
}

public String getQuestionText() {
Expand Down
20 changes: 20 additions & 0 deletions app/src/main/java/ai/loko/hk/ui/services/OCRFloating.java
Original file line number Diff line number Diff line change
Expand Up @@ -282,6 +282,26 @@ protected void onPostExecute(final String s) {
option1.setTextColor(Color.BLACK);
option2.setTextColor(Color.BLACK);
break;
case "ab":
option1.setTextColor(Color.RED);
option2.setTextColor(Color.RED);
option3.setTextColor(Color.BLACK);
break;
case "ac":
option1.setTextColor(Color.RED);
option2.setTextColor(Color.BLACK);
option3.setTextColor(Color.RED);
break;
case "bc":
option1.setTextColor(Color.BLACK);
option2.setTextColor(Color.RED);
option3.setTextColor(Color.RED);
break;
case "abc":
option1.setTextColor(Color.BLACK);
option2.setTextColor(Color.BLACK);
option3.setTextColor(Color.BLACK);
break;
}
} else if (questionAndOption.length > 0) {
Toast.makeText(getApplicationContext(), questionAndOption[0], Toast.LENGTH_SHORT).show();
Expand Down
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ buildscript {
}
}
dependencies {
classpath 'com.android.tools.build:gradle:3.5.2'
classpath 'com.android.tools.build:gradle:3.2.1'
// NOTE: Do not place your application dependencies here; they belong
// in the individual module build.gradle files
classpath 'com.google.gms:google-services:4.2.0'
Expand Down
4 changes: 2 additions & 2 deletions gradle/wrapper/gradle-wrapper.properties
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
#Sun Nov 03 14:45:03 IST 2019
#Sun Mar 29 11:22:16 IST 2020
distributionBase=GRADLE_USER_HOME
distributionPath=wrapper/dists
zipStoreBase=GRADLE_USER_HOME
zipStorePath=wrapper/dists
distributionUrl=https\://services.gradle.org/distributions/gradle-5.4.1-all.zip
distributionUrl=https\://services.gradle.org/distributions/gradle-5.6.4-all.zip

0 comments on commit eea6217

Please sign in to comment.