Skip to content

Commit

Permalink
Merge pull request #740 from lanzagar/corpview_search
Browse files Browse the repository at this point in the history
Corpus Viewer: Run search when finished typing the query (on enter).
  • Loading branch information
PrimozGodec authored Nov 14, 2021
2 parents b3511fa + 6348468 commit 0839602
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 2 deletions.
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

0 comments on commit 0839602

Please sign in to comment.