-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathDependencyFilterPanel.py
63 lines (52 loc) · 2.23 KB
/
DependencyFilterPanel.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/usr/bin/env python3
# -*- coding: utf-8, vim: expandtab:ts=4 -*-
from NLPCanvas import *
from EdgeLabelFilter import *
from EdgeTokenFilter import *
"""
* A DependencyFilterPanel controls a EdgeLabelFilter and a EdgeTokenFilter and updates an NLPCanvas after changes to
* the filters.
*
* @author Sebastian Riedel
"""
class DependencyFilterPanel:
"""
* Creates a new DependencyFilterPanel.
*
* @param nlpCanvas the NLPCanvas to update when the filters are changed through this panel.
* @param edgeLabelFilter The EdgeLabelFilter to control through this panel.
* @param edgeTokenFilter The EdgeTokenFilter to control through this panel.
"""
def __init__(self, gui, nlpCanvas=NLPCanvas, edgeLabelFilter=EdgeLabelFilter, edgeTokenFilter=EdgeTokenFilter):
labelField = gui.labelLineEdit
def labelFieldChanged(text):
edgeLabelFilter.clear()
split = text.split(",")
for label in split:
edgeLabelFilter.addAllowedLabel(label)
nlpCanvas.updateNLPGraphics()
labelField.textEdited.connect(labelFieldChanged)
tokenTextField = gui.edgeFilterTokenLineEdit
def tokenTextFieldChanged(text):
print("tokenTextFieldChanged")
edgeTokenFilter.clear()
split = text.split(",")
for property in split:
edgeTokenFilter.addAllowedProperty(property)
nlpCanvas.updateNLPGraphics()
tokenTextField.textEdited.connect(tokenTextFieldChanged)
usePath = gui.onlyPathCheckBox
def usePathAction(value):
edgeTokenFilter.usePath = value == 2 #checked
nlpCanvas.updateNLPGraphics()
usePath.stateChanged.connect(usePathAction)
collapse= gui.collapsCheckBox
def collapseAction(value):
edgeTokenFilter.collaps = value == 2 # checked
nlpCanvas.updateNLPGraphics()
collapse.stateChanged.connect(collapseAction)
wholeWords = gui.edgeFilterWholeWordsCheckBox
def wholeWordsAction(value):
edgeTokenFilter.wholeWords = value == 2 # checked
nlpCanvas.updateNLPGraphics()
wholeWords.stateChanged.connect(wholeWordsAction)