def __parse_with_freeling(self):
        self.progressDialog = ProgressDialog(self.parent)

        try:

            freeling_path = ConfigurationManager.load()['freeling_path']

            string = self.input_text_area.get("1.0", END)

            if self.tagger_var.get() == 'FreeLing':
                tagger = None
            else:
                tagger_path = ConfigurationManager.load()['treetagger_path']
                tagger = TreeTagger(tagger_path)

            parser = FreeLing(freeling_path, tagger=tagger)

            tree = next(parser.raw_parse(string))

            self.output_text_area.delete(1.0, END)

            tree_str = str(tree)

            self.output_text_area.insert(INSERT, str(tree_str))
        finally:
            self.stop_progressbar()
    def __parse_with_stanford(self):
        self.progressDialog = ProgressDialog(self.parent)

        try:
            parser_path = ConfigurationManager.load()['stanfordsr_path']
            parser_model_path = ConfigurationManager.load()['stanfordsr_model_path']
            freeling_path = ConfigurationManager.load()['freeling_path']

            string = self.input_text_area.get("1.0", END)
            # string = string.rstrip()
            # string = "[" + string + "]"
            # string = string.replace("\n", ",")

            tagger = inco.nlp.tag.freeling.FreeLing(freeling_path)

            parser = StanfordShiftReduceParser(parser_path, parser_model_path, tagger=tagger)

            tree = next(parser.raw_parse(string))

            tree_str = str(tree)

            self.output_text_area.delete(1.0, END)
            self.output_text_area.insert(INSERT, tree_str)
        finally:
            self.stop_progressbar()
    def __parse_with_maltparser(self):
        self.progressDialog = ProgressDialog(self.parent)

        try:
            parser_path = ConfigurationManager.load()['maltparser_path']
            parser_model_path = ConfigurationManager.load()['maltparser_model_path']

            if self.tagger_var.get() == 'FreeLing':
                tagger_path = ConfigurationManager.load()['freeling_path']
                tagger = inco.nlp.tag.freeling.FreeLing(tagger_path)
            else:
                tagger_path = ConfigurationManager.load()['treetagger_path']
                tagger = TreeTagger(tagger_path)

            string = self.input_text_area.get("1.0", END)

            parser = MaltParser(parser_path, parser_model_path, tagger=tagger)

            tree = next(parser.raw_parse(string))

            tree_str = str(tree)

            self.output_text_area.delete(1.0, END)
            self.output_text_area.insert(INSERT, tree_str)
        finally:
            self.stop_progressbar()
 def __apply_configuration(self):
     ConfigurationManager.save(self.var_freeling_path.get(),
                               self.var_treetagger_path.get(),
                               self.var_maltparser_path.get(),
                               self.var_maltparser_model_path.get(),
                               self.var_stanfordsr_path.get(),
                               self.var_stanfordsr_model_path.get(),
     )
 def __apply_configuration(self):
     ConfigurationManager.save(
         self.var_freeling_path.get(),
         self.var_treetagger_path.get(),
         self.var_maltparser_path.get(),
         self.var_maltparser_model_path.get(),
         self.var_stanfordsr_path.get(),
         self.var_stanfordsr_model_path.get(),
     )
    def __tag_with_treetagger(self):
        self.progressDialog = ProgressDialog(self.parent)

        try:

            path = ConfigurationManager.load()['treetagger_path']

            string = self.input_text_area.get("1.0", END)

            try:
                tagger = TreeTagger(path)
                tokens_dict = tagger.raw_tag_full(string)
            except:
                tkMessageBox.showerror("Error", "TreeTagger is not configured correctly, please verify path.")
                return

            tokens_dict_array = [str(x) for x in tokens_dict]

            tokenized_string = "\n".join(tokens_dict_array)

            self.output_text_area['state'] = 'normal'

            self.output_text_area.delete(1.0, END)
            self.output_text_area.insert(INSERT, tokenized_string)

            self.output_text_area['state'] = 'disabled'
        finally:
            self.progressDialog.close()
    def __tokenize_with_freeling(self):
        self.progressDialog = ProgressDialog(self.parent)

        try:
            freeling_path = ConfigurationManager.load()['freeling_path']

            string = self.input_text_area.get("1.0", END)

            try:
                tokenizer = FreeLing(freeling_path)
                tokens = tokenizer.tokenize(string)
            except:
                tkMessageBox.showerror("Error", "FreeLing is not configured correctly, please verify path.")
                return

            tokenized_string = "\n".join(tokens)

            self.output_text_area['state'] = 'normal'

            self.output_text_area.delete(1.0, END)
            self.output_text_area.insert(INSERT, tokenized_string)

            self.output_text_area['state'] = 'disabled'
        finally:
            self.progressDialog.close()
Example #8
0
    def __tokenize_with_freeling(self):
        self.progressDialog = ProgressDialog(self.parent)

        try:
            freeling_path = ConfigurationManager.load()['freeling_path']

            string = self.input_text_area.get("1.0", END)

            try:
                tokenizer = FreeLing(freeling_path)
                tokens = tokenizer.tokenize(string)
            except:
                tkMessageBox.showerror(
                    "Error",
                    "FreeLing is not configured correctly, please verify path."
                )
                return

            tokenized_string = "\n".join(tokens)

            self.output_text_area['state'] = 'normal'

            self.output_text_area.delete(1.0, END)
            self.output_text_area.insert(INSERT, tokenized_string)

            self.output_text_area['state'] = 'disabled'
        finally:
            self.progressDialog.close()
    def open_configuration(self):
        filewin = Tkinter.Toplevel(self.parent)
        filewin.wm_title('Configuration')
        filewin.wm_transient(self.parent)

        i = 0

        label = Tkinter.Label(filewin, text="Configure path to binaries")
        label.grid(row=i, column=0)
        i += 1

        label = Tkinter.Label(filewin, text="FreeLing")
        label.grid(row=i, column=0)
        entry_freeling = Tkinter.Entry(filewin, width=100, textvariable=self.var_freeling_path)
        entry_freeling.grid(row=i, column=1)
        control = Tkinter.Button(filewin, text="Browse...", command=self.browse_freeling)
        control.grid(row=1, column=2)
        i += 1

        label = Tkinter.Label(filewin, text="TreeTagger")
        label.grid(row=i, column=0)
        entry_treetagger = Tkinter.Entry(filewin, width=100, textvariable=self.var_treetagger_path)
        entry_treetagger.grid(row=i, column=1)
        control = Tkinter.Button(filewin, text="Browse...", command=self.browse_treetagger)
        control.grid(row=i, column=2)
        i += 1

        label = Tkinter.Label(filewin, text="MaltParser")
        label.grid(row=i, column=0)
        entry_maltparser = Tkinter.Entry(filewin, width=100, textvariable=self.var_maltparser_path)
        entry_maltparser.grid(row=i, column=1)
        control = Tkinter.Button(filewin, text="Browse...", command=self.browse_maltparser)
        control.grid(row=i, column=2)
        i += 1

        label = Tkinter.Label(filewin, text="MaltParser Spanish model")
        label.grid(row=i, column=0)
        entry = Tkinter.Entry(filewin, width=100, textvariable=self.var_maltparser_model_path)
        entry.grid(row=i, column=1)
        control = Tkinter.Button(filewin, text="Browse...", command=self.browse_maltparser_model)
        control.grid(row=i, column=2)
        i += 1

        label = Tkinter.Label(filewin, text="Stanford Shift-Reduce")
        label.grid(row=i, column=0)
        entry = Tkinter.Entry(filewin, width=100, textvariable=self.var_stanfordsr_path)
        entry.grid(row=i, column=1)
        control = Tkinter.Button(filewin, text="Browse...", command=self.browse_stanfordsr)
        control.grid(row=i, column=2)
        i += 1

        label = Tkinter.Label(filewin, text="Stanford SR Spanish model")
        label.grid(row=i, column=0)
        entry = Tkinter.Entry(filewin, width=100, textvariable=self.var_stanfordsr_model_path)
        entry.grid(row=i, column=1)
        control = Tkinter.Button(filewin, text="Browse...", command=self.browse_stanfordsr_model)
        control.grid(row=i, column=2)
        i += 1

        control = Tkinter.Button(filewin, text="Apply", command=self.__apply_configuration)
        control.grid(row=i, columnspan=2)

        # load saved settings
        settings = ConfigurationManager.load()
        if settings is not None:
            self.var_freeling_path.set(settings['freeling_path'])
            self.var_treetagger_path.set(settings['treetagger_path'])
            self.var_maltparser_path.set(settings['maltparser_path'])
            self.var_maltparser_model_path.set(settings['maltparser_model_path'])
            self.var_stanfordsr_path.set(settings['stanfordsr_path'])
            self.var_stanfordsr_model_path.set(settings['stanfordsr_model_path'])

        self.read_delegate = None
    def open_configuration(self):
        filewin = Tkinter.Toplevel(self.parent)
        filewin.wm_title('Configuration')
        filewin.wm_transient(self.parent)

        i = 0

        label = Tkinter.Label(filewin, text="Configure path to binaries")
        label.grid(row=i, column=0)
        i += 1

        label = Tkinter.Label(filewin, text="FreeLing")
        label.grid(row=i, column=0)
        entry_freeling = Tkinter.Entry(filewin,
                                       width=100,
                                       textvariable=self.var_freeling_path)
        entry_freeling.grid(row=i, column=1)
        control = Tkinter.Button(filewin,
                                 text="Browse...",
                                 command=self.browse_freeling)
        control.grid(row=1, column=2)
        i += 1

        label = Tkinter.Label(filewin, text="TreeTagger")
        label.grid(row=i, column=0)
        entry_treetagger = Tkinter.Entry(filewin,
                                         width=100,
                                         textvariable=self.var_treetagger_path)
        entry_treetagger.grid(row=i, column=1)
        control = Tkinter.Button(filewin,
                                 text="Browse...",
                                 command=self.browse_treetagger)
        control.grid(row=i, column=2)
        i += 1

        label = Tkinter.Label(filewin, text="MaltParser")
        label.grid(row=i, column=0)
        entry_maltparser = Tkinter.Entry(filewin,
                                         width=100,
                                         textvariable=self.var_maltparser_path)
        entry_maltparser.grid(row=i, column=1)
        control = Tkinter.Button(filewin,
                                 text="Browse...",
                                 command=self.browse_maltparser)
        control.grid(row=i, column=2)
        i += 1

        label = Tkinter.Label(filewin, text="MaltParser Spanish model")
        label.grid(row=i, column=0)
        entry = Tkinter.Entry(filewin,
                              width=100,
                              textvariable=self.var_maltparser_model_path)
        entry.grid(row=i, column=1)
        control = Tkinter.Button(filewin,
                                 text="Browse...",
                                 command=self.browse_maltparser_model)
        control.grid(row=i, column=2)
        i += 1

        label = Tkinter.Label(filewin, text="Stanford Shift-Reduce")
        label.grid(row=i, column=0)
        entry = Tkinter.Entry(filewin,
                              width=100,
                              textvariable=self.var_stanfordsr_path)
        entry.grid(row=i, column=1)
        control = Tkinter.Button(filewin,
                                 text="Browse...",
                                 command=self.browse_stanfordsr)
        control.grid(row=i, column=2)
        i += 1

        label = Tkinter.Label(filewin, text="Stanford SR Spanish model")
        label.grid(row=i, column=0)
        entry = Tkinter.Entry(filewin,
                              width=100,
                              textvariable=self.var_stanfordsr_model_path)
        entry.grid(row=i, column=1)
        control = Tkinter.Button(filewin,
                                 text="Browse...",
                                 command=self.browse_stanfordsr_model)
        control.grid(row=i, column=2)
        i += 1

        control = Tkinter.Button(filewin,
                                 text="Apply",
                                 command=self.__apply_configuration)
        control.grid(row=i, columnspan=2)

        # load saved settings
        settings = ConfigurationManager.load()
        if settings is not None:
            self.var_freeling_path.set(settings['freeling_path'])
            self.var_treetagger_path.set(settings['treetagger_path'])
            self.var_maltparser_path.set(settings['maltparser_path'])
            self.var_maltparser_model_path.set(
                settings['maltparser_model_path'])
            self.var_stanfordsr_path.set(settings['stanfordsr_path'])
            self.var_stanfordsr_model_path.set(
                settings['stanfordsr_model_path'])

        self.read_delegate = None