Пример #1
0
    def createNoteFilterTab(self):
        self.frame1 = QWidget()
        self.tabWidget.addTab(self.frame1, "Note Filter")
        vbox = QVBoxLayout(); self.frame1.setLayout(vbox); vbox.setContentsMargins(0, 20, 0, 0)

        self.tableModel = QStandardItemModel(0, 5)
        self.tableView = QTableView()
        self.tableView.setModel(self.tableModel)
        self.tableView.horizontalHeader().setResizeMode(QHeaderView.Stretch)
        self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tableView.setSelectionMode(QAbstractItemView.SingleSelection)
        self.tableModel.setHeaderData(0, Qt.Horizontal, "Note type")
        self.tableModel.setHeaderData(1, Qt.Horizontal, "Tags")
        self.tableModel.setHeaderData(2, Qt.Horizontal, "Fields")
        self.tableModel.setHeaderData(3, Qt.Horizontal, "Morphemizer")
        self.tableModel.setHeaderData(4, Qt.Horizontal, "Modify?")

        rowData = jcfg('Filter')
        self.tableModel.setRowCount(len(rowData))
        self.rowGui = []
        for i, row in enumerate(rowData):
            self.setTableRow(i, row)

        label = QLabel("Any card that has the given `Note type` and all of the given `Tags` will have its `Fields` analyzed with the specified `Morphemizer`. A morphemizer specifies how words are extraced from a sentence. `Fields` and `Tags` are both comma-separated lists. If `Tags` is empty, there are no tag restrictions. If `Modify` is deactivated, the note will only be analyzed.\n\nIf a note is matched multple times, only the first filter in this list will be used.")
        label.setWordWrap(True)
        vbox.addWidget(label)
        vbox.addSpacing(20)
        vbox.addWidget(self.tableView)

        hbox = QHBoxLayout(); vbox.addLayout(hbox)

        self.clone = mkBtn("Clone", self.onClone, self, hbox)
        self.delete = mkBtn("Delete", self.onDelete, self, hbox)
        self.up = mkBtn("Up", self.onUp, self, hbox)
        self.down = mkBtn("Down", self.onDown, self, hbox)
Пример #2
0
    def __init__(self, parent=None):
        super(AdaptiveSubWin, self).__init__(parent)
        self.setWindowTitle('Adaptive Subs')
        self.grid = grid = QGridLayout(self)
        self.vbox = vbox = QVBoxLayout()

        self.matureFmt = QLineEdit(u'%(jpn)s')
        self.knownFmt = QLineEdit(u'%(jpn)s [%(eng)s]')
        self.unknownFmt = QLineEdit(u'%(eng)s [%(N_k)s] [%(unknowns)s]')
        self.morphemizer = QComboBox()

        for morphemizer in getAllMorphemizers():
            self.morphemizer.addItem(morphemizer.getDescription())

        self.vbox.addWidget(QLabel('Mature Format'))
        self.vbox.addWidget(self.matureFmt)
        self.vbox.addWidget(QLabel('Known Format'))
        self.vbox.addWidget(self.knownFmt)
        self.vbox.addWidget(QLabel('Unknown Format'))
        self.vbox.addWidget(self.unknownFmt)
        self.vbox.addWidget(QLabel('Morpheme Engine (Morphemizer)'))
        self.vbox.addWidget(self.morphemizer)

        self.goBtn = mkBtn('Convert subs', self.onGo, self, vbox)

        grid.addLayout(vbox, 0, 0)
Пример #3
0
    def __init__( self, parent=None ):
        super( AdaptiveSubWin, self ).__init__( parent )
        self.setWindowTitle( 'Adaptive Subs' )
        self.grid = grid = QGridLayout( self )
        self.vbox = vbox = QVBoxLayout()

        self.matureFmt  = QLineEdit( u'%(jpn)s' )
        self.knownFmt   = QLineEdit( u'%(jpn)s [%(eng)s]' )
        self.unknownFmt = QLineEdit( u'%(eng)s [%(N_k)s] [%(unknowns)s]' )
        self.morphemizer = QComboBox()

        for morphemizer in getAllMorphemizers():
            self.morphemizer.addItem(morphemizer.getDescription())

        self.vbox.addWidget( QLabel( 'Mature Format' ) )
        self.vbox.addWidget( self.matureFmt )
        self.vbox.addWidget( QLabel( 'Known Format' ) )
        self.vbox.addWidget( self.knownFmt )
        self.vbox.addWidget( QLabel( 'Unknown Format' ) )
        self.vbox.addWidget( self.unknownFmt )
        self.vbox.addWidget( QLabel( 'Morpheme Engine (Morphemizer)' ) )
        self.vbox.addWidget( self.morphemizer )

        self.goBtn = mkBtn( 'Convert subs', self.onGo, self, vbox )

        grid.addLayout( vbox, 0, 0 )
Пример #4
0
    def createNoteFilterTab(self):
        self.frame1 = QWidget()
        self.tabWidget.addTab(self.frame1, "Note Filter")
        vbox = QVBoxLayout()
        self.frame1.setLayout(vbox)
        vbox.setContentsMargins(0, 20, 0, 0)

        self.tableModel = QStandardItemModel(0, 5)
        self.tableView = QTableView()
        self.tableView.setModel(self.tableModel)
        self.tableView.horizontalHeader().setResizeMode(QHeaderView.Stretch)
        self.tableView.setSelectionBehavior(QAbstractItemView.SelectRows)
        self.tableView.setSelectionMode(QAbstractItemView.SingleSelection)
        self.tableModel.setHeaderData(0, Qt.Horizontal, "Note type")
        self.tableModel.setHeaderData(1, Qt.Horizontal, "Tags")
        self.tableModel.setHeaderData(2, Qt.Horizontal, "Fields")
        self.tableModel.setHeaderData(3, Qt.Horizontal, "Morphemizer")
        self.tableModel.setHeaderData(4, Qt.Horizontal, "Modify?")

        rowData = jcfg('Filter')
        self.tableModel.setRowCount(len(rowData))
        self.rowGui = []
        for i, row in enumerate(rowData):
            self.setTableRow(i, row)

        label = QLabel(
            "Any card that has the given `Note type` and all of the given `Tags` will have its `Fields` analyzed with the specified `Morphemizer`. A morphemizer specifies how words are extraced from a sentence. `Fields` and `Tags` are both comma-separated lists. If `Tags` is empty, there are no tag restrictions. If `Modify` is deactivated, the note will only be analyzed.\n\nIf a note is matched multple times, the first line will take precedence."
        )
        label.setWordWrap(True)
        vbox.addWidget(label)
        vbox.addSpacing(20)
        vbox.addWidget(self.tableView)

        hbox = QHBoxLayout()
        vbox.addLayout(hbox)

        self.clone = mkBtn("Clone", self.onClone, self, hbox)
        self.delete = mkBtn("Delete", self.onDelete, self, hbox)
        self.up = mkBtn("Up", self.onUp, self, hbox)
        self.down = mkBtn("Down", self.onDown, self, hbox)
Пример #5
0
    def __init__(self, parent=None):
        super(MorphMan, self).__init__(parent)
        self.mw = parent
        self.setWindowTitle('Morph Man 3 Manager')
        self.grid = grid = QGridLayout(self)
        self.vbox = vbox = QVBoxLayout()

        # DB Paths
        self.aPathLEdit = QLineEdit()
        vbox.addWidget(self.aPathLEdit)
        self.aPathBtn = mkBtn('Browse for DB A',
                              lambda le=self.aPathLEdit: getPath(le),
                              self,
                              vbox)

        self.bPathLEdit = QLineEdit()
        vbox.addWidget(self.bPathLEdit)
        self.bPathBtn = mkBtn('Browse for DB B',
                              lambda le=self.bPathLEdit: getPath(le),
                              self,
                              vbox)

        # Comparisons
        self.showABtn = mkBtn('A', self.onShowA, self, vbox)
        self.AmBBtn = mkBtn('A-B', lambda x='A-B': self.onDiff(x), self, vbox)
        self.BmABtn = mkBtn('B-A', lambda x='B-A': self.onDiff(x), self, vbox)
        self.symBtn = mkBtn('Symmetric Difference',
                            lambda x='sym': self.onDiff(x),
                            self,
                            vbox)
        self.interBtn = mkBtn('Intersection',
                              lambda x='inter': self.onDiff(x),
                              self,
                              vbox)
        self.unionBtn = mkBtn('Union',
                              lambda x='union': self.onDiff(x),
                              self,
                              vbox)

        # Creation
        ## language class/morphemizer
        self.db = None
        self.morphemizerComboBox = QComboBox()
        for morphemizer in getAllMorphemizers():
            self.morphemizerComboBox.addItem(morphemizer.getDescription())

        vbox.addSpacing(40)
        vbox.addWidget(self.morphemizerComboBox)
        self.extractTxtFileBtn = mkBtn('Extract morphemes from file',
                                       self.onExtractTxtFile, self, vbox)
        self.saveResultsBtn = mkBtn('Save results to db', self.onSaveResults,
                                    self, vbox)

        # Display
        vbox.addSpacing(40)
        self.col4Mode = QRadioButton('Results as 4col morpheme')
        self.col4Mode.setChecked(True)
        self.col1Mode = QRadioButton('Results as 1col morpheme')
        vbox.addWidget(self.col4Mode)
        vbox.addWidget(self.col1Mode)
        self.morphDisplay = QTextEdit()
        self.analysisDisplay = QTextEdit()

        # Exporting
        self.adaptiveSubs = mkBtn('Adaptive Subs', self.adaptiveSubs, self,
                                  vbox)

        # layout
        grid.addLayout(vbox, 0, 0)
        grid.addWidget(self.morphDisplay, 0, 1)
        grid.addWidget(self.analysisDisplay, 0, 2)
Пример #6
0
    def __init__( self, parent=None ):
        super( MorphMan, self ).__init__( parent )
        self.mw = parent
        self.setWindowTitle( 'Morph Man 3 Manager' )
        self.grid = grid = QGridLayout( self )
        self.vbox = vbox = QVBoxLayout()

        # DB Paths
        self.aPathLEdit = QLineEdit()
        vbox.addWidget( self.aPathLEdit )
        self.aPathBtn = mkBtn( 'Browse for DB A', lambda le=self.aPathLEdit: getPath( le ), self, vbox )

        self.bPathLEdit = QLineEdit()
        vbox.addWidget( self.bPathLEdit )
        self.bPathBtn = mkBtn( 'Browse for DB B', lambda le=self.bPathLEdit: getPath( le ), self, vbox )

        # Comparisons
        self.showABtn = mkBtn( 'A', self.onShowA, self, vbox )
        self.AmBBtn = mkBtn( 'A-B', lambda x='A-B': self.onDiff(x), self, vbox )
        self.BmABtn = mkBtn( 'B-A', lambda x='B-A': self.onDiff(x), self, vbox )
        self.symBtn = mkBtn( 'Symmetric Difference', lambda x='sym': self.onDiff(x), self, vbox )
        self.interBtn = mkBtn( 'Intersection', lambda x='inter': self.onDiff(x), self, vbox )
        self.unionBtn = mkBtn( 'Union', lambda x='union': self.onDiff(x), self, vbox )

        # Creation
        ## language class/morphemizer
        self.db = None
        self.morphemizerComboBox = QComboBox()
        for morphemizer in getAllMorphemizers():
            self.morphemizerComboBox.addItem(morphemizer.getDescription())

        vbox.addSpacing(40)
        vbox.addWidget(self.morphemizerComboBox)
        self.extractTxtFileBtn = mkBtn( 'Extract morphemes from file', self.onExtractTxtFile, self, vbox )
        self.saveResultsBtn = mkBtn( 'Save results to db', self.onSaveResults, self, vbox )


        # Display
        vbox.addSpacing(40)
        self.col4Mode = QRadioButton( 'Results as 4col morpheme' )
        self.col4Mode.setChecked( True )
        self.col1Mode = QRadioButton( 'Results as 1col morpheme' )
        vbox.addWidget( self.col4Mode )
        vbox.addWidget( self.col1Mode )
        self.morphDisplay = QTextEdit()
        self.analysisDisplay = QTextEdit()

        # Exporting
        self.adaptiveSubs = mkBtn( 'Adaptive Subs', self.adaptiveSubs, self, vbox )

        # layout
        grid.addLayout( vbox, 0, 0 )
        grid.addWidget( self.morphDisplay, 0, 1 )
        grid.addWidget( self.analysisDisplay, 0, 2 )