Commit 5fe4b1ee authored by IT17165662's avatar IT17165662

Merge remote-tracking branch 'origin/master'

# Conflicts:
#	app/build.gradle
#	app/src/main/java/com/elearning/probabilityandstatisticsanalyserandeducator/dataExtraction/DescriptiveStatisticsQuestionComparation.java
#	app/src/main/java/com/elearning/probabilityandstatisticsanalyserandeducator/inputMethod/DescriptiveSCinputMethod.java
#	app/src/main/java/com/elearning/probabilityandstatisticsanalyserandeducator/inputMethod/StandardDeviationInputMethod.java
parents 75e23879 cc47c8bc
......@@ -18,7 +18,7 @@ public class DBConnection {
Connection connection = null;
public DBConnection(){
sever ="192.168.1.6/MSSQLSEVER";
sever ="192.168.43.229/MSSQLSEVER";
username ="sa";
Pass = "sa@123";
database ="ProbabilityDB";
......
......@@ -17,16 +17,49 @@ public class AdaptiveQuestionGenarator {
public Question GenarateQuestions(int counter, boolean isAnsCorrect, long timer ){
public Question GenarateQuestions(int counter, boolean isAnsCorrect, long timer, int selected_Question_Type ){
this.counter = counter;
this.isAnsCorrect = isAnsCorrect;
this.timer = timer;
QuizDbHelper dbHelper = new QuizDbHelper();
questionList = dbHelper.getAllInitialQuestion();
easyQuestionList = dbHelper.genarateEasyQuestions();
moderateQuestionList = dbHelper.genarateModerateQuestions();
hardQuestionList = dbHelper.genarateHardQuestions();
if (selected_Question_Type == 0){
questionList = dbHelper.getAllInitialQuestion();
easyQuestionList = dbHelper.genarateEasyQuestions();
moderateQuestionList = dbHelper.genarateModerateQuestions();
hardQuestionList = dbHelper.genarateHardQuestions();
}else if (selected_Question_Type == 1){
questionList = dbHelper.getAllDescriptiveStatisticsQuestion();
easyQuestionList = dbHelper.genarateDescriptiveStatisticsEasyQuestions();
moderateQuestionList = dbHelper.genarateModerateDescriptiveStatisticsQuestions();
hardQuestionList = dbHelper.genarateHardDescriptiveStatisticsQuestions();
}else if (selected_Question_Type == 2){
questionList = dbHelper.StandardDeviationGetAllQuestion();
easyQuestionList = dbHelper.StandardDeviationgenarateEasyQuestions();
moderateQuestionList = dbHelper.StandardDeviationGenarateModerateQuestions();
hardQuestionList = dbHelper.StandardDeviationGenarateHardQuestions();
}else if (selected_Question_Type == 3){
questionList = dbHelper.ProbabilityGetAllInitialQuestion();
easyQuestionList = dbHelper.ProbabilityGenarateEasyQuestions();
moderateQuestionList = dbHelper.ProbabilityGenarateModerateQuestions();
hardQuestionList = dbHelper.ProbabilityGenarateHardQuestions();
}else if (selected_Question_Type == 4){
questionList = dbHelper.ProbabilityDistributionGetAllQuestion();
easyQuestionList = dbHelper.ProbabilityDistributionGenarateEasyQuestions();
moderateQuestionList = dbHelper.ProbabilityDistributionGenarateModerateQuestions();
hardQuestionList = dbHelper.ProbabilityDistributionGenarateHardQuestions();
}else if (selected_Question_Type == 5){
questionList = dbHelper.Z_ScoreGetAllInitialQuestion();
easyQuestionList = dbHelper.Z_ScoreGenarateEasyQuestions();
moderateQuestionList = dbHelper.Z_ScoreGenarateModerateQuestions();
hardQuestionList = dbHelper.Z_ScoreGenarateHardQuestions();
}else if (selected_Question_Type == 6){
questionList = dbHelper.NormalDistributionGetAllInitialQuestion();
easyQuestionList = dbHelper.NormalDistributionGenarateEasyQuestions();
moderateQuestionList = dbHelper.NormalDistributionGenarateModerateQuestions();
hardQuestionList = dbHelper.Z_ScoreGenarateHardQuestions();
}
Collections.shuffle(questionList);
Collections.shuffle(easyQuestionList);
......
......@@ -135,6 +135,7 @@ public class DashBoardHome extends Fragment {
probability_deistribu.setBackground(getDrawable(getContext(),R.drawable.bg_item));
z_score.setBackground(getDrawable(getContext(),R.drawable.bg_item));
normal_distribu.setBackground(getDrawable(getContext(),R.drawable.bg_item));
SELECTED_QUESTION_TYPE = 0;
dashbord_continur.setAlpha(0);
dashboard_cancel.setAlpha(0);
}
......@@ -145,6 +146,8 @@ public class DashBoardHome extends Fragment {
public void onClick(View view) {
Intent intent = new Intent(getContext(),StartingScreen.class);
intent.putExtra("Selected_Question_type",SELECTED_QUESTION_TYPE);
startActivity(intent);
}
......
......@@ -37,6 +37,8 @@ public class QuizActivity extends AppCompatActivity {
private String answerNr = "notAnswerd";
private int userID;
static int SELECT_QUESTION_TYPE = 0;
// assigning times and dates variable
private String strtingTime;
private String examDate;
......@@ -95,6 +97,10 @@ public class QuizActivity extends AppCompatActivity {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_quiz);
Intent intent = getIntent();
SELECT_QUESTION_TYPE = intent.getIntExtra("Selected_Question_type",0);
System.out.println("Selected_Question_type_Quiz "+SELECT_QUESTION_TYPE);
SessionManager sessionManager = new SessionManager(this);
HashMap<String,String> userDetails = sessionManager.getUserDetailsFromSession();
......@@ -200,7 +206,34 @@ public class QuizActivity extends AppCompatActivity {
if (questionCounter < questionCountTotal){
currentQuestion = adaptiveQuestionGenarator.GenarateQuestions(questionCounter,isAnswerCorrect,answeredTime);
switch (SELECT_QUESTION_TYPE){
case 0:
currentQuestion = adaptiveQuestionGenarator.GenarateQuestions(questionCounter,isAnswerCorrect,answeredTime,SELECT_QUESTION_TYPE);
break;
case 1:
currentQuestion = adaptiveQuestionGenarator.GenarateQuestions(questionCounter,isAnswerCorrect,answeredTime,SELECT_QUESTION_TYPE);
break;
case 2:
currentQuestion = adaptiveQuestionGenarator.GenarateQuestions(questionCounter,isAnswerCorrect,answeredTime,SELECT_QUESTION_TYPE);
break;
case 3:
currentQuestion = adaptiveQuestionGenarator.GenarateQuestions(questionCounter,isAnswerCorrect,answeredTime,SELECT_QUESTION_TYPE);
break;
case 4:
currentQuestion = adaptiveQuestionGenarator.GenarateQuestions(questionCounter,isAnswerCorrect,answeredTime,SELECT_QUESTION_TYPE);
break;
case 5:
currentQuestion = adaptiveQuestionGenarator.GenarateQuestions(questionCounter,isAnswerCorrect,answeredTime,SELECT_QUESTION_TYPE);
break;
case 6:
currentQuestion = adaptiveQuestionGenarator.GenarateQuestions(questionCounter,isAnswerCorrect,answeredTime,SELECT_QUESTION_TYPE);
break;
}
//get current question marks
allocatedMark = currentQuestion.getAllocatedMarks();
......
......@@ -20,12 +20,17 @@ public class StartingScreen extends AppCompatActivity {
private TextView textViewHighscore;
private int highscore;
static int SELECT_QUESTION_TYPE = 0;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_starting_screen);
Intent intent = getIntent();
SELECT_QUESTION_TYPE = intent.getIntExtra("Selected_Question_type",0);
System.out.println("Selected_Question_type "+SELECT_QUESTION_TYPE);
//assign text view
//we load the highscor from shared Prefrenc and set it value to textView
textViewHighscore = findViewById(R.id.text_view_highscore);
......@@ -41,6 +46,7 @@ public class StartingScreen extends AppCompatActivity {
}
private void Start() {
Intent intent = new Intent(StartingScreen.this, QuizActivity.class);
intent.putExtra("Selected_Question_type",SELECT_QUESTION_TYPE);
startActivityForResult(intent, REQUEST_CODE_QUIZ);
}
......
......@@ -7,6 +7,8 @@ import com.chaquo.python.Python;
import com.elearning.probabilityandstatisticsanalyserandeducator.R;
import com.elearning.probabilityandstatisticsanalyserandeducator.inputMethod.DescriptiveSCinputMethod;
import org.w3c.dom.ls.LSOutput;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
......@@ -26,13 +28,16 @@ public class DescriptiveStatisticsQuestionComparation {
DescriptiveSCinputMethod DescriptiveSCinputMethod;
String a="Find mean, median for 15, 18, 21, 22, 26, 28, 31, 39";
public String DescriptiveStatisticsQuestionComparewithCSV(String Descriptivestatisticsquestions, List<String> reading) {
System.out.println("reading des questions in dsqc "+reading);
String[] keywordlist = {"mean","median","mode","total","dataset","range","average","number of","population","sample","parameter","sample size","quartiles","first quartile","second quartile","third quartile","Q1","Q2","Q3","upper quartile","lower quartile","Inter quartile range","IQR","maximum","minimum"};
String[] keywordlist = {"first","First","second","Second","third","Third","inter","Inter","quartiles","Quartiles","range","Range","mean","Mean","x̄","μ","median","Median","mode","Mode","total","Total","dataset","Dataset","set","Set","series","Series","Data","data","average","Average","number of","Number of","population","Population","sample","Sample","parameter","Parameter","sample size","Sample size","first quartile","First Quartile","second quartile","Second Quartile","third quartile","Third Quartile","Q1","Q2","Q3","upper quartile","Upper Quartile","lower quartile","Lower Quartile","Inter quartile range","Interquartile Range","inter quartile range","IQR","maximum","Maximum","minimum","Minimum"};
String b="Determine the mean median and modal values for the set 3, 8, 10, 7, 5, 14, 2, 9, 8";
//System.out.println("value passing from python"+b);
List<String> questions ;
List<String> matchkeyword = new ArrayList<>();
......@@ -61,7 +66,7 @@ public class DescriptiveStatisticsQuestionComparation {
String result=obj.toString();
String result1=obj1.toString();
System.out.println("output matching: "+result);
//System.out.println("output matching: "+result);
System.out.println("matching: "+result1);
matchkeyword = QuestionMatch(result);
......@@ -133,9 +138,10 @@ public class DescriptiveStatisticsQuestionComparation {
List<String> extractnumbervalues = new ArrayList<String>();
Pattern pattern1 = Pattern.compile("((?<!^,)\\d+(,(?!$)|$))+.\\d+");
Matcher matcher1 = pattern1.matcher(question);
boolean value1 = matcher1.matches();
Pattern pattern1 = Pattern.compile("(?<=\\s)\\d++(?!\\.\\b)");
Matcher matcher1 = pattern1.matcher(question);
boolean value1 = matcher1.matches();
while (matcher1.find()) {
System.out.println("'" + matcher1.group().trim() + "'");
......
......@@ -23,6 +23,7 @@ public class ExtractData {
word = s.toString().trim();
String data1 = word;
Pattern pattern2 = Pattern.compile("\\b(\\d|\\.)+(,(\\d|\\.)+)*\\b|\\b(\\d|\\.)+(\\s(\\d|\\.)+)*\\b|\\b(\\d|\\.)+(;(\\d|\\.)+)*\\b|\\b(\\d|\\.)+(:(\\d|\\.)+)*\\b");
s.replaceAll("\\s","");
......
package com.elearning.probabilityandstatisticsanalyserandeducator.dataExtraction;
public class StandardDeviationCSVfile {
private String question;
public String getQuestion() {
return question;
}
public void setQuestion(String question) {
this.question = question;
}
}
package com.elearning.probabilityandstatisticsanalyserandeducator.dataExtraction;
import com.chaquo.python.PyObject;
import com.chaquo.python.Python;
import com.elearning.probabilityandstatisticsanalyserandeducator.inputMethod.DescriptiveSCinputMethod;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
public class StandardDeviationQuestionComparation {
Python py=null;
String a="Find the standard deviation for the following data series: 12, 6, 7, 3, 15, 10, 18, 5";
public String StandardDeviationQuestionComparewithCSV(String Standarddeviationquestions, List<String> reading) {
System.out.println("reading std questions in standard deviation "+reading);
String[] keywordlist = {"Standard","standard","Deviation","deviation","Standard Deviation","standard deviation","Variance","variance","Skewness","skewness","Kurtosis","kurtosis","sample size","number of","population","Population","mean","Mean","parameter","sample proportion","square root","sum of square","average of square","SS","Sampling distribution","sampling distribution","proportion","mean","dataset","dispersion","spread","σ²","σ","s²","s","SD","sd","symmetric"};
String b="Calculate the standard deviation for the following population of scores: 8 5 3 7 5 6 4 7 2 6 5 3 6 4 5 7 8 6 5 6";
List<String> questions ;
List<String> matchstdkeyword = new ArrayList<>();
questions= reading;
String[] dataReader = new String[questions.size()];
questions.toArray(dataReader);
for (int i=0; i<dataReader.length; i++){
// System.out.println("print array " + dataReader[i]);
}
//System.out.println("arrayData "+Arrays.toString(questions));
String questionlist = "";
for (String s : questions){
questionlist += s + "\t";
}
py = Python.getInstance();
PyObject pyo2 = py.getModule("stdquestion");
PyObject pyo21 = py.getModule("standarddeviation_keywords");
PyObject obj2 = pyo2.callAttr("main",a,dataReader);
PyObject obj21 = pyo21.callAttr("matchkeyword",keywordlist,Standarddeviationquestions);
String result2=obj2.toString();
String result21=obj21.toString();
//System.out.println("output matching for std: "+result2);
System.out.println("matching keywords for std: "+result21);
matchstdkeyword = QuestionMatch(result2);
return result21;
}
private List<String> readStdQuestions(InputStream in){
String[] printQuestion = new String[500];
List<StandardDeviationCSVfile> stdQuestions= new ArrayList<>();
List<String> StringstdQuestions= new ArrayList<>();
BufferedReader reader = new BufferedReader(
new InputStreamReader(in, Charset.forName("UTF-8"))
);
String line = "";
try {
while ((line = reader.readLine()) != null) {
//Split by '"'
String tokens = line;
//Read the csv
StandardDeviationCSVfile question = new StandardDeviationCSVfile();
question.setQuestion(tokens);
stdQuestions.add(question);
StringstdQuestions.add(tokens);
//printQuestion[lines] = line;
//Log.d("MyActivity", "Just created: " + question);
}
} catch (IOException e) {
// Log.wtf("MyActivity", "Error reading data file on line " + line, e);
e.printStackTrace();
}
finally {
try {
reader.close();
}catch (IOException e) {
e.printStackTrace();
}
}
return StringstdQuestions;
}
String data;
public List<String> QuestionMatch(String highest) {
int counter = 0;
List<String> wordlist = new ArrayList<String>();
List<String> matchword = new ArrayList<String>();
List<String> valueAccordingtoLine = new ArrayList<>();
String word;
// System.out.println("value for meaning of the keyword "+valueAccordingtoLine);
return valueAccordingtoLine;
}
public List<String> ExtractDatasetFromStdQuestion(String question) {
List<String> extractnumbervalues = new ArrayList<String>();
Pattern pattern1 = Pattern.compile("(?<=\\s)\\d++(?!\\.\\b)");
Matcher matcher1 = pattern1.matcher(question);
boolean value1 = matcher1.matches();
while (matcher1.find()) {
System.out.println("'" + matcher1.group().trim() + "'");
extractnumbervalues.add(matcher1.group().trim());
}
System.out.println("matched data set of extract in std "+extractnumbervalues);
return extractnumbervalues;
}
}
......@@ -38,6 +38,8 @@ import com.elearning.probabilityandstatisticsanalyserandeducator.calculationfunc
import com.elearning.probabilityandstatisticsanalyserandeducator.dataExtraction.DescriptiveStatisticsCSVfile;
import com.elearning.probabilityandstatisticsanalyserandeducator.dataExtraction.DescriptiveStatisticsQuestionComparation;
import com.elearning.probabilityandstatisticsanalyserandeducator.dataExtraction.ExtractData;
import com.elearning.probabilityandstatisticsanalyserandeducator.dataExtraction.StandardDeviationCSVfile;
import com.elearning.probabilityandstatisticsanalyserandeducator.dataExtraction.StandardDeviationQuestionComparation;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.googlecode.tesseract.android.TessBaseAPI;
import com.theartofdev.edmodo.cropper.CropImage;
......@@ -113,6 +115,8 @@ public class DescriptiveSCinputMethod extends AppCompatActivity {
textInput = findViewById(R.id.keyboard_Input);
rg_01 = findViewById(R.id.rg_01);
rg_02 = findViewById(R.id.rg_02);
......@@ -276,80 +280,90 @@ public class DescriptiveSCinputMethod extends AppCompatActivity {
calculate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//getting calculation type by radio butons
String selectedType = selectedRadioButton.getText().toString();
// destroy the speech recognition instance
speechRecognizer.destroy();
String selectedType = null;
// -------------**** getting the final input from edit text
String output = textInput.getText().toString().trim();
if (selectedRadioButton == null) {
Toast.makeText(DescriptiveSCinputMethod.this, "You must Select A Question Type", Toast.LENGTH_SHORT).show();
} else {
if (extractedData.size() == 0){
extractedData.add(output); // adding data to List
}
System.out.println("ExctractedData list size "+ extractedData.size());
//getting calculation type by radio butons
selectedType = selectedRadioButton.getText().toString();
// adding List to array in order to pass to ExtractData function
String[] dataArray = new String[extractedData.size()];
dataArray = extractedData.toArray(dataArray);
// destroy the speech recognition instance
speechRecognizer.destroy();
// -------------**** getting the final input from edit text
String output = textInput.getText().toString().trim();
if (extractedData.size() == 0) {
extractedData.add(output); // adding data to List
}
//list to receive the extrated data
List<String> extractedDataset;
System.out.println("ExctractedData list size " + extractedData.size());
// adding List to array in order to pass to ExtractData function
String[] dataArray = new String[extractedData.size()];
dataArray = extractedData.toArray(dataArray);
DescriptiveStatisticsQuestionComparation dsqc = new DescriptiveStatisticsQuestionComparation();
List<String> reading = readDesQuestions();
List<String> extractDatasetForEssay;
String[] extractDatasetForEssayArray = new String[0];
String extractedKeywordsFromFuzzy = null;
//list to receive the extrated data
List<String> extractedDataset;
if (selectedType.equals("Solve Essay problem")){
extractedKeywordsFromFuzzy = dsqc.DescriptiveStatisticsQuestionComparewithCSV(output,reading);
System.out.println("extractedKeywordsFromFuzzy "+extractedKeywordsFromFuzzy);
//--------------------extrct dataset from DescripticeStatsQuesCompare class using ExtractDatasetfromDescriptiveQuestion method -----------------------------
DescriptiveStatisticsQuestionComparation dsqc = new DescriptiveStatisticsQuestionComparation();
List<String> reading = readDesQuestions();
List<String> extractDatasetForEssay;
String[] extractDatasetForEssayArray = new String[0];
String extractedKeywordsFromFuzzy = null;
if (selectedType.equals("Solve Essay problem")) {
extractedKeywordsFromFuzzy = dsqc.DescriptiveStatisticsQuestionComparewithCSV(output, reading);
System.out.println("extractedKeywordsFromFuzzy " + extractedKeywordsFromFuzzy);
//--------------------extrct dataset from DescripticeStatsQuesCompare class using ExtractDatasetfromDescriptiveQuestion method -----------------------------
extractDatasetForEssay = dsqc.ExtractDatasetFromDescriptiveQuestion(output);
System.out.println("extractDatasetForEssay "+extractDatasetForEssay);
System.out.println("lengtheee:"+extractDatasetForEssay.size());
// Converting list to array after data extraction function
extractDatasetForEssayArray = new String[extractDatasetForEssay.size()];
extractDatasetForEssayArray = extractDatasetForEssay.toArray(extractDatasetForEssayArray);
}
// Converting list to array after data extraction function
extractDatasetForEssayArray = new String[extractDatasetForEssay.size()];
extractDatasetForEssayArray = extractDatasetForEssay.toArray(extractDatasetForEssayArray);
//calling the extract data function for normal question solvings
extractedDataset = extractData.ExtractionWithComma(dataArray);
}
//-------------------------------------------------------------------------------------------------------------------------------- remove lateer
// Converting list to array after daa extraction function
String[] datasetArray = new String[extractedDataset.size()];
datasetArray = extractedDataset.toArray(datasetArray);
//calling the extract data function for normal question solvings
extractedDataset = extractData.ExtractionWithComma(dataArray);
//-------------------------------------------------------------------------------------------------------------------------------- remove lateer
// System.out.println("selected Type "+selectedRadioButton.getText().toString());
Intent intent = new Intent(DescriptiveSCinputMethod.this, DescriptiveStatisticsCalcuation.class);
intent.putExtra("dataset",datasetArray);
intent.putExtra("des_calculation_type", selectedType);
// Converting list to array after daa extraction function
String[] datasetArray = new String[extractedDataset.size()];
datasetArray = extractedDataset.toArray(datasetArray);
if (selectedType.equals("Solve Essay problem")){
intent.putExtra("extractDatasetForEssayArray",extractDatasetForEssayArray);
intent.putExtra("extractedKeywordsFromFuzzy",extractedKeywordsFromFuzzy);
}
extractedDataset.clear();
datasetArray = null;
startActivity(intent);
// System.out.println("selected Type "+selectedRadioButton.getText().toString());
Intent intent = new Intent(DescriptiveSCinputMethod.this, DescriptiveStatisticsCalcuation.class);
intent.putExtra("dataset", datasetArray);
intent.putExtra("des_calculation_type", selectedType);
if (selectedType.equals("Solve Essay problem")) {
intent.putExtra("extractDatasetForEssayArray", extractDatasetForEssayArray);
intent.putExtra("extractedKeywordsFromFuzzy", extractedKeywordsFromFuzzy);
}
extractedDataset.clear();
datasetArray = null;
startActivity(intent);
}
}
});
......@@ -599,4 +613,6 @@ public void showMessege(){
}
\ No newline at end of file
......@@ -21,6 +21,7 @@ import android.speech.RecognizerIntent;
import android.speech.SpeechRecognizer;
import android.speech.tts.TextToSpeech;
import android.util.Log;
import android.view.View;
import android.view.animation.Animation;
import android.view.animation.AnimationUtils;
......@@ -39,17 +40,21 @@ import com.elearning.probabilityandstatisticsanalyserandeducator.R;
import com.elearning.probabilityandstatisticsanalyserandeducator.calculationfunction.DescriptiveStatisticsCalcuation;
import com.elearning.probabilityandstatisticsanalyserandeducator.calculationfunction.StandaradDeviationCalculation;
import com.elearning.probabilityandstatisticsanalyserandeducator.dataExtraction.ExtractData;
import com.elearning.probabilityandstatisticsanalyserandeducator.dataExtraction.StandardDeviationCSVfile;
import com.elearning.probabilityandstatisticsanalyserandeducator.dataExtraction.StandardDeviationQuestionComparation;
import com.google.android.material.floatingactionbutton.FloatingActionButton;
import com.googlecode.tesseract.android.TessBaseAPI;
import com.theartofdev.edmodo.cropper.CropImage;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileOutputStream;
import java.io.IOException;
import java.io.InputStream;
import java.io.InputStreamReader;
import java.io.OutputStream;
import java.nio.charset.Charset;
import java.util.ArrayList;
import java.util.List;
......@@ -69,7 +74,7 @@ public class StandardDeviationInputMethod extends AppCompatActivity {
List<String> extractedData;
Integer[] valuesTakenFromEditTextArray;
// ImageView imageView, img_greyview;
// ImageView imageView, img_greyview;
FloatingActionButton action_TakePhoto , action_UploadPhoto , action_voiceInput;
Button calculate;
TextView outputText;
......@@ -102,12 +107,12 @@ public class StandardDeviationInputMethod extends AppCompatActivity {
setContentView(R.layout.activity_standard_deviation);
// variable initialization
// imageView = findViewById(R.id.outImage);
// imageView = findViewById(R.id.outImage);
calculate = findViewById(R.id.btnTakeImage);
action_TakePhoto = findViewById(R.id.action_capturePhoto);
action_UploadPhoto = findViewById(R.id.action_uploadImage);
action_voiceInput = findViewById(R.id.action_voiceInput);
// img_greyview = findViewById(R.id.greyImg);
// img_greyview = findViewById(R.id.greyImg);
textInput = findViewById(R.id.keyboard_Input);
......@@ -274,36 +279,68 @@ public class StandardDeviationInputMethod extends AppCompatActivity {
calculate.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
//getting calculation type by radio butons
String selectedType = selectedRadioButton.getText().toString();
speechRecognizer.destroy();
String output = textInput.getText().toString().trim();
if (selectedRadioButton == null) {
Toast.makeText(StandardDeviationInputMethod.this, "You must Select A Question Type", Toast.LENGTH_SHORT).show();
} else {
if (extractedData.size() == 0){
extractedData.add(output); // adding data to List
}
//getting calculation type by radio butons
String selectedType = selectedRadioButton.getText().toString();
System.out.println("radio name "+ selectedType);
speechRecognizer.destroy();
String output = textInput.getText().toString().trim();
if (extractedData.size() == 0) {
extractedData.add(output); // adding data to List
}
// adding List to array in order to pass to ExtractData function
String[] dataArray = new String[extractedData.size()];
dataArray = extractedData.toArray(dataArray);
// adding List to array in order to pass to ExtractData function
String[] dataArray = new String[extractedData.size()];
dataArray = extractedData.toArray(dataArray);
//---------------------------------------------------------------------------------------------------
// --------------------------------- Use StandardDeviationQuestionComparation class methods --------------------------
//list to receive the extrated data
List<String> extractedDataset;
//list to receive the extrated data
List<String> extractedStdDataset;
//calling the extract data function
extractedDataset = extractData.ExtractionWithComma(dataArray);
StandardDeviationQuestionComparation stdqc = new StandardDeviationQuestionComparation();
List<String> reading1 = readStdQuestions();
List<String> extractDatasetForStdEssay;
String[] extractDatasetForEssayStdArray = new String[0];
// Converting list to array after daa extraction function
String[] datasetArray = new String[extractedDataset.size()];
datasetArray = extractedDataset.toArray(datasetArray);
String extractedStdKeywordsFromFuzzy = null;
if (selectedType.equals("Solve Essay problem")) {
extractedStdKeywordsFromFuzzy = stdqc.StandardDeviationQuestionComparewithCSV(output, reading1);
System.out.println("extractedStdKeywordsFromFuzzy " + extractedStdKeywordsFromFuzzy);
//--------------------extrct dataset from StdQuesCompare class using ExtractDatasetFromStdQuestion method -----------------------------
extractDatasetForStdEssay = stdqc.ExtractDatasetFromStdQuestion(output);
System.out.println("extractDatasetForEssay Std " + extractDatasetForStdEssay);
// Converting list to array after data extraction function
extractDatasetForEssayStdArray = new String[extractDatasetForStdEssay.size()];
extractDatasetForEssayStdArray = extractDatasetForStdEssay.toArray(extractDatasetForEssayStdArray);
}
// System.out.println("selected Type "+selectedRadioButton.getText().toString());
//calling the extract data function for normal question solvings
extractedStdDataset = extractData.ExtractionWithComma(dataArray);
//-------------------------------------------------------------------------------------------------------------------------------- remove lateer
// Converting list to array after daa extraction function
String[] datasetArray = new String[extractedStdDataset.size()];
datasetArray = extractedStdDataset.toArray(datasetArray);
// System.out.println("selected Type "+selectedRadioButton.getText().toString());
Intent intent = new Intent(StandardDeviationInputMethod.this, StandaradDeviationCalculation.class);
intent.putExtra("dataset",datasetArray);
......@@ -450,7 +487,7 @@ public class StandardDeviationInputMethod extends AppCompatActivity {
// setting the grey scale image
// img_greyview.setImageBitmap(greybmp);
// img_greyview.setImageBitmap(greybmp);
// creating new thread to start OCR
new Thread(new Runnable() {
......@@ -486,4 +523,56 @@ public class StandardDeviationInputMethod extends AppCompatActivity {
Toast.makeText(this,"'"+selectedRadioButton.getText().toString()+"'",Toast.LENGTH_SHORT).show();
}
//----------------------readStdQuestion method-----------------------------------------------------------------------
private List<String> readStdQuestions(){
String[] printQuestion = new String[500];
List<StandardDeviationCSVfile> stdQuestions= new ArrayList<>();
List<String> StringstdQuestions= new ArrayList<>();
InputStream is = getResources().openRawResource(R.raw.std);
BufferedReader reader = new BufferedReader(
new InputStreamReader(is, Charset.forName("UTF-8"))
);
String line = "";
try {
/*int lines = 0;
while(reader.readLine() != null){
lines++;
}*/
while ((line = reader.readLine()) != null) {
//Split by '"'
String tokens = line;
//Read the csv
StandardDeviationCSVfile question = new StandardDeviationCSVfile();
question.setQuestion(tokens);
stdQuestions.add(question);
StringstdQuestions.add(tokens);
//printQuestion[lines] = line;
Log.d("MyActivity", "Just created: " + question);
}
} catch (IOException e) {
Log.wtf("MyActivity", "Error reading data file on line " + line, e);
e.printStackTrace();
}
finally {
try {
reader.close();
}catch (IOException e) {
e.printStackTrace();
}
}
return StringstdQuestions;
}
}
\ No newline at end of file
def word2vec(word):
from collections import Counter
from math import sqrt
# count the characters in word
cw = Counter(word)
# precomputes a set of the different characters
sw = set(cw)
# precomputes the "length" of the word vector
lw = sqrt(sum(c*c for c in cw.values()))
# return a tuple
return cw, sw, lw
def cosdis(v1, v2):
# which characters are common to the two words?
common = v1[1].intersection(v2[1])
# by definition of cosine distance we have
return sum(v1[0][ch]*v2[0][ch] for ch in common)/v1[2]/v2[2]
def matchkeyword(klist,sen):
matchedkeywordlist=[]
list_of_keywords = klist
Sentence = sen
threshold = 0.90
for key in list_of_keywords:
for word in Sentence.split():
try:
# print(key)
print(word)
res = cosdis(word2vec(word), word2vec(key))
print(res)
if res > threshold:
print("Found a word with cosine distance > 100 : {} with original word: {}".format(word, key))
matchedkeywordlist.append(word)
except IndexError:
pass
return matchedkeywordlist
from fuzzywuzzy import process
def main(data,data2):
str2match=data
stroptions=["Find the standard deviation for the following data series: 12, 6, 7, 3, 15, 10, 18, 5","Calculate the mean, sum of square, variance, and standard deviation for the following sample: 6 8 4 3 5 7 4 3","For the following data: 1 4 3 6 2 7 18 3 7 2 4 3 Compute the mean, standard deviation, median, and semi-quartile range. Then explain which measures of central tendency and variability provide a better description of the sample"]
ratio=process.extract(str2match,data2)
highest=process.extractOne(str2match,data2)
print(ratio)
check_list=isinstance(data2,list)
print(check_list)
print(type(data2))
return ""+str(highest)
\ No newline at end of file
......@@ -131,7 +131,7 @@
android:id="@+id/rg_03_Q4"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Solve Essey problem" />
android:text="Solve Essay problem" />
</RadioGroup>
......
"Calculate the standard deviation for the following population of scores: 8 5 3 7 5 6 4 7 2 6 5 3 6 4 5 7 8 6 5 6"
"Calculate the mean, sum of square, variance, and standard deviation for the following sample: 6 8 4 3 5 7 4 3"
"For the following data: 1 4 3 6 2 7 18 3 7 2 4 3
Compute the mean, standard deviation, median, and semi-quartile range. Then explain which measures of central tendency and variability provide a better description of the sample"
"Calculate the standard deviation for the following three sample data sets:
a. 13 21 27 31 35 24 28 32 17 20
b. 100 115 112 113 95 87 90 104 107 98
c. 55 54 59 55 52 51 57 49 61 57"
"Find the standard deviation for the following data series: 12, 6, 7, 3, 15, 10, 18, 5"
"Find the standard deviation for the following series of numbers:
2, 3, 6, 8, 11.
12, 6, 7, 3, 15, 10, 18, 5."
"Find the standard deviation for the series:
3, 5, 2, 7, 6, 4, 9.
3, 5, 2, 7, 6, 4, 9, 1."
"Assume the population proportion is 0.55. Compute the standard deviation of the proportion for the following sample sizes (use 4 decimal places):
a. 150
b. 250
c. 450
d. 750
e. What can you say about the size of the standard deviation of the proportion as the sample size is increased?"
"You flip a coin 100 times and it lands on heads 44 times. You then use the same coin and do another 100 flips. This time in lands on heads 49 times. You repeat this experiment a total of 10 times and get the following results for the number of heads.
{44;49;52;62;53;48;54;49;46;51}
Compute the mean and variance of this data set."
"What is the variance and standard deviation of the possibilities associated with rolling a fair die?"
"Compute the mean and variance of the following set of values.
150; 300; 250; 270; 130; 80; 700; 500; 200; 220; 110; 320; 420; 140"
"The following data set has a mean of 14,7 and a variance of 10,01.
18; 11; 12; a; 16; 11; 19; 14; b; 13
Compute the values of a and b."
"The heights of students (in cm) in a class are: {148, 156, 160, 164, 164, 167, 171, 176, 180, 194}. Find the Population Standard Deviation, Variance."
"the variances of observation 3,4,5,6,7,10 is"
"Find the standard deviation of the following set of numbers: 10,15,19,35,27,44. Round your answer to the nearest tenth."
"Find the standard deviation of the following set of numbers: 10,15,7,13. Round your answer to the nearest hundredth."
"Kyle scored the following on his mathematics tests: 60,75,80,75,70. What is the standard deviation of his test scores? Round your answer to the nearest tenth."
"If I add 2 to all my observations, how variance and mean will vary?"
"If I multiply the result of my observations by 3, how variance and mean will vary?"
"Find the variance of 6, 7, 10, 11, 11, 13, 16, 18, 25"
"Find the variance and standard deviation of the following correct to 2 decimal places:
1. a) 10, 16, 12, 15, 9, 16, 10, 17, 12, 15
b) 74, 72, 83, 96, 64, 79, 88, 69
c) £326, £438, £375, £366, £419, £424"
"According to the U.S. Department of Agriculture, ten to twenty earthworms per
cubic foot is a sign of healthy soil. Mr. Green checked the soil in his garden
by digging 7 one-cubic-foot holes and counting the earthworms. He found the
following counts: 4, 23, 15, 10, 8, 12, 18.
Calculate the sample variance and sample standard deviation of the numbers
of earthworms per cubic foot."
""
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment