def insert_cosine_database(self,taxonomy_id,maxvalue,getquestion_id):
        checkquestionid=[]
        print("taxonomyno")
        sqlstatement="select * from question_max_cosine where question_id=" + str(getquestion_id)+ ""
        print(sqlstatement)
        checkquestionid=DBHandler().getData("select * from question_max_cosine where question_id=" + str(getquestion_id)+ "")
        if not(checkquestionid):
            insertstatement ="insert into question_max_cosine(question_id) values(" + str(getquestion_id)+ ")"
            print(insertstatement)
            DBHandler().setData(insertstatement)
        column_name=''
        if(taxonomy_id=='1'):
            column_name="max_cosine_A"
        if(taxonomy_id=='2'):
             column_name="max_cosine_B"
        if(taxonomy_id=='3'):
             column_name="max_cosine_C"
        if(taxonomy_id=='4'):
             column_name="max_cosine_D"
        if(taxonomy_id=='5'):
             column_name="max_cosine_E"
        if(taxonomy_id=='6'):
             column_name="max_cosine_F"

        updatesql="update question_max_cosine set " + column_name+ "=" + str(maxvalue) + " where question_id= " + str(getquestion_id)+ ""
        print(updatesql)
        DBHandler().setData(updatesql)
 def loadsubjectDescription(self):
     items = self.tableWidget.selectedItems()
     print(str(items[0].text()))
     subjectcategory = DBHandler().getData(
         "SELECT subject from subject_evaluation where Nos='" +
         str(items[0].text()) + "' LIMIT 1")
     description = DBHandler().getData(
         "SELECT description from subject where subject_code='" +
         str(subjectcategory[0][0]) + "' LIMIT 1")
     self.textEdit_SubjectDescription.setText(str(description[0][0]))
Exemplo n.º 3
0
    def insertpattern(self):

        tagpattern = self.textAdd_tagpattern.toPlainText()
        bloomscategory = self.comboBox.currentText()
        selectData = "SELECT taxonomy_id,taxonomy_namel FROM blooms_taxonomy WHERE taxonomy_namel like '%" + bloomscategory + "%'"
        wup_list = DBHandler().getData(selectData)
        print(wup_list)
        insertsql = "insert into question_stems(taxonomy_id,question_stem)values(" + str(
            wup_list[0][0]) + ",'" + str(tagpattern) + "')"
        print(insertsql)
        DBHandler().setData(insertsql)
        self.loadtabledata()
    def questiondataGenerate(self):
        getpaperno = self.lineEdit_Paperno.text()
        print(getpaperno)
        getquestionlist = "SELECT * from question_list where process_complete ='no' and paperno=" + getpaperno + ""
        questionsList = DBHandler().getData(getquestionlist)
        print(questionsList)

        taxonomyList = []

        for question in questionsList:
            print(question[2])
            sentenses = nltk.sent_tokenize(question[2])
            sentences = [nltk.word_tokenize(sent) for sent in sentenses]
            sentences = [nltk.pos_tag(sent) for sent in sentences]
            verbList = Lemmatizer().getLematizedWord(
                #ExtractVerb().searchVerbs1(ExtractVerb().wordTagger(WordTokeninzer().tokenize_word(question[2],1),1)))
                ExtractVerb().searchVerbs11(sentences))

            newList = []
            for i in range(6):
                taxonomyLineList = DBHandler().getData(
                    "SELECT verb from taxonomy_verb_list where taxonomy_id=" +
                    str(i + 1))
                taxonomyWordList = []

                for line in taxonomyLineList:
                    for word in line:
                        taxonomyWordList.append(word)
                if len(verbList) > 0 and len(taxonomyWordList) > 0:
                    temp = SimilarityChecker().calsulateSimilarity(
                        verbList, taxonomyWordList, question[0], question[1],
                        (i + 1))

            SementicSimilarityChecker().tagpattern_Gensim_Algorithm(
                question[0], question[1], question[2])
            Normilize_algoWLGTag().normalize_WLGT(getpaperno, question[0])
            Getthepriority().normalized_group_rank(getpaperno, question[0])
            cosine_similarity_checker().generateCosinepatterns(
                getpaperno, question[0])
            CosinePreprocess().cosinePreprocess_papers(getpaperno, question[0])
            SementicSimilarityCheckerAll().allquestionGensim(
                question[0], question[2])
            taxonomy_allDatabase().inserttoDatabase(question[0])
            time.sleep(2)
            getsqlvalues = "UPDATE question_list SET process_complete='yes' WHERE question_id = '" + str(
                question[0]) + "'"
            print(getsqlvalues)
            DBHandler().setData(getsqlvalues)

            self.loadquestionlist()

            print("loadquestion")
    def updateQuestion(self):

        QuestionNo = self.lineEdit_RemainMarks.text()

        newquestion = self.textEdit_Question.toPlainText()
        questionMarks = self.spinBox_Questionmarks.value()
        print(newquestion)
        print(questionMarks)
        updateData = "update question_list set question='" + str(
            newquestion
        ) + "', questionmarks=" + str(
            questionMarks
        ) + ", process_complete='no' ,Question_category= 0  where question_id=" + str(
            QuestionNo) + ""
        print(updateData)

        DBHandler().setData(updateData)
        question_analysis = "delete from question_analysis where question_id=" + QuestionNo + ""
        DBHandler().setData(question_analysis)
        question_analysis_groupresults = "delete from question_analysis_groupresults where question_id=" + QuestionNo + ""
        DBHandler().setData(question_analysis_groupresults)
        question_analysis_normalized_groupresults = "delete from question_analysis_normalized_groupresults where question_id=" + QuestionNo + ""
        DBHandler().setData(question_analysis_normalized_groupresults)
        question_analysis_stem = "delete from question_analysis_stem where question_id=" + QuestionNo + ""
        DBHandler().setData(question_analysis_stem)
        question_dataset = "delete from question_dataset where question_id=" + QuestionNo + ""
        DBHandler().setData(question_dataset)
        question_gem_simliar_no = "delete from question_gem_simliar_no where question_id=" + QuestionNo + ""
        DBHandler().setData(question_gem_simliar_no)
        question_max_cosine = "delete from question_max_cosine where question_id=" + QuestionNo + ""
        DBHandler().setData(question_max_cosine)
        self.loadquestionlist()
Exemplo n.º 6
0
    def deletepatterns(self):

        tagpatternNo = self.tagpatternno_text.text()

        updateData = "delete from question_stems where id=" + tagpatternNo + ""
        DBHandler().setData(updateData)
        self.loadsearchtabledata()
Exemplo n.º 7
0
    def updateTaxonomy(self):

        taxonomyNO = self.Subject_no_text.text()
        description = self.Subject_description_text.text()
        updateData = "update blooms_taxonomy set taxonomy_namel='" + description + "' where taxonomy_id=" + taxonomyNO + ""
        DBHandler().setData(updateData)
        self.loadtabledata()
    def loadquestionlist(self):

        entertext = self.lineEdit_Search.text()
        getpaperno = self.lineEdit_Paperno.text()

        selectData = "SELECT question_id,process_complete,questionmarks" \
                     ",question FROM question_list WHERE subject_code " \
                     "like '%"+ entertext + "%' and paperno=" +getpaperno+ ""
        wup_list = DBHandler().getData(selectData)
        print(len(wup_list))
        print(len(wup_list[0]))
        rows = len(wup_list)
        columns = len(wup_list[0])
        i = 0
        j = 0
        self.tableWidget.clearContents()
        for i in range(0, rows):
            for j in range(0, columns):

                item = QtGui.QTableWidgetItem((str(wup_list[i][j])))
                if (wup_list[i][1] == 'yes'):
                    brush = QtGui.QBrush(QtGui.QColor(154, 232, 80))
                    brush.setStyle(QtCore.Qt.SolidPattern)
                    item.setBackground(brush)
                elif (wup_list[i][1] == 'no'):
                    brush = QtGui.QBrush(QtGui.QColor(231, 214, 25))
                    brush.setStyle(QtCore.Qt.SolidPattern)
                    item.setBackground(brush)
                self.tableWidget.setItem(i, j, item)

        print(wup_list[0][1])
    def editpattern(self, row, column):

        print("Row %d and Column %d was clicked" % (row, column))
        item = self.tableWidget.itemAt(row, column)
        self.ID = item.text()
        print(self.ID)
        items = self.tableWidget.selectedItems()
        print(str(items[0].text()))
        selectData = "SELECT subject,years,semester,papertype,dates,papermarks  FROM exam_paper WHERE No =" + str(
            items[0].text()) + ""
        getData = DBHandler().getData(selectData)
        print(getData[0][0])
        print(getData[0][1])
        value = 0
        if (getData[0][1] == '2016'):
            value = 1
        elif (getData[0][1] == '2017'):
            value = 2

        self.lineEdit_RemainMarks.setText(str(items[0].text()))
        self.comboBox_Year.setCurrentIndex(value)
        self.comboBox_Semester.setEditText((str(getData[0][2])))
        self.comboBox_papertype.setEditText((str(getData[0][3])))
        self.dateEdit.setDate(getData[0][4])
        self.spinBox_papermarks.setValue(getData[0][5])
    def deletepapers(self):

        paperNo = self.lineEdit_RemainMarks.text()

        updateData = "delete from exam_paper where No=" + paperNo + ""
        DBHandler().setData(updateData)
        self.loadtabledata()
    def deletesubjeEval(self):

        items = self.tableWidget.selectedItems()
        print(str(items[0].text()))
        updateData = "delete from subject_evaluation where Nos=" + str(
            items[0].text()) + ""
        DBHandler().setData(updateData)
        self.loadtabledata()
    def allquestionGensim(self, questionid, question):
        documents = DBHandler().getData(
            "SELECT question FROM nlp_compare.question_list where Question_category !=0 and Quetion_OrderNo!=0"
        )
        sentences = []
        for line in documents:
            sentences.append(line[0])

        self.getSementicSimilarityValues(sentences, questionid, question)
Exemplo n.º 13
0
    def updatepatterns(self):

        tagpatternNo = self.tagpatternno_text.text()
        tappatterns = self.textEdit_tagpattern.toPlainText()

        updateData = "update question_stems set question_stem='" + tappatterns + "', Tag_pattern='no',grammer_tag_pattern='no',pattern_set='no'  where id=" + tagpatternNo + ""
        print(updateData)

        DBHandler().setData(updateData)
        self.loadsearchtabledata()
    def generation(self):

        QuestionStemList = DBHandler().getData("SELECT * from question_stems where pattern_set ='no' ")
        for Question in QuestionStemList:
            TagPatterngrammer=""
            Tagpattern = []
            print(Question[2])
            text = nltk.word_tokenize(Question[2])
            results= nltk.pos_tag(text)
            for(word,tag)in results:
                Tagpattern.append(tag)
                TagPatterngrammer+="<"+tag+">"
            covertstring = ','.join(Tagpattern)
            print(covertstring)
            patternset="yes"
            updatestring = "update question_stems set Tag_pattern= '" +\
                           str(covertstring) + "',grammer_tag_pattern='"  \
                           + TagPatterngrammer + "',pattern_set='"  + patternset \
                           + "',No_tags=" +str(len(Tagpattern))+ " where id="+str(Question[0])+ " and taxonomy_id=" +str(Question[1])+  ""
            DBHandler().setData(updatestring)
Exemplo n.º 15
0
    def tagpattern_Gensim_Algorithm(self, questionno, getsubject, questions):

        #questionsList = DBHandler().getData("SELECT * from question_list where question_id BETWEEN 460 AND 529")
        #print(len(questionsList))
        taxonomyList = []

        myQuery = "Insert into question_analysis_stem (question_id,subject_code) values (" + str(
            questionno) + ",'" + str(getsubject) + "')"
        print(myQuery)
        DBHandler().setData(myQuery)
        for i in range(6):
            print("taxonomy:" + str(i))
            documents = DBHandler().getData(
                "SELECT question_stem FROM question_stems where taxonomy_id = '"
                + str(i + 1) + "'")
            sentences = []
            for line in documents:
                sentences.append(line[0])
            self.getSementicSimilarityValues((i + 1), sentences, questionno,
                                             getsubject, questions)
 def questionClassification(self, paperID):
     getrecords = "Select * from question_dataset INNER JOIN question_list" \
                  " on question_dataset.question_id=question_list.question_id" \
                  " where question_list.Question_category=0 and question_list.paperno='" +str(paperID)+"'"
     print(getrecords)
     lastrecord = DBHandler().getData(getrecords)
     if (lastrecord):
         for classifyquestion in lastrecord:
             MachineLearning().classify(classifyquestion)
     else:
         print("no value")
    def loadyears(self):

        getsubject = self.comboBox_subject.currentText()
        getyearlist = "SELECT DISTINCT years from exam_paper where subject='" + getsubject + "'"
        yearlist = DBHandler().getData(getyearlist)
        self.comboBox_Year.clear()
        self.comboBox_Semester.clear()
        self.comboBox_papertype.clear()
        self.comboBox_date.clear()
        b = [str(text[0]) for text in yearlist]
        for value in b:
            self.comboBox_Year.addItem(value)
    def loadquestionlist(self):

        getpaperno = self.lineEdit_Paperno.text()

        selectData = "SELECT question_id,process_complete,Question_category,questionmarks" \
                     ",question FROM question_list WHERE paperno=" +getpaperno+ ""
        wup_list = DBHandler().getData(selectData)
        print(len(wup_list))
        print(len(wup_list[0]))
        rows = len(wup_list)
        columns = len(wup_list[0])
        i = 0
        j = 0
        self.tableWidget.clearContents()
        for i in range(0, rows):
            for j in range(0, columns):

                item = QtGui.QTableWidgetItem((str(wup_list[i][j])))
                if (wup_list[i][1] == 'yes'):
                    brush = QtGui.QBrush(QtGui.QColor(238, 238, 178))
                    brush.setStyle(QtCore.Qt.SolidPattern)
                    item.setBackground(brush)
                if (wup_list[i][1] == 'no'):
                    brush = QtGui.QBrush(QtGui.QColor(231, 214, 25))
                    brush.setStyle(QtCore.Qt.SolidPattern)
                    item.setBackground(brush)
                if (wup_list[i][2] == 1):
                    brush = QtGui.QBrush(QtGui.QColor(251, 216, 255))
                    brush.setStyle(QtCore.Qt.SolidPattern)
                    item.setBackground(brush)
                if (wup_list[i][2] == 2):
                    brush = QtGui.QBrush(QtGui.QColor(255, 155, 105))
                    brush.setStyle(QtCore.Qt.SolidPattern)
                    item.setBackground(brush)
                if (wup_list[i][2] == 3):
                    brush = QtGui.QBrush(QtGui.QColor(248, 255, 170))
                    brush.setStyle(QtCore.Qt.SolidPattern)
                    item.setBackground(brush)
                if (wup_list[i][2] == 4):
                    brush = QtGui.QBrush(QtGui.QColor(139, 191, 255))
                    brush.setStyle(QtCore.Qt.SolidPattern)
                    item.setBackground(brush)
                if (wup_list[i][2] == 5):
                    brush = QtGui.QBrush(QtGui.QColor(171, 171, 171))
                    brush.setStyle(QtCore.Qt.SolidPattern)
                    item.setBackground(brush)
                if (wup_list[i][2] == 6):
                    brush = QtGui.QBrush(QtGui.QColor(160, 255, 190))
                    brush.setStyle(QtCore.Qt.SolidPattern)
                    item.setBackground(brush)
                self.tableWidget.setItem(i, j, item)

        print(wup_list[0][1])
    def laodpapertypes(self):

        getyear = self.comboBox_Year.currentText()
        getsubject = self.comboBox_subject.currentText()
        getsemester = self.comboBox_Semester.currentText()
        getpapertypes = "SELECT DISTINCT papertype from exam_paper" \
                          " where years=" +getyear+ " and subject='" + getsubject + "' and semester="+getsemester+ ""
        paperset = DBHandler().getData(getpapertypes)
        self.comboBox_papertype.clear()
        self.comboBox_date.clear()
        b = [str(text[0]) for text in paperset]
        for value in b:
            self.comboBox_papertype.addItem(value)
    def __init__(self):
        super(bloomsVerbs, self).__init__()

        self.setupUi(self)
        self.Searchbox_text.textChanged.connect(self.loadtabledata)
        bloomstaxonomy = DBHandler().getData(
            "SELECT  taxonomy_namel from blooms_taxonomy ")
        self.comboBox.clear()

        b = [str(text[0]) for text in bloomstaxonomy]
        for value in b:
            self.comboBox.addItem(value)
            print(value)
    def loadtabledata(self):

        entertext = self.Searchbox_text.text()
        self.sub_code = self.comboBox.currentText()
        selectData = "SELECT taxonomy_id FROM blooms_taxonomy WHERE taxonomy_namel = '" + self.sub_code + "'"
        taxonomyID = DBHandler().getData(selectData)
        verbLIst = "SELECT taxonomy_id,verb FROM taxonomy_verb_list WHERE verb like '%"+ entertext + "%'" \
                   " and taxonomy_id=" + str(taxonomyID[0][0]) + ""
        wup_list = DBHandler().getData(verbLIst)
        print(len(wup_list))
        print(len(wup_list[0]))
        rows = len(wup_list)
        columns = len(wup_list[0])
        i = 0
        j = 0
        self.tableWidget.clearContents()
        for i in range(0, rows):
            for j in range(0, columns):

                item = QtGui.QTableWidgetItem((str(wup_list[i][j])))
                self.tableWidget.setItem(i, j, item)

        print(wup_list[0][1])
    def insertPapers(self):
        subject = self.comboBox_subject.currentText()
        year = self.comboBox_Year.currentText()
        semester = self.comboBox_Semester.currentText()
        date = self.dateEdit.text()
        papertype = self.comboBox_papertype.currentText()
        papermarks = self.spinBox_papermarks.value()

        insertsql = "insert into exam_paper(subject,years,semester,papertype,dates" \
                    ",papermarks)values('"+str(subject)+ "'," \
                    +str(year) +"," + str(semester) +",'"+ str(papertype) + "','" +str(date)+ "'," \
                    +str(papermarks)+")"
        DBHandler().setData(insertsql)
        self.loadtabledata()
    def updatepaper(self):

        paperNo = self.lineEdit_RemainMarks.text()

        dates = self.dateEdit.text()
        papermarks = self.spinBox_papermarks.value()
        print(dates)
        print(papermarks)
        updateData = "update exam_paper set dates='" + str(
            dates) + "', papermarks=" + str(papermarks) + "  where No=" + str(
                paperNo) + ""
        print(updateData)

        DBHandler().setData(updateData)
        self.loadtabledata()
 def loadmarks(self):
     getyear = self.comboBox_Year.currentText()
     getsubject = self.comboBox_subject.currentText()
     getsemester = self.comboBox_Semester.currentText()
     getpapertype = self.comboBox_papertype.currentText()
     getdate = self.comboBox_date.currentText()
     papermarks = "select papermarks,No from exam_paper where subject='"\
                  +getsubject+ "' and years=" + getyear + \
                     " and semester=" +getsemester+ " and papertype='" +getpapertype+ "' " \
                     "and dates= '" +getdate+ "'"
     gettotalmarks = DBHandler().getData(papermarks)
     self.lineEdit_TotalMarks.setText(str(gettotalmarks[0][0]))
     self.lineEdit_Paperno.setEnabled(False)
     paperno = gettotalmarks[0][1]
     self.lineEdit_Paperno.setText(str(paperno))
     self.lineEdit_Papermarks.setText(str(gettotalmarks[0][0]))
     nowMarks = "select sum(questionmarks) from question_list where paperno =" + str(
         paperno) + ""
     print(nowMarks)
     getnowMarks = DBHandler().getData(nowMarks)
     print(getnowMarks)
     if (nowMarks is not None):
         remainmarks = gettotalmarks[0][0] - getnowMarks[0][0]
         self.lineEdit_RemainMarks.setText(str(remainmarks))
    def loaddates(self):

        getyear = self.comboBox_Year.currentText()
        getsubject = self.comboBox_subject.currentText()
        getsemester = self.comboBox_Semester.currentText()
        getpapertype = self.comboBox_papertype.currentText()
        getdates = "SELECT DISTINCT dates from exam_paper" \
                          " where years=" +getyear+ " and subject='" + getsubject +\
                          "' and semester="+getsemester+ " and papertype='"+getpapertype+ "'"
        datelist = DBHandler().getData(getdates)
        self.comboBox_date.clear()
        b = [str(text[0]) for text in datelist]
        for value in b:
            self.comboBox_date.addItem(value)
        self.loadquestionlist()
    def __init__(self):
        super(Questionpaper, self).__init__()

        self.setupUi(self)
        subjectlist = DBHandler().getData("SELECT  subject_code from subject ")
        self.comboBox_subject.clear()
        self.pushButton_Insert.clicked.connect(self.insertPapers)
        self.lineEdit_Search.textChanged.connect(self.loadtabledata)
        self.tableWidget.cellClicked.connect(self.editpattern)
        self.pushButton_Update.clicked.connect(self.updatepaper)
        self.pushButton_Delete.clicked.connect(self.deletepapers)
        b = [str(text[0]) for text in subjectlist]
        for value in b:
            self.comboBox_subject.addItem(value)
            print(value)
 def enterquestion(self):
     getyear = self.comboBox_Year.currentText()
     getsubject = self.comboBox_subject.currentText()
     getsemester = self.comboBox_Semester.currentText()
     getpaperno = self.lineEdit_Paperno.text()
     question = self.textEdit_Question.toPlainText()
     questionmark = self.spinBox_Questionmarks.text()
     print(getyear, getsubject, getsemester, getpaperno, question,
           questionmark)
     insertquestion ="insert into question_list(subject_code,question,Years,Semester,questionmarks,paperno)" \
                     "values('"+getsubject+ "','"+ question +"',"+getyear \
                     +"," +getsemester+","+questionmark +","+getpaperno+")"
     print(insertquestion)
     DBHandler().setData(insertquestion)
     self.loadquestionlist()
Exemplo n.º 28
0
 def loadselection(self, row, column):
     print("Row %d and Column %d was clicked" % (row, column))
     item = self.tableWidget.itemAt(row, column)
     self.ID = item.text()
     print(self.ID)
     items = self.tableWidget.selectedItems()
     print(str(items[0].text()))
     selectData = "SELECT taxonomy_id,taxonomy_namel FROM blooms_taxonomy WHERE taxonomy_id =" + str(
         items[0].text()) + ""
     getData = DBHandler().getData(selectData)
     print(getData[0][0])
     print(getData[0][1])
     self.Subject_no_text.setText(str(getData[0][0]))
     self.Subject_no_text.setDisabled(True)
     self.Subject_description_text.setText(str(getData[0][1]))
 def loadmarks(self):
     getyear = self.comboBox_Year.currentText()
     getsubject = self.comboBox_subject.currentText()
     getsemester = self.comboBox_Semester.currentText()
     getpapertype = self.comboBox_papertype.currentText()
     getdate = self.comboBox_date.currentText()
     papermarks = "select papermarks,No from exam_paper where subject='"\
                  +getsubject+ "' and years=" + getyear + \
                     " and semester=" +getsemester+ " and papertype='" +getpapertype+ "' " \
                     "and dates= '" +getdate+ "'"
     gettotalmarks = DBHandler().getData(papermarks)
     self.lineEdit_TotalMarks.setText(str(gettotalmarks[0][0]))
     self.lineEdit_Paperno.setEnabled(False)
     paperno = gettotalmarks[0][1]
     self.lineEdit_Paperno.setText(str(paperno))
     self.lineEdit_Papermarks.setText(str(gettotalmarks[0][0]))
Exemplo n.º 30
0
    def editpattern(self, row, column):

        print("Row %d and Column %d was clicked" % (row, column))
        item = self.tableWidget.itemAt(row, column)
        self.ID = item.text()
        print(self.ID)
        items = self.tableWidget.selectedItems()
        print(str(items[0].text()))
        selectData = "SELECT id, question_stem FROM question_stems WHERE id =" + str(
            items[0].text()) + ""
        getData = DBHandler().getData(selectData)
        print(getData[0][0])
        print(getData[0][1])
        self.tagpatternno_text.setText(str(getData[0][0]))
        self.tagpatternno_text.setDisabled(True)
        self.textEdit_tagpattern.setText(str(getData[0][1]))