def display(self, str):
        '''
        print("\n")
        print("------X------")
        print("Start  output:\n")
        '''
        out = []
        for i in range(len(str)):
            if (len(str[i]) >= 3):
                if (questionValidation.hNvalidation(str[i]) == 1):
                    if ((str[i][0] == 'W' and str[i][1] == 'h')
                            or (str[i][0] == 'H' and str[i][1] == 'o')
                            or (str[i][0] == 'H' and str[i][1] == 'a')):
                        WH = str[i].split(',')
                        if (len(WH) == 1):
                            str[i] = str[i][:-1]
                            str[i] = str[i][:-1]
                            str[i] = str[i][:-1]
                            str[i] = str[i] + "?"

                            #if (count < 10):
                            #print("Q-0%d: %s" % (count, str[i]))
                            out.append(str[i])
        '''
        print("")
        print("End  OutPut")
        print("-----X-----\n\n")

        output = "DB/output.txt"
        w = open(output, 'w+', encoding="utf8")
        w.write(out)
        w.close()
        '''
        return out
    def display(self, str):
        print("\n")
        print("------X------")
        print("Start  output:\n")

        count = 0
        out = ""
        for i in range(len(str)):
            if (len(str[i][0]) >= 3):
                if (questionValidation.hNvalidation(str[i][0]) == 1):
                    if ((str[i][0][0] == 'W' and str[i][0][1] == 'h')
                            or (str[i][0][0] == 'H' and str[i][0][1] == 'o')
                            or (str[i][0][0] == 'H' and str[i][0][1] == 'a')):
                        WH = str[i][0].split(',')
                        if (len(WH) == 1):
                            str[i][0] = str[i][0][:-1]
                            str[i][0] = str[i][0][:-1]
                            str[i][0] = str[i][0][:-1]
                            str[i][0] = str[i][0] + "?"
                            count = count + 1

                            if (count < 10):
                                # print("Q-0%d: %s" % (count, str[i][0]))
                                # print("\nAnswer:",str[i][1].replace("\n"," "),"\n---------\n")
                                out += "Q-0" + count.__str__(
                                ) + ": " + str[i][0] + "\n"
                                out += "Ans: " + str[i][1].replace("\n",
                                                                   " ") + "\n"
                                out += "----------\n"

                            else:
                                # print("Q-%d: %s" % (count, str[i][0]))
                                # print("\nAnswer:",str[i][1].replace("\n"," "),"\n---------\n")
                                out += "Q-" + count.__str__(
                                ) + ": " + str[i][0] + "\n"
                                out += "Ans: " + str[i][1].replace("\n",
                                                                   " ") + "\n"
                                out += "----------\n"

        print("")
        print("End  OutPut")
        print("-----X-----\n\n")

        output = "./DB/output.txt"
        w = open(output, 'w+', encoding="utf8")
        w.write(out)
        w.close()
        return 0
    def display(self, str):
        print("\n")
        print("------X------")
        print("Start  output:\n")

        count = 0
        out = ""
        for i in range(len(str)):
            if (len(str[i]) >= 3):
                if (questionValidation.hNvalidation(str[i]) == 1):
                    if ((str[i][0] == 'W' and str[i][1] == 'h')
                            or (str[i][0] == 'H' and str[i][1] == 'o')
                            or (str[i][0] == 'H' and str[i][1] == 'a')):
                        WH = str[i].split(',')
                        if (len(WH) == 1):

                            str[i] = str[i][:-1]
                            str[i] = str[i][:-1]
                            str[i] = str[i][:-1]
                            str[i] = str[i] + "?"
                            count = count + 1

                            grammar_validate.grammar_check(str, i)

                            # if (count < 10):
                            #     print("Q-0%d: %s" % (count, str[i]))
                            #     out += "Q-0" + count.__str__() + ": " + str[i] + "\n"
                            # else:
                            #     print("Q-%d: %s" % (count, str[i]))

                            #     out += "Q-" + count.__str__() + ": " + str[i] + "\n"
        # print(str)
        # grammar_validate.grammar_check(str,count)
        # grammar_validate.print_ans(str)

        print(grammar_validate.print_ans())
        print("")
        print("End  OutPut")
        print("-----X-----\n\n")

        # output = "DB/output.txt"
        # w = open(output, 'w+', encoding="utf8")
        # w.write(out)
        # w.close()
        return 0
Example #4
0
    def display(self, str):
        print("\n")
        print("------X------")
        print("Start  output:\n")

        count = 0
        out = ""
        for i in range(len(str)):
            if (len(str[i]) >= 3):
                if (questionValidation.hNvalidation(str[i]) == 1):
                    if ((str[i][0] == 'W' and str[i][1] == 'h')
                            or (str[i][0] == 'H' and str[i][1] == 'o')
                            or (str[i][0] == 'H' and str[i][1] == 'a')):
                        WH = str[i].split(',')
                        if (len(WH) == 1):
                            str[i] = str[i][:-1]
                            str[i] = str[i][:-1]
                            str[i] = str[i][:-1]
                            str[i] = str[i] + "?"
                            count = count + 1

                            if (count < 10):
                                print("Q-0%d: %s" % (count, str[i]))
                                out += "Q-0" + count.__str__(
                                ) + ": " + str[i] + "\n"

                            else:
                                print("Q-%d: %s" % (count, str[i]))
                                out += "Q-" + count.__str__(
                                ) + ": " + str[i] + "\n"

        print("")
        print("End  OutPut")
        print("-----X-----\n\n")

        output = r"C:\Users\hp\3D Objects\practice\capstone\01-Basic-Setup\capstone\static\files/" + self.filename + r".txt"
        w = open(output, 'w+', encoding="utf8")
        w.write(out)
        w.close()
        return 0
    def display(self, str):
        print("\n")
        print("------X------")
        print("Start  output:\n")

        count = 0
        out = ""
        for i in range(len(str)):
            if (len(str[i]) >= 3):
                if (questionValidation.hNvalidation(str[i]) == 1):
                    if ((str[i][0] == 'W' and str[i][1] == 'h') or (str[i][0] == 'H' and str[i][1] == 'o') or (
                            str[i][0] == 'H' and str[i][1] == 'a')):
                        WH = str[i].split(',')
                        if (len(WH) == 1):
                            str[i] = str[i][:-1]
                            str[i] = str[i][:-1]
                            str[i] = str[i][:-1]
                            str[i] = str[i] + "?"
                            count = count + 1

                            if (count < 10):
                                print("Q-0%d: %s" % (count, str[i]))
                                out += "Q-0" + count.__str__() + ": " + str[i] + "\n"

                            else:
                                print("Q-%d: %s" % (count, str[i]))
                                out += "Q-" + count.__str__() + ": " + str[i] + "\n"

        print("")
        print("End  OutPut")
        print("-----X-----\n\n")

        # output = "output file path -- ?? ../DB/output.txt"
        # w = open(output, 'w+', encoding="utf8")
        # w.write(out)
        # w.close()
        return str