-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
57b5839
commit b217de0
Showing
3 changed files
with
49 additions
and
5 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
""" | ||
This file contains code samples for analyzers. | ||
Run the following to check the available methods: | ||
.. code-block:: shell | ||
python analyzers.py --help | ||
""" | ||
import typer | ||
from rich.console import Console | ||
|
||
from config import INDEX_NAME, client | ||
from helpers import log_titles | ||
from typing import List | ||
|
||
app = typer.Typer(rich_markup_mode="rich") | ||
console = Console() | ||
resp = client.search(index=INDEX_NAME, body=query_body) | ||
|
||
|
||
analyzers = [ | ||
"standard", | ||
"simple", | ||
"whitespace", | ||
"stop", | ||
"keyword", | ||
"pattern", | ||
"fingerprint", | ||
] | ||
|
||
|
||
def generate_tokens(analyzer, text): | ||
res = os.indices.analyze(body={"analyzer": analyzer, "text": [text]}) | ||
tokens = [sample["token"] for c, sample in enumerate(res["tokens"])] | ||
print(f"{analyzer} \n") | ||
print(f"Tokens: {tokens} \n") | ||
|
||
|
||
if __name__ == "__main__": | ||
text = "Hello my Name is Laysa.12345" | ||
for analyzer in analyzers: | ||
generate_tokens(analyzer, text) |
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