Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added search of multiple strings. updated dependencies. fixed linting…
… errors
- Loading branch information
Gal Ben David
committed
Apr 20, 2022
1 parent
9546c6c
commit 28049a6
Showing
14 changed files
with
347 additions
and
190 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,73 @@ | ||
import typing | ||
|
||
from . import pysubstringsearch | ||
|
||
|
||
Writer = pysubstringsearch.Writer | ||
Reader = pysubstringsearch.Reader | ||
class Writer: | ||
def __init__( | ||
self, | ||
index_file_path: str, | ||
max_chunk_len: typing.Optional[int] = None, | ||
) -> None: | ||
self.writer = pysubstringsearch.Writer( | ||
index_file_path=index_file_path, | ||
max_chunk_len=max_chunk_len, | ||
) | ||
|
||
def add_entries_from_file_lines( | ||
self, | ||
input_file_path: str, | ||
) -> None: | ||
self.writer.add_entries_from_file_lines( | ||
input_file_path=input_file_path, | ||
) | ||
|
||
def add_entry( | ||
self, | ||
text: str, | ||
) -> None: | ||
self.writer.add_entry( | ||
text=text, | ||
) | ||
|
||
def dump_data( | ||
self, | ||
) -> None: | ||
self.writer.dump_data() | ||
|
||
def finalize( | ||
self, | ||
) -> None: | ||
self.writer.finalize() | ||
|
||
|
||
class Reader: | ||
def __init__( | ||
self, | ||
index_file_path: str, | ||
) -> None: | ||
self.reader = pysubstringsearch.Reader( | ||
index_file_path=index_file_path, | ||
) | ||
|
||
def search( | ||
self, | ||
substring: str, | ||
) -> typing.List[str]: | ||
return self.reader.search( | ||
substring=substring, | ||
) | ||
|
||
def search_multiple( | ||
self, | ||
substrings: typing.List[str], | ||
) -> typing.List[str]: | ||
results = [] | ||
for substring in substrings: | ||
results.extend( | ||
self.search( | ||
substring=substring, | ||
), | ||
) | ||
|
||
return results |
Empty file.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.