コード例 #1
0
    def __init__(self, coderName, parent=None):
        super().__init__(parent=parent)
        self.setWindowTitle('Edit default coder name')

        self._coderName = coderName

        layout = QVBoxLayout()
        self.setLayout(layout)

        inputLayout = QHBoxLayout()
        layout.addLayout(inputLayout)

        self.coderNameLineEdit = QLineEdit(self._coderName)
        inputLayout.addWidget(QLabel('Default coder:'))
        inputLayout.addWidget(self.coderNameLineEdit)

        buttonLayout = QHBoxLayout()
        layout.addLayout(buttonLayout)

        okButton = QPushButton('Ok')
        buttonLayout.addWidget(okButton)
        okButton.clicked.connect(self.accept)

        cancelButton = QPushButton('Cancel')
        buttonLayout.addWidget(cancelButton)
        cancelButton.clicked.connect(self.reject)
コード例 #2
0
    def __init__(self, results):
        super().__init__()
        self.setWindowTitle('Search Results')
        layout = QVBoxLayout()
        self.result = None

        resultsLayout = QHBoxLayout()

        self.resultsList = QListWidget()
        for r in results:
            self.resultsList.addItem(r.gloss)

        resultsLayout.addWidget(self.resultsList)
        layout.addLayout(resultsLayout)

        buttonLayout = QHBoxLayout()
        okButton = QPushButton('Go to this entry')
        cancelButton = QPushButton('Cancel')
        okButton.clicked.connect(self.accept)
        cancelButton.clicked.connect(self.reject)
        buttonLayout.addWidget(okButton)
        buttonLayout.addWidget(cancelButton)

        layout.addLayout(buttonLayout)

        self.setLayout(layout)
コード例 #3
0
    def __init__(self, recents, favourites=None):
        if favourites is None:
            favourites = list()
        super().__init__()
        self.setWindowTitle('Recent Searches')
        self.result = None
        layout = QVBoxLayout()

        tableLayout = QHBoxLayout()

        self.recentTable = RecentSearchTable(recents, 'Add to favourites')
        tableLayout.addWidget(self.recentTable)

        self.favouriteTable = RecentSearchTable(favourites,
                                                'Remove from favourites')
        tableLayout.addWidget(self.favouriteTable)

        buttonLayout = QHBoxLayout()
        ok = QPushButton('Use selected search')
        ok.clicked.connect(self.accept)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.reject)
        buttonLayout.addWidget(ok)
        buttonLayout.addWidget(cancel)

        layout.addLayout(tableLayout)
        layout.addLayout(buttonLayout)

        self.setLayout(layout)

        self.resize(self.recentTable.width() * 1.5, self.height())
コード例 #4
0
    def __init__(self, corpus):
        super().__init__()
        self.setWindowTitle('Search by gloss')

        layout = QVBoxLayout()

        searchLayout = QHBoxLayout()

        searchLabel = QLabel('Enter gloss to search for: ')
        searchLayout.addWidget(searchLabel)

        self.searchEdit = QLineEdit()
        completer = QCompleter()
        model = QStringListModel()
        model.setStringList([word.gloss for word in corpus])
        completer.setModel(model)
        completer.setCaseSensitivity(Qt.CaseInsensitive)
        self.searchEdit.setCompleter(completer)
        searchLayout.addWidget(self.searchEdit)

        buttonLayout = QHBoxLayout()
        ok = QPushButton('OK')
        ok.clicked.connect(self.accept)
        buttonLayout.addWidget(ok)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.reject)
        buttonLayout.addWidget(cancel)

        layout.addLayout(searchLayout)
        layout.addLayout(buttonLayout)

        self.setLayout(layout)
コード例 #5
0
    def __init__(self):
        super().__init__('Number of extended fingers')

        groupLayout = QVBoxLayout()
        self.setLayout(groupLayout)

        logicComment = QLabel('Returned signs will contain ANY of the specificed numbers:')
        groupLayout.addWidget(logicComment)

        buttonLayout = QHBoxLayout()
        groupLayout.addLayout(buttonLayout)

        self.zero = QCheckBox('0')
        self.one = QCheckBox('1')
        self.two = QCheckBox('2')
        self.three = QCheckBox('3')
        self.four = QCheckBox('4')
        self.five = QCheckBox('5')
        self.zero.setChecked(True)
        self.one.setChecked(True)
        self.two.setChecked(True)
        self.three.setChecked(True)
        self.four.setChecked(True)
        self.five.setChecked(True)

        buttonLayout.addWidget(self.zero)
        buttonLayout.addWidget(self.one)
        buttonLayout.addWidget(self.two)
        buttonLayout.addWidget(self.three)
        buttonLayout.addWidget(self.four)
        buttonLayout.addWidget(self.five)
コード例 #6
0
    def __init__(self, model, checkStrategy=None):
        super().__init__()
        self.setWindowFlags(Qt.WindowStaysOnTopHint)
        self.setWindowTitle('Select Parameters')
        self.adjustedHeight = self.frameGeometry().height()
        self.adjustedWidth = self.frameGeometry().width()
        self.adjustedPos = self.pos()

        self.model = model
        self.model.itemChanged.connect(self.updateDisplayTree)

        self.treeView = ParameterTreeView()
        self.treeView.setModel(self.model)
        self.treeView.clicked.connect(self.updateDisplayTree)

        self.displayTree = anytree.Node('Selected Parameters', parent=None)
        self.displayTreeWidget = QTextEdit()
        self.displayTreeWidget.setReadOnly(True)

        layout = QVBoxLayout()
        self.selectionLayout = QVBoxLayout()
        self.parameterLayout = QHBoxLayout()
        self.selectionLayout.addWidget(self.displayTreeWidget)
        self.parameterLayout.addWidget(self.treeView)
        self.parameterLayout.addLayout(self.selectionLayout)

        self.buildDisplayTree(self.model.invisibleRootItem(), self.displayTree)
        self.generateDisplayTreeText()

        terminalNodesLayout = QVBoxLayout()
        self.terminalNodesLabel = QTextEdit('No parameters selected')
        self.terminalNodesLabel.setReadOnly(True)
        terminalNodesLayout.addWidget(self.terminalNodesLabel)
        self.parameterLayout.addLayout(terminalNodesLayout)
        self.updateTerminalNodes()

        buttonLayout = QGridLayout()
        okButton = QPushButton('OK')
        cancelButton = QPushButton('Cancel')
        resetButton = QPushButton('Reset to default values')
        clearButton = QPushButton('Clear all check boxes')
        buttonLayout.addWidget(resetButton, 0, 0)
        buttonLayout.addWidget(clearButton, 0, 1)
        buttonLayout.addWidget(okButton, 1, 0)
        buttonLayout.addWidget(cancelButton, 1, 1)
        okButton.clicked.connect(self.accept)
        cancelButton.clicked.connect(self.reject)
        resetButton.clicked.connect(self.reset)
        clearButton.clicked.connect(self.clear)

        layout.addLayout(self.parameterLayout)
        layout.addLayout(buttonLayout)

        self.setLayout(layout)
        self.resize(self.adjustedHeight, self.adjustedWidth)
        self.move(self.adjustedPos)
コード例 #7
0
    def __init__(self):
        super().__init__()

        self.hand1Trans = TransLayout(1)
        self.hand2Trans = TransLayout(2)

        mainLayout = QVBoxLayout()
        mainLayout.addLayout(self.hand1Trans)
        mainLayout.addLayout(self.hand2Trans)
        self.setLayout(mainLayout)
コード例 #8
0
    def __init__(self, constraints):
        super().__init__()
        self.setWindowTitle('Select constraints')
        self.constraints = constraints
        layout = QVBoxLayout()

        self.transcriptionPage = QWidget()
        self.populateTranscriptionPage()
        self.simplePage = QWidget()
        self.populateSimplePage()
        self.conditionalPage = QWidget()
        self.populateConditionalPage()

        self.pageSelection = QComboBox()
        self.pageSelection.addItem('Transcription Constraints')
        self.pageSelection.addItem('Simple Constraints')
        self.pageSelection.addItem('Conditional Constraints')
        layout.addWidget(self.pageSelection)

        self.pages = QStackedWidget()
        self.pages.addWidget(self.transcriptionPage)
        self.pages.addWidget(self.simplePage)
        self.pages.addWidget(self.conditionalPage)
        self.pageSelection.currentIndexChanged.connect(self.pages.setCurrentIndex)
        self.pages.setCurrentIndex(0)
        layout.addWidget(self.pages)

        buttonLayout = QHBoxLayout()
        selectThisPageButton = QPushButton('Select all (this page)')
        selectThisPageButton.clicked.connect(self.selectThisPage)
        buttonLayout.addWidget(selectThisPageButton)
        selectAllButton = QPushButton('Select all (global)')
        selectAllButton.clicked.connect(self.selectAll)
        buttonLayout.addWidget(selectAllButton)
        removeThisPageButton = QPushButton('Unselect all (this page)')
        removeThisPageButton.clicked.connect(self.removeThisPage)
        buttonLayout.addWidget(removeThisPageButton)
        removeAllButton = QPushButton('Unselect all (global)')
        removeAllButton.clicked.connect(self.removeAll)
        buttonLayout.addWidget(removeAllButton)
        okCancelLayout = QHBoxLayout()
        ok = QPushButton('OK')
        cancel = QPushButton('Cancel')
        ok.clicked.connect(self.accept)
        cancel.clicked.connect(self.reject)
        okCancelLayout.addWidget(ok)
        okCancelLayout.addWidget(cancel)
        layout.addLayout(buttonLayout)
        layout.addLayout(okCancelLayout)

        self.setLayout(layout)
コード例 #9
0
    def __init__(self, blankOptionSelection=None, wildcard=None):
        super().__init__()

        self.blankOptionSelection = blankOptionSelection
        self.wildcard = wildcard

        self.setWindowTitle('Search Options')
        layout = QVBoxLayout()

        blankOptionsLabel = QLabel(
            'How should blank spaces be interpreted in your search?')
        layout.addWidget(blankOptionsLabel)

        blankOptionsLayout = QVBoxLayout()
        self.blankOptionsGroup = QButtonGroup()

        asBlankOption = QRadioButton(
            'Interpret as literal blanks, and only match blank slots')
        blankOptionsLayout.addWidget(asBlankOption)
        self.blankOptionsGroup.addButton(asBlankOption)
        self.blankOptionsGroup.setId(asBlankOption, 0)
        if self.blankOptionSelection == 'literal':
            asBlankOption.setChecked(True)

        asWildcardOption = QRadioButton(
            'Interpret as wildcards, and match anything')
        blankOptionsLayout.addWidget(asWildcardOption)
        self.blankOptionsGroup.addButton(asWildcardOption)
        self.blankOptionsGroup.setId(asWildcardOption, 1)
        if self.blankOptionSelection == 'wildcard' or self.blankOptionSelection is None:
            asWildcardOption.setChecked(True)

        miniLayout = QHBoxLayout()
        asBlankWithWildcard = QRadioButton(
            'Interpret as literal blanks, and use this character for wildcards: '
        )
        self.wildcardLineEdit = QLineEdit()
        self.wildcardLineEdit.setMaxLength(1)
        self.wildcardLineEdit.setMaximumWidth(30)
        self.blankOptionsGroup.addButton(asBlankWithWildcard)
        self.blankOptionsGroup.setId(asBlankWithWildcard, 2)
        if self.blankOptionSelection == 'both':
            asBlankWithWildcard.setChecked(True)
            self.wildcardLineEdit.setText(self.wildcard)
        miniLayout.addWidget(asBlankWithWildcard)
        miniLayout.addWidget(self.wildcardLineEdit)
        blankOptionsLayout.addLayout(miniLayout)

        layout.addLayout(blankOptionsLayout)

        buttonLayout = QHBoxLayout()
        ok = QPushButton('OK')
        ok.clicked.connect(self.accept)
        buttonLayout.addWidget(ok)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.reject)
        buttonLayout.addWidget(cancel)
        layout.addLayout(buttonLayout)

        self.setLayout(layout)
コード例 #10
0
    def __init__(self, parent, settings, worker):
        super().__init__(parent)

        self.settings = settings

        self.setWindowTitle(self.name.title())

        self.newTableButton = QPushButton('Run/Restart')
        self.newTableButton.setDefault(True)
        self.newTableButton.clicked.connect(self.newTable)

        self.oldTableButton = QPushButton('Append to current results table')
        self.oldTableButton.clicked.connect(self.oldTable)

        self.cancelButton = QPushButton('Cancel')
        self.cancelButton.clicked.connect(self.reject)

        self.aboutButton = QPushButton('About {}...'.format(self.name))
        self.aboutButton.clicked.connect(self.open_about)

        acLayout = QHBoxLayout()
        acLayout.addWidget(self.newTableButton)
        acLayout.addWidget(self.oldTableButton)
        acLayout.addWidget(self.cancelButton)
        acLayout.addWidget(self.aboutButton)

        self.thread = worker
        self.thread.dataReady.connect(self.setResults)

        #if self.settings['tooltips']:
        #    self.aboutButton.setToolTip(('<FONT COLOR=black>'
        #                                 '{}'
        #                                 '</FONT>'.format('\n'.join(self.about)))
        #                                )

        majorLayout = QVBoxLayout()
        majorLayout.addLayout(acLayout)

        self.setLayout(majorLayout)
        self.resize(1000, 500)
コード例 #11
0
    def __init__(self, title, dialog, parent):
        super().__init__(parent=parent)
        self.setWindowTitle(title)
        self.dialog = dialog
        dataModel = ResultsTableModel(self.dialog.header, self.dialog.results)

        self.table = ResultsTableView()
        self.table.setModel(dataModel)
        self.table.horizontalHeader().setSectionResizeMode(
            QHeaderView.ResizeToContents)

        # The option buttons
        self.reopenButton = QPushButton('Reopen function dialog')
        self.reopenButton.clicked.connect(self.reopen)

        self.saveButton = QPushButton('Save to file')
        self.saveButton.clicked.connect(self.save)

        self.closeButton = QPushButton('Close window')
        self.closeButton.clicked.connect(self.reject)

        # Appearance
        self.table.resizeColumnsToContents()
        self.table.resizeRowsToContents()
        dialogWidth = self.table.horizontalHeader().length() + 25
        dialogHeight = self.table.verticalHeader().length() + 25
        self.resize(dialogWidth, dialogHeight)

        # Layout
        self.buttonLayout = QHBoxLayout()
        self.buttonLayout.addWidget(self.reopenButton)
        self.buttonLayout.addWidget(self.saveButton)
        self.buttonLayout.addWidget(self.closeButton)

        mainLayout = QVBoxLayout()
        mainLayout.addWidget(self.table)
        mainLayout.addLayout(self.buttonLayout)

        self.setLayout(mainLayout)
コード例 #12
0
    def __init__(self, parent, corpus):
        super().__init__()

        self.parent = parent
        self.corpus = corpus

        mainLayout = QVBoxLayout()
        self.setLayout(mainLayout)

        handShapeLayout = QVBoxLayout()
        mainLayout.addLayout(handShapeLayout)

        globalFrame = QGroupBox('Global options')
        globalLayout = QHBoxLayout()
        globalFrame.setLayout(globalLayout)
        handShapeLayout.addWidget(globalFrame)

        forearmButton = QCheckBox('Forearm')
        globalLayout.addWidget(forearmButton)
        estimatedButton = QCheckBox('Estimated')
        globalLayout.addWidget(estimatedButton)
        uncertainButton = QCheckBox('Uncertain')
        globalLayout.addWidget(uncertainButton)
        incompleteButton = QCheckBox('Incomplete')
        globalLayout.addWidget(incompleteButton)

        config1Frame = QGroupBox('Config 1')
        config1Layout = QVBoxLayout()
        config1Frame.setLayout(config1Layout)
        handShapeLayout.addWidget(config1Frame)

        config1 = TranscriptionConfigTab(1)
        config1Layout.addWidget(config1)

        config2Frame = QGroupBox('Config 2')
        config2Layout = QVBoxLayout()
        config2Frame.setLayout(config2Layout)
        handShapeLayout.addWidget(config2Frame)

        config2 = TranscriptionConfigTab(2)
        config2Layout.addWidget(config2)

        searchOptionLayout= QHBoxLayout()

        extendedFingerSearch = ExtendedFingerPanel()
        searchOptionLayout.addWidget(extendedFingerSearch)


        mainLayout.addLayout(searchOptionLayout)

        buttonLayout = QHBoxLayout()
        mainLayout.addLayout(buttonLayout)
        okButton = QPushButton('Search')
        recentButton = QPushButton('Show recent searches...')
        cancelButton = QPushButton('Cancel')
        buttonLayout.addWidget(okButton)
        buttonLayout.addWidget(recentButton)
        buttonLayout.addWidget(cancelButton)
コード例 #13
0
    def __init__(self):
        super().__init__('Finger configuration')
        mainLayout = QVBoxLayout()
        self.setLayout(mainLayout)

        fingerExtensionSpecificationLayout = QHBoxLayout()
        mainLayout.addLayout(fingerExtensionSpecificationLayout)

        self.optionsForT = FingerOptionGroup('Thumb')
        self.optionsForI = FingerOptionGroup('Index')
        self.optionsForM = FingerOptionGroup('Middle')
        self.optionsForR = FingerOptionGroup('Ring')
        self.optionsForP = FingerOptionGroup('Pinky')
        fingerExtensionSpecificationLayout.addWidget(self.optionsForT)
        fingerExtensionSpecificationLayout.addWidget(self.optionsForI)
        fingerExtensionSpecificationLayout.addWidget(self.optionsForM)
        fingerExtensionSpecificationLayout.addWidget(self.optionsForR)
        fingerExtensionSpecificationLayout.addWidget(self.optionsForP)

        self.logicGroup = LogicRadioButtonGroup('horizontal', 'a',
                                                title='Sign should contain:',
                                                a='All of the extensions',
                                                o='Any of the extensions')
        mainLayout.addWidget(self.logicGroup)
コード例 #14
0
    def __init__(self, corpus, recents, blankValue, wildcard):
        super().__init__()

        print('recents', recents)
        print('blankValue', blankValue)
        print('wildcard', wildcard)

        self.corpus = corpus
        self.recents = recents
        self.blankValue = blankValue
        self.wildcard = wildcard
        self.setWindowTitle('Search')
        self.setWindowFlags(Qt.WindowMaximizeButtonHint
                            | Qt.WindowMinimizeButtonHint
                            | Qt.WindowCloseButtonHint)

        layout = QVBoxLayout()

        #Set up up top layout
        self.topLayout = QHBoxLayout()
        explanation = QLabel()
        text = ('Enter the transcription you want to match in your corpus.')
        explanation.setText(text)
        explanation.setFont(QFont('Arial', 16))
        self.topLayout.addWidget(explanation)
        layout.addLayout(self.topLayout)

        #Set up config tabs
        self.configTabs = QTabWidget()
        self.configTabs.addTab(TranscriptionConfigTab(1), 'Config 1')
        self.configTabs.addTab(TranscriptionConfigTab(2), 'Config 2')
        layout.addWidget(self.configTabs)

        # Add "global" handshape options (as checkboxes)
        self.globalOptionsLayout = QHBoxLayout()
        self.setupGlobalOptions()
        layout.addLayout(self.globalOptionsLayout)

        #Add hand image
        self.infoPanel = QHBoxLayout()
        self.handImage = HandShapeImage(getMediaFilePath('hand.JPG'))
        self.infoPanel.addWidget(self.handImage)
        self.transcriptionInfo = TranscriptionInfo()
        self.infoPanel.addLayout(self.transcriptionInfo)
        layout.addLayout(self.infoPanel)

        #Connects some slots and signals
        for k in [0, 1]:
            for slot in self.configTabs.widget(k).hand1Transcription.slots[1:]:
                slot.slotSelectionChanged.connect(
                    self.handImage.useNormalImage)
                slot.slotSelectionChanged.connect(
                    self.handImage.transcriptionSlotChanged)
                slot.slotSelectionChanged.connect(
                    self.transcriptionInfo.transcriptionSlotChanged)
                slot.changeValidatorState(True)

            for slot in self.configTabs.widget(k).hand2Transcription.slots[1:]:
                slot.slotSelectionChanged.connect(
                    self.handImage.useReverseImage)
                slot.slotSelectionChanged.connect(
                    self.handImage.transcriptionSlotChanged)
                slot.slotSelectionChanged.connect(
                    self.transcriptionInfo.transcriptionSlotChanged)
                slot.changeValidatorState(True)

        buttonLayout = QHBoxLayout()
        blankOptionsButton = QPushButton('Search options...')
        blankOptionsButton.clicked.connect(self.showSearchOptions)
        buttonLayout.addWidget(blankOptionsButton)
        showRecents = QPushButton('Show recent searches...')
        showRecents.clicked.connect(self.recentSearches)
        ok = QPushButton('Search')
        ok.clicked.connect(self.accept)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.reject)
        buttonLayout.addWidget(showRecents)
        buttonLayout.addWidget(ok)
        buttonLayout.addWidget(cancel)
        layout.addLayout(buttonLayout)
        self.setLayout(layout)
        self.showMaximized()
コード例 #15
0
class PhraseDialog(QDialog):
    def __init__(self):
        super().__init__()

        self.descriptionLayouts = list()
        self.introduction = QLabel()
        self.introduction.setFont(QFont('Arial', 15))
        #the introduction label is used by subclasses to present different information to the user

        self.transcriptions = list()
        self.regularExpressions = None

        self.layout = QVBoxLayout()
        self.layout.addWidget(self.introduction)

        self.metaLayout = QVBoxLayout()
        self.layout.addLayout(self.metaLayout)

        sepFrame = QFrame()
        sepFrame.setFrameShape(QFrame.HLine)
        sepFrame.setLineWidth(2)
        self.layout.addWidget(sepFrame)

        self.buttonLayout = QVBoxLayout()
        self.topButtonLayout = QHBoxLayout()
        self.addDescription = QPushButton('')
        self.addDescription.clicked.connect(self.addFingerLayout)
        self.topButtonLayout.addWidget(self.addDescription)
        remove = QPushButton('Remove all selected phrases')
        self.topButtonLayout.addWidget(remove)
        remove.clicked.connect(self.removeFingerLayouts)
        self.buttonLayout.addLayout(self.topButtonLayout)

        bottomButtonLayout = QHBoxLayout()
        ok = QPushButton('OK')
        bottomButtonLayout.addWidget(ok)
        ok.clicked.connect(self.accept)
        cancel = QPushButton('Cancel')
        bottomButtonLayout.addWidget(cancel)
        cancel.clicked.connect(self.reject)
        self.buttonLayout.addLayout(bottomButtonLayout)

        self.layout.addLayout(self.buttonLayout)

        self.setLayout(self.layout)

    def clearLayout(self, layout):
        if layout is not None:
            while layout.count():
                item = layout.takeAt(0)
                widget = item.widget()
                if widget is not None:
                    widget.deleteLater()
                else:
                    self.clearLayout(item.layout())

    def removeFingerLayouts(self):
        for n in reversed(range(len(self.descriptionLayouts))):
            layout = self.metaLayout.itemAt(n)
            if layout.deleteMe.isChecked():
                layout = self.metaLayout.takeAt(n)
                self.descriptionLayouts.pop(n)
                while layout.count():
                    item = layout.takeAt(0)
                    widget = item.widget()
                    if widget is not None:
                        widget.deleteLater()

    def addFingerLayout(self, disable_quantifiers=False, allowAnyFinger=False):
        newLayout = FingerSearchLayout(allowAnyFinger)
        if disable_quantifiers:
            newLayout.quantifiers.removeItem(2)
            newLayout.quantifiers.removeItem(1)
            newLayout.configs.removeItem(2)
            newLayout.hands.removeItem(2)
        self.descriptionLayouts.append(newLayout)
        self.metaLayout.addLayout(newLayout)

    def addJointLayout(self):
        newLayout = JointSearchLayout()
        self.descriptionLayouts.append(newLayout)
        self.metaLayout.addLayout(newLayout)

    def findSlotNumbers(self, finger):
        if finger == 'thumb':
            slots = [4, 5]
        elif finger == 'index':
            slots = [17, 18, 19]
        elif finger == 'middle':
            slots = [22, 23, 24]
        elif finger == 'ring':
            slots = [27, 28, 29]
        elif finger == 'pinky':
            slots = [32, 33, 34]
        elif finger == 'any':
            slots = [4, 5, 17, 18, 19, 22, 23, 24, 32, 33, 34]
        return slots

    def findTranscriptionSymbol(self, description):
        description = description.lower()
        if description == 'unestimatable':
            symbol = '?'

        elif description == 'blank':
            symbol = ''

        elif 'extended' in description:
            if 'hyper' in description:
                symbol = 'H'
            elif 'fully' in description:
                symbol = 'E'
            elif 'somewhat' in description:
                symbol = 'e'
            else:
                symbol = 'HEe'

        elif 'flexed' in description:
            if 'fully' in description:
                symbol = 'F'
            elif 'somewhat' in description:
                symbol = 'f'
            else:
                symbol = 'Ff'

        elif 'intermediate' in description:
            if 'clearly' in description:
                symbol = 'i'
            else:
                symbol = 'efi'

        return symbol

    def generateTranscriptions(self):
        transcriptions = list()
        for regex in self.regularExpressions:
            t = list()
            for symbol in regex:
                if symbol == '.':
                    t.append('_')
                else:
                    t.append(symbol)
            transcriptions.append(t)
        self.transcriptions = transcriptions

    def generateGlobalOptions(self):
        self.forearm = False
        self.estimated = False
        self.uncertain = False
        self.incomplete = False
        self.reduplicated = False

    def generatePhrases(self):
        self.phrases = [
            layout.generatePhrase() for layout in self.descriptionLayouts
        ]

    def generateRegEx(self):
        mapping = {
            'config1hand1': (0, 'hand1Transcription'),
            'config1hand2': (0, 'hand2Transcription'),
            'config2hand1': (1, 'hand1Transcription'),
            'config2hand2': (1, 'hand2Transcription')
        }

        for layout in self.descriptionLayouts:
            transcriptions = {
                'config1hand1': [None for n in range(34)],
                'config1hand2': [None for n in range(34)],
                'config2hand1': [None for n in range(34)],
                'config2hand2': [None for n in range(34)]
            }

            finger = layout.fingers.currentText().lower()
            quantifier = layout.quantifiers.currentText().lower()
            config = layout.configs.currentText().lower().replace(' ', '')
            hand = layout.hands.currentText().lower().replace(' ', '')
            slots = self.findSlotNumbers(layout.fingers.currentText().lower())
            symbol = self.findTranscriptionSymbol(
                layout.flexions.currentText())

            configs = ['config1', 'config2'
                       ] if config == 'bothconfigs' else [config]
            hands = ['hand1', 'hand2'] if hand == 'bothhands' else [hand]

            if quantifier == 'all':
                pass  #symbol is normal
            elif quantifier == 'any':
                if finger == 'thumb':
                    symbol = '{}|.(?={})'.format(symbol, symbol)
                    slots = [slots[0], -1 * slots[1]]
                elif finger == 'any':
                    pass
                else:
                    symbol = '{}|.(?={})|.(?=.{})'.format(
                        symbol, symbol, symbol)
                    slots = [slots[0], -1 * slots[1], -1 * slots[2]]
                #this new "symbol" acts as a regex that looks ahead 2 or 3 slots, depending on the selected finger
                #we don't want to put this regex in each of those slots, but rather only in the first one
            elif quantifier == 'none':
                symbol = '[^{}]'.format(symbol)

            for c in configs:
                for h in hands:
                    for slot in slots:
                        if slot < 0:
                            transcriptions[c + h].pop(slot - 1 * -1)
                        else:
                            transcriptions[c + h][slot - 1] = symbol

            for key, value in transcriptions.items():
                regex = ['.' if v is None else v for v in value]
                transcriptions[key] = regex

            self.regularExpressions = [
                ''.join(transcriptions[key])
                for key in sorted(list(transcriptions.keys()))
            ]

    def accept(self):
        self.accepted = True
        super().accept()

    def reject(self):
        self.accepted = False
        super().reject()
コード例 #16
0
    def __init__(self, corpus):
        super().__init__()
        self.corpus = corpus
        self.results = list()

        self.setWindowTitle('Functional Load')
        layout = QVBoxLayout()

        #Set up top row of radio button options
        contrastBox = QGroupBox('Contrast')
        contrastLayout = QHBoxLayout()
        self.contrastGroup = QButtonGroup()
        flexionOption = QRadioButton('Degrees of flexion')
        flexionOption.click()
        ductionOption = QRadioButton('Degree of duction')
        oppositionOption = QRadioButton('Thumb opposition')
        contactOption = QRadioButton('Thumb/finger contact')
        customOption = QRadioButton('Custom options')
        self.contrastGroup.addButton(flexionOption, id=0)
        self.contrastGroup.addButton(ductionOption, id=1)
        self.contrastGroup.addButton(oppositionOption, id=2)
        self.contrastGroup.addButton(contactOption, id=3)
        self.contrastGroup.addButton(customOption, id=4)
        contrastLayout.addWidget(flexionOption)
        contrastLayout.addWidget(ductionOption)
        contrastLayout.addWidget(oppositionOption)
        contrastLayout.addWidget(contactOption)
        contrastLayout.addWidget(customOption)
        contrastBox.setLayout(contrastLayout)

        #set up stacked widgets
        self.middleWidget = QStackedWidget()

        #Collapse degress of flexion
        flexionWidget = QWidget()
        flexionLayout = QHBoxLayout()
        self.flexionFingerSelection = QComboBox()
        self.flexionFingerSelection.addItems(
            ['Thumb', 'Index', 'Middle', 'Pinky', 'Ring', 'All'])
        self.flexionJointSelection = QComboBox()
        self.flexionJointSelection.addItems(
            ['Proximal', 'Medial', 'Distal', 'All'])
        #note: Thumb+Proximal not possible, and there's an alert window that will pop up if this combination is chosen
        flexionLayout.addWidget(self.flexionFingerSelection)
        flexionLayout.addWidget(self.flexionJointSelection)
        flexionWidget.setLayout(flexionLayout)

        #Collapse degrees of duction
        ductionWidget = QWidget()
        ductionLayout = QHBoxLayout()
        self.ductionFingerSelection = QComboBox()
        self.ductionFingerSelection.addItems([
            'Thumb/Finger', 'Index/Middle', 'Middle/Ring', 'Ring/Pinky', 'All'
        ])
        ductionLayout.addWidget(self.ductionFingerSelection)
        ductionWidget.setLayout(ductionLayout)

        #Collapse thumb opposition
        oppositionWidget = QWidget()
        oppositionLayout = QHBoxLayout()
        oppositionWidget.setLayout(oppositionLayout)

        #Collapse thumb/finger contact
        contactWidget = QWidget()
        contactLayout = QHBoxLayout()
        contactWidget.setLayout(contactLayout)

        #Collapse custom slots
        customWidget = QWidget()
        customLayout = QHBoxLayout()
        customLayout.addWidget(QLabel('Merge this symbol: '))
        self.customSymbo1A = QComboBox()
        self.customSymbo1A.addItem('')
        self.customSymbo1A.addItems(STANDARD_SYMBOLS)
        self.customSymbo1A.setEditable(True)
        customLayout.addWidget(self.customSymbo1A)
        customLayout.addWidget(QLabel('with this symbol: '))
        self.customSymbolB = QComboBox()
        self.customSymbolB.addItem('')
        self.customSymbolB.addItems(STANDARD_SYMBOLS)
        self.customSymbolB.setEditable(True)
        customLayout.addWidget(self.customSymbolB)
        customLayout.addWidget(QLabel('in these slots: '))
        self.customSlots = QLineEdit()
        customLayout.addWidget(self.customSlots)
        customLayout.addWidget(
            QLabel(
                '(separate numbers with commas, leave blank to merge symbols everywhere)'
            ))
        customWidget.setLayout(customLayout)

        #Build up middle widget
        self.middleWidget.addWidget(flexionWidget)
        self.middleWidget.addWidget(ductionWidget)
        self.middleWidget.addWidget(oppositionWidget)
        self.middleWidget.addWidget(contactWidget)
        self.middleWidget.addWidget(customWidget)

        #Connect slots and signals
        flexionOption.clicked.connect(self.changeMiddleWidget)
        ductionOption.clicked.connect(self.changeMiddleWidget)
        oppositionOption.clicked.connect(self.changeMiddleWidget)
        contactOption.clicked.connect(self.changeMiddleWidget)
        customOption.clicked.connect(self.changeMiddleWidget)

        #Bottom buttons (OK/Cancel)
        buttonLayout = QHBoxLayout()
        ok = QPushButton('OK')
        ok.clicked.connect(self.accept)
        cancel = QPushButton('Cancel')
        cancel.clicked.connect(self.reject)
        buttonLayout.addWidget(ok)
        buttonLayout.addWidget(cancel)

        layout.addWidget(contrastBox)
        layout.addWidget(self.middleWidget)
        layout.addLayout(buttonLayout)

        self.setLayout(layout)
コード例 #17
0
    def __init__(self, constraints, configTabs):
        super().__init__()
        self.setWindowTitle('Transcription verification')
        layout = QVBoxLayout()
        if all([not value for value in constraints.values()]):
            layout.addWidget(QLabel('There were no problems detected with your transcription, '
                            'because no constraints have been selected. '
                          '\nTo set constraints, go to the Settings menu.'))
            buttonLayout = QHBoxLayout()
            ok = QPushButton('OK')
            ok.clicked.connect(self.accept)
            buttonLayout.addWidget(ok)
            layout.addLayout(buttonLayout)
            self.setLayout(layout)
            self.violations = {}
            return

        self.satisfied_message = 'This constraint is fully satisfied.\n("{}")'
        self.violations = {'config1hand1': {n:set() for n in range(35)}, 'config2hand1': {n:set() for n in range(35)},
                           'config1hand2': {n:set() for n in range(35)}, 'config2hand2': {n:set() for n in range(35)}}

        layout = QVBoxLayout()

        self.pageSelection = QComboBox()
        self.pageSelection.addItem('Transcription constraints')
        self.pageSelection.addItem('Simple constraints')
        self.pageSelection.addItem('Conditional constraints')
        layout.addWidget(self.pageSelection)

        self.pages = QStackedWidget()
        self.transcriptionsConstraintsTab = QTabWidget()
        self.transcriptionsConstraintsTab.currentChanged.connect(self.changedTab)
        self.pages.addWidget(self.transcriptionsConstraintsTab)
        self.simpleConstraintsTab = QTabWidget()
        self.simpleConstraintsTab.currentChanged.connect(self.changedTab)
        self.pages.addWidget(self.simpleConstraintsTab)
        self.conditionalConstraintsTab = QTabWidget()
        self.conditionalConstraintsTab.currentChanged.connect(self.changedTab)
        self.pages.addWidget(self.conditionalConstraintsTab)
        self.pageSelection.currentIndexChanged.connect(self.pages.setCurrentIndex)
        self.selected_page = 0
        self.selected_tab = 0
        self.page_maximum = self.pages.count()
        self.pages.currentChanged.connect(self.changedPage)

        #first, add all of the selected constraints to the stacked widgets
        # selected_constraints = list()
        # for c in MasterConstraintList:
        #     alert_text = list()
        #     constraint_text = list()
        #     if constraints[c[0]]:
        #         selected_constraints.append(c)
        #         tab = ConstraintTab()
        #         if c[1].constraint_type == 'transcription':
        #             self.transcriptionsConstraintsTab.addTab(tab, c[1].name)
        #         elif c[1].constraint_type == 'simple':
        #             self.simpleConstraintsTab.addTab(tab, c[1].name)
        #         elif c[1].constraint_type == 'conditional':
        #             self.conditionalConstraintsTab.addTab(tab, c[1].name)
        #             no_problems = True
        #then check to see if any constraints are actually violated
        #if they are, then add them to the self.violations set

        problems = dict()
        for constraint_name, constraint in MasterConstraintList:
            if not constraints[constraint_name]:
                continue
            if constraint in UnsupportedConstraints:
                problems[constraint_name] = [(('The constraint "{}" is not supported '
                                            'in the current version of SLPAnnotator'.format(constraint_name)), constraint)]
                continue
            for j in [1,2]:
                for k in [0,1]:
                    transcription = 'hand{}Transcription'.format(j)
                    transcription = getattr(configTabs.widget(k), transcription)
                    result = constraint.check(transcription.slots)
                    if result:
                        handconfig = 'config{}hand{}'.format(k+1, j)
                        for slot in result.split(', '):
                            self.violations[handconfig][int(slot)].add(constraint.name)
                    else:
                        result = 'This constraint is fully satisfied.'
                    text = 'Config {}, Hand {}: {}'.format(k+1, j, result)
                    info = (text, constraint)
                    try:
                        problems[constraint_name].append(info)
                    except (KeyError, AttributeError):
                        problems[constraint_name] = [info]

        for name,details in problems.items():
            tab = ConstraintTab()
            constraint_type = details[-1][-1].constraint_type
            labeltext = '\n'.join([d[0] for d in details])
            tab.layout.addWidget(QLabel(labeltext))
            if constraint_type == 'transcription':
                self.transcriptionsConstraintsTab.addTab(tab, name)
            elif constraint_type == 'simple':
                self.simpleConstraintsTab.addTab(tab, name)
            elif constraint_type == 'conditional':
                self.conditionalConstraintsTab.addTab(tab, name)

        if not problems:
            layout.addWidget(QLabel('All constraints are satisfied!'))
        else:
            layout.addWidget(self.pages)


        self.tab_maximum = {page_number:self.pages.widget(page_number).count()-1
                                     for page_number in range(self.page_maximum)}
        buttonLayout = QHBoxLayout()
        ok = QPushButton('OK')
        ok.clicked.connect(self.accept)
        buttonLayout.addWidget(ok)

        layout.addLayout(buttonLayout)

        self.setLayout(layout)