Android Open Source - wherewithal Scoring






From Project

Back to project page wherewithal.

License

The source code is released under:

GNU General Public License

If you think the Android project wherewithal listed in this page is inappropriate, such as containing malicious code/tools or violating the copyright, please email info at java2s dot com, thanks.

Java Source Code

package com.curchod.domartin;
/*from w ww.j a va2s.c  o  m*/
import java.util.Hashtable;

import android.util.Log;

public class Scoring 
{
  
  private static final String DEBUG_TAG = "Scoring";
  
  public static String applyOptions(Hashtable <String,String>user_options, String text)
  {
    if (user_options == null)
    {
      user_options = defaultOptions();
    }
    String grade_whitespace = (String)user_options.get("grade_whitespace");
    String exclude_chars = (String)user_options.get("exclude_chars");
    String exclude_area = (String)user_options.get("exclude_area");
    String exclude_area_begin_char = (String)user_options.get("exclude_area_begin_char");
    String exclude_area_end_char = (String)user_options.get("exclude_area_end_char");
    //String alternate_answer_separator = (String)user_options.get("alternate_answer_separator");
    if (grade_whitespace.equals("false"))
    {
      text = text.replace(" ", "");
    }
    if (exclude_area.equals("true"))
    {
      text = excludeArea(exclude_area_begin_char, exclude_area_end_char, text);
    }
    if (exclude_chars.length()>0)
    {
      text = removeExcludeChars(text, exclude_chars);
    }
    return text;
  }
  
  public static String removeExcludeChars(String text, String exclude_chars)
  {
    int i = 0;
    int size = exclude_chars.length();
    while (i<size)
    {
      String c = exclude_chars.substring(i, i+1);
      if (text.contains(c))
      {
        text = text.replace(c, "");
      }
      i++;
    }
    return text;
  }
  
  private static String excludeArea(String exclude_area_begin, String exclude_area_end, String text)
  {
    String first_part = new String();
    int first = text.indexOf(exclude_area_begin);
    int last = text.lastIndexOf(exclude_area_end);
    int length = text.length();
    try
    {
      first_part = text.substring(0, first);
      if (length != last)
      {
        String last_part = text.substring(last+1, length);
        first_part = first_part.concat(last_part);
      }
    } catch (java.lang.StringIndexOutOfBoundsException sioob)
    {
      first_part = text;
    }
    return first_part;
  }
  
  public static boolean scoreAnswer(String question, String answer)
  {
    String method = "scoreAnswer";
    answer = Scoring.applyOptions(null, answer);
    answer = Scoring.applyOptions(null, answer);
    Log.i(DEBUG_TAG, method+" answer  after apply options "+answer);
    Log.i(DEBUG_TAG, method+" correct after apply options "+answer);
    if (answer.equals(answer))
    { 
      Log.i(DEBUG_TAG, method+" correct");
      return true;
    }
    Log.i(DEBUG_TAG, method+" incorrect!");
    return false;
  }
  
  private static Hashtable<String,String> defaultOptions()
  {
    Hashtable <String,String> user_options = new Hashtable <String,String>();
    user_options.put("grade_whitespace","false");
    user_options.put("max_level","3");
    user_options.put("exclude_chars",".~!@#$%^*()_+-=?'\";/:-//");
    user_options.put("exclude_area","true");
    user_options.put("exclude_area_begin_char","[");
    user_options.put("exclude_area_end_char","]");
    user_options.put("alternate_answer_separator","");
    return user_options;
  }

}




Java Source Code List

com.curchod.domartin.AsyncLoadGameFile.java
com.curchod.domartin.Constants.java
com.curchod.domartin.Filer.java
com.curchod.domartin.HouseDeck.java
com.curchod.domartin.IWantTo.java
com.curchod.domartin.MockNdefMessages.java
com.curchod.domartin.NfcUtils.java
com.curchod.domartin.RemoteCall.java
com.curchod.domartin.Sarray.java
com.curchod.domartin.Scoring.java
com.curchod.domartin.TagDescription.java
com.curchod.domartin.UtilityTo.java
com.curchod.dto.Card.java
com.curchod.dto.DeckCard.java
com.curchod.dto.GameWord.java
com.curchod.dto.Game.java
com.curchod.dto.PlayerInfo.java
com.curchod.dto.SavedTest.java
com.curchod.dto.SingleWordTestResult.java
com.curchod.dto.SingleWord.java
com.curchod.json.VocabularyDefinition.java
com.curchod.json.VocabularyLearningObject.java
com.curchod.wherewithal.AddPlayerActivity.java
com.curchod.wherewithal.CardDeckActivity.java
com.curchod.wherewithal.CardDecksActivity.java
com.curchod.wherewithal.CardPlayerHouseDeckActivity.java
com.curchod.wherewithal.CardPlayerWordsActivity.java
com.curchod.wherewithal.CardPlayersListActivity.java
com.curchod.wherewithal.CardsActivity.java
com.curchod.wherewithal.GameConcentrationActivity.java
com.curchod.wherewithal.GameReadingStonesActivity.java
com.curchod.wherewithal.GameReadingStonesInstructionsActivity.java
com.curchod.wherewithal.GameSnazzyThumbworkActivity.java
com.curchod.wherewithal.GameWritingStonesActivity.java
com.curchod.wherewithal.GamesActivity.java
com.curchod.wherewithal.InstructionsActivity.java
com.curchod.wherewithal.MainActivity.java
com.curchod.wherewithal.PlayerActivity.java
com.curchod.wherewithal.PlayersActivity.java