コード例 #1
0
ファイル: storykey.py プロジェクト: PredectiveAI/desktopapp
    def gramarize(self, sent):

        f = open('Value-json/logic_activation.json')
        activation = json.load(f)
        if activation['grammar_logic'] == "active":
            test_str = sent
            splitter = SentenceSplitter(language='en')
            sente = splitter.split(text=test_str)
            gram_sent = []

            for sent in sente:
                parser = GingerIt()

                output = parser.parse(sent)
                output_1 = (output.get("result"))
                output_1 = output_1
                gram_sent.append(output_1)

            f_output = ' '.join(gram_sent)

            if f_output[-1] == '.' and f_output[-2] == '.':
                f_output = f_output[:-2]

            f_output = f_output + '.'

            f_output = self.remove_trailing_dots(f_output)
            f_output = f_output.replace('..', '.')

            return f_output

        else:
            return sent
コード例 #2
0
def output():
    text2 = text.get("1.0", "end-1c")
    parser = GingerIt()
    output1 = parser.parse(text2)
    text3 = tk.Text(root, width=40, height=30)
    text3.place(x=500, y=50)
    text3.insert(tk.END, output1.get("result"))
コード例 #3
0
 def test(self):
     j = 0
     text = "".join([int_to_vocab[i] for i in noise_maker(good_sentences[j], 0.99)]) + " "
     parser = GingerIt()
     output = parser.parse(text)
     self.assertEqual(
         output.get("result"), "".join([int_to_vocab[i] for i in good_sentences[j]])
     )
コード例 #4
0
ファイル: model.py プロジェクト: gabbyprecious/HNG-IsThisReal
def check(mail):
    f = word(mail, 'sentence')
    corrections = 0
    for s in f:
        g = GingerIt()
        h = g.parse(s)
        corrections += len(h['corrections'])
    return corrections
コード例 #5
0
    def correct_string(self):
        text = self.input_textEdit.toPlainText()

        #self.input_textEdit.clear()
        text = text + " "  #added because wasnt parsing till the end
        text_compare = text

        parser = GingerIt()
        a = parser.parse(text)  #stored in a dictionary
        #print(a)
        if a["result"][0] == " ":
            self.output_textEdit.setText(a["result"][1:])
        else:
            self.output_textEdit.setText(a["result"])
        '''if a["result"][0]==" ":
コード例 #6
0
def checker_model_messages(id):
    all_data = Messages.query.get(id)

    text_message_unknown = all_data.message_unknown

    parser = GingerIt()

    results_dictionary = parser.parse(text_message_unknown)

    all_data.message_unknown = results_dictionary['result']

    db.session.commit()
    flash("Row {} has been corrected successfully!".format(all_data.id),
          "success")

    return redirect(url_for('table'))
コード例 #7
0
    def start(self, text):
        ret = []
        result = GingerIt().parse(text)
        for correction in result.get('corrections'):
            if len(result.get('corrections')) > 0:
                self.start_positions.append(correction.get('start'))
                self.end_positions.append(
                    correction.get('start') + len(correction.get('text')) - 1)
                self.my_mistakes.append(correction.get('text'))
                self.my_corrections.append(correction.get('correct'))

        ret = {
            "mistakes": self.my_mistakes,
            "corrections": self.my_corrections,
            "start_posititons": self.start_positions,
            "end_position": self.end_positions
        }
        return len(result.get('corrections')), ret