Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Corpus Viewer: Run search when finished typing the query (on enter). #740

Merged
merged 2 commits into from
Nov 14, 2021
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions orangecontrib/text/widgets/owcorpusviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -92,8 +92,8 @@ def __init__(self):
orientation=Qt.Horizontal,
sizePolicy=QSizePolicy(QSizePolicy.MinimumExpanding,
QSizePolicy.Fixed),
label='RegExp Filter:')
self.filter_input.textChanged.connect(self.refresh_search)
label='RegExp Filter:',
callback=self.refresh_search)

# Main area
self.splitter = QSplitter(
Expand Down
6 changes: 6 additions & 0 deletions orangecontrib/text/widgets/tests/test_owcorpusviewer.py
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ def test_data(self):
def test_search(self):
self.send_signal(self.widget.Inputs.corpus, self.corpus)
self.widget.regexp_filter = "Human"
self.widget.refresh_search()
self.process_events()
out_corpus = self.get_output(self.widget.Outputs.matching_docs)
self.assertEqual(len(out_corpus), 1)
Expand All @@ -30,6 +31,7 @@ def test_search(self):
# first document is selected, when filter with word that is not in
# selected document out_corpus is None
self.widget.regexp_filter = "graph"
self.widget.refresh_search()
self.process_events()
out_corpus = self.get_output(self.widget.Outputs.matching_docs)
self.assertIsNone(out_corpus)
Expand All @@ -38,6 +40,7 @@ def test_search(self):

# when filter is removed, matched words is 0
self.widget.regexp_filter = ""
self.widget.refresh_search()
self.process_events()
self.assertEqual(self.widget.matches, 0)

Expand Down Expand Up @@ -73,6 +76,7 @@ def test_highlighting_non_latin(self):

self.send_signal(self.widget.Inputs.corpus, corpus)
self.widget.regexp_filter = "\\bсад\\b"
self.widget.refresh_search()
self.process_events()
self.widget.doc_webview.html()
spy = QSignalSpy(self.widget.doc_webview.loadFinished)
Expand All @@ -84,6 +88,7 @@ def test_output(self):
""" Output is intersection between selection and filter """
self.send_signal(self.widget.Inputs.corpus, self.corpus)
self.widget.regexp_filter = "graph"
self.widget.refresh_search()
self.process_events()
self.assertIsNone(self.get_output(self.widget.Outputs.matching_docs))
self.assertEqual(
Expand All @@ -108,6 +113,7 @@ def test_output(self):
)

self.widget.regexp_filter = "human"
self.widget.refresh_search()
self.process_events()
# empty because none of matching documents is selected
self.assertIsNone(self.get_output(self.widget.Outputs.matching_docs))
Expand Down