Skip to content

Commit

Permalink
Reorder notebooks in docs
Browse files Browse the repository at this point in the history
  • Loading branch information
maks-operlejn-ds committed Oct 11, 2023
1 parent be48f56 commit afbf24b
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 9 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"cells": [
{
"cell_type": "raw",
"metadata": {},
"source": [
"---\n",
"sidebar_position: 2\n",
"title: Multi-language anonymization\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -248,15 +258,15 @@
"import langdetect\n",
"from langchain.schema import runnable\n",
"\n",
"\n",
"def detect_language(text: str) -> dict:\n",
" language = langdetect.detect(text)\n",
" print(language)\n",
" return {\"text\": text, \"language\": language}\n",
"\n",
"\n",
"chain = (\n",
" runnable.RunnableLambda(detect_language)\n",
" | (lambda x: anonymizer.anonymize(x[\"text\"], language=x[\"language\"]))\n",
"chain = runnable.RunnableLambda(detect_language) | (\n",
" lambda x: anonymizer.anonymize(x[\"text\"], language=x[\"language\"])\n",
")"
]
},
Expand Down Expand Up @@ -345,15 +355,17 @@
"import fasttext\n",
"\n",
"model = fasttext.load_model(\"lid.176.ftz\")\n",
"\n",
"\n",
"def detect_language(text: str) -> dict:\n",
" language = model.predict(text)[0][0].replace('__label__', '')\n",
" language = model.predict(text)[0][0].replace(\"__label__\", \"\")\n",
" print(language)\n",
" return {\"text\": text, \"language\": language}\n",
"\n",
"chain = (\n",
" runnable.RunnableLambda(detect_language)\n",
" | (lambda x: anonymizer.anonymize(x[\"text\"], language=x[\"language\"]))\n",
")\n"
"\n",
"chain = runnable.RunnableLambda(detect_language) | (\n",
" lambda x: anonymizer.anonymize(x[\"text\"], language=x[\"language\"])\n",
")"
]
},
{
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,14 @@
{
"cells": [
{
"cell_type": "raw",
"metadata": {},
"source": [
"---\n",
"sidebar_position: 3\n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,15 @@
{
"cells": [
{
"cell_type": "raw",
"metadata": {},
"source": [
"---\n",
"sidebar_position: 1\n",
"title: Reversible anonymization \n",
"---"
]
},
{
"cell_type": "markdown",
"metadata": {},
Expand Down Expand Up @@ -623,4 +633,4 @@
},
"nbformat": 4,
"nbformat_minor": 4
}
}

0 comments on commit afbf24b

Please sign in to comment.