Commit 83d8592f authored by Bernhard Liebl's avatar Bernhard Liebl
Browse files

mathjax fixes

parent 5c08cdbc
...@@ -153,7 +153,7 @@ ...@@ -153,7 +153,7 @@
}, },
{ {
"cell_type": "code", "cell_type": "code",
"execution_count": 2, "execution_count": 1,
"id": "6bb0f486", "id": "6bb0f486",
"metadata": {}, "metadata": {},
"outputs": [ "outputs": [
...@@ -176,7 +176,7 @@ ...@@ -176,7 +176,7 @@
"\n", "\n",
" <div class=\"bk-root\">\n", " <div class=\"bk-root\">\n",
" <a href=\"https://bokeh.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n", " <a href=\"https://bokeh.org\" target=\"_blank\" class=\"bk-logo bk-logo-small bk-logo-notebook\"></a>\n",
" <span id=\"1003\">Loading BokehJS ...</span>\n", " <span id=\"1002\">Loading BokehJS ...</span>\n",
" </div>" " </div>"
] ]
}, },
...@@ -346,7 +346,7 @@ ...@@ -346,7 +346,7 @@
" \"</div>\"}};\n", " \"</div>\"}};\n",
"\n", "\n",
" function display_loaded() {\n", " function display_loaded() {\n",
" var el = document.getElementById(\"1003\");\n", " var el = document.getElementById(\"1002\");\n",
" if (el != null) {\n", " if (el != null) {\n",
" el.textContent = \"BokehJS is loading...\";\n", " el.textContent = \"BokehJS is loading...\";\n",
" }\n", " }\n",
...@@ -412,7 +412,7 @@ ...@@ -412,7 +412,7 @@
" document.body.appendChild(element);\n", " document.body.appendChild(element);\n",
" }\n", " }\n",
"\n", "\n",
" const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.0.min.js\": \"HjagQp6T0/7bxYTAXbLotF1MLAGWmhkY5siA1Gc/pcEgvgRPtMsRn0gQtMwGKiw1\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.0.min.js\": \"ZEPPTjL+mdyqgIq+/pl9KTwzji8Kow2NnI3zWY8+sFinWP/SYJ80BnfeJsa45iYj\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.0.min.js\": \"exLqv2ACDRIaV7ZK1iL8aGzGYQvKVuT3U2CT7FsQREBxRah6JrkVCoFy0koY1YqV\"};\n", " const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.2.min.js\": \"XypntL49z55iwGVUW4qsEu83zKL3XEcz0MjuGOQ9SlaaQ68X/g+k1FcioZi7oQAc\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.2.min.js\": \"bEsM86IHGDTLCS0Zod8a8WM6Y4+lafAL/eSiyQcuPzinmWNgNO2/olUF0Z2Dkn5i\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.2.min.js\": \"TX0gSQTdXTTeScqxj6PVQxTiRW8DOoGVwinyi1D3kxv7wuxQ02XkOxv0xwiypcAH\"};\n",
"\n", "\n",
" for (let i = 0; i < js_urls.length; i++) {\n", " for (let i = 0; i < js_urls.length; i++) {\n",
" const url = js_urls[i];\n", " const url = js_urls[i];\n",
...@@ -437,7 +437,7 @@ ...@@ -437,7 +437,7 @@
" }\n", " }\n",
"\n", "\n",
" \n", " \n",
" var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.0.min.js\"];\n", " var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.2.min.js\"];\n",
" var css_urls = [];\n", " var css_urls = [];\n",
" \n", " \n",
"\n", "\n",
...@@ -466,7 +466,7 @@ ...@@ -466,7 +466,7 @@
" console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n", " console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n",
" root._bokeh_failed_load = true;\n", " root._bokeh_failed_load = true;\n",
" } else if (force !== true) {\n", " } else if (force !== true) {\n",
" var cell = $(document.getElementById(\"1003\")).parents('.cell').data().cell;\n", " var cell = $(document.getElementById(\"1002\")).parents('.cell').data().cell;\n",
" cell.output_area.append_execute_result(NB_LOAD_WARNING)\n", " cell.output_area.append_execute_result(NB_LOAD_WARNING)\n",
" }\n", " }\n",
"\n", "\n",
...@@ -483,7 +483,7 @@ ...@@ -483,7 +483,7 @@
" }\n", " }\n",
"}(window));" "}(window));"
], ],
"application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"1003\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.0.min.js\": \"HjagQp6T0/7bxYTAXbLotF1MLAGWmhkY5siA1Gc/pcEgvgRPtMsRn0gQtMwGKiw1\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.0.min.js\": \"ZEPPTjL+mdyqgIq+/pl9KTwzji8Kow2NnI3zWY8+sFinWP/SYJ80BnfeJsa45iYj\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.0.min.js\": \"exLqv2ACDRIaV7ZK1iL8aGzGYQvKVuT3U2CT7FsQREBxRah6JrkVCoFy0koY1YqV\"};\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n if (url in hashes) {\n element.crossOrigin = \"anonymous\";\n element.integrity = \"sha384-\" + hashes[url];\n }\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n \n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.0.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.0.min.js\"];\n var css_urls = [];\n \n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {\n \n \n }\n ];\n\n function run_inline_js() {\n \n if (root.Bokeh !== undefined || force === true) {\n \n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"1003\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));" "application/vnd.bokehjs_load.v0+json": "\n(function(root) {\n function now() {\n return new Date();\n }\n\n var force = true;\n\n if (typeof root._bokeh_onload_callbacks === \"undefined\" || force === true) {\n root._bokeh_onload_callbacks = [];\n root._bokeh_is_loading = undefined;\n }\n\n \n\n \n if (typeof (root._bokeh_timeout) === \"undefined\" || force === true) {\n root._bokeh_timeout = Date.now() + 5000;\n root._bokeh_failed_load = false;\n }\n\n var NB_LOAD_WARNING = {'data': {'text/html':\n \"<div style='background-color: #fdd'>\\n\"+\n \"<p>\\n\"+\n \"BokehJS does not appear to have successfully loaded. If loading BokehJS from CDN, this \\n\"+\n \"may be due to a slow or bad network connection. Possible fixes:\\n\"+\n \"</p>\\n\"+\n \"<ul>\\n\"+\n \"<li>re-rerun `output_notebook()` to attempt to load from CDN again, or</li>\\n\"+\n \"<li>use INLINE resources instead, as so:</li>\\n\"+\n \"</ul>\\n\"+\n \"<code>\\n\"+\n \"from bokeh.resources import INLINE\\n\"+\n \"output_notebook(resources=INLINE)\\n\"+\n \"</code>\\n\"+\n \"</div>\"}};\n\n function display_loaded() {\n var el = document.getElementById(\"1002\");\n if (el != null) {\n el.textContent = \"BokehJS is loading...\";\n }\n if (root.Bokeh !== undefined) {\n if (el != null) {\n el.textContent = \"BokehJS \" + root.Bokeh.version + \" successfully loaded.\";\n }\n } else if (Date.now() < root._bokeh_timeout) {\n setTimeout(display_loaded, 100)\n }\n }\n\n\n function run_callbacks() {\n try {\n root._bokeh_onload_callbacks.forEach(function(callback) {\n if (callback != null)\n callback();\n });\n } finally {\n delete root._bokeh_onload_callbacks\n }\n console.debug(\"Bokeh: all callbacks have finished\");\n }\n\n function load_libs(css_urls, js_urls, callback) {\n if (css_urls == null) css_urls = [];\n if (js_urls == null) js_urls = [];\n\n root._bokeh_onload_callbacks.push(callback);\n if (root._bokeh_is_loading > 0) {\n console.debug(\"Bokeh: BokehJS is being loaded, scheduling callback at\", now());\n return null;\n }\n if (js_urls == null || js_urls.length === 0) {\n run_callbacks();\n return null;\n }\n console.debug(\"Bokeh: BokehJS not loaded, scheduling load and callback at\", now());\n root._bokeh_is_loading = css_urls.length + js_urls.length;\n\n function on_load() {\n root._bokeh_is_loading--;\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: all BokehJS libraries/stylesheets loaded\");\n run_callbacks()\n }\n }\n\n function on_error(url) {\n console.error(\"failed to load \" + url);\n }\n\n for (let i = 0; i < css_urls.length; i++) {\n const url = css_urls[i];\n const element = document.createElement(\"link\");\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.rel = \"stylesheet\";\n element.type = \"text/css\";\n element.href = url;\n console.debug(\"Bokeh: injecting link tag for BokehJS stylesheet: \", url);\n document.body.appendChild(element);\n }\n\n const hashes = {\"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.2.min.js\": \"XypntL49z55iwGVUW4qsEu83zKL3XEcz0MjuGOQ9SlaaQ68X/g+k1FcioZi7oQAc\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.2.min.js\": \"bEsM86IHGDTLCS0Zod8a8WM6Y4+lafAL/eSiyQcuPzinmWNgNO2/olUF0Z2Dkn5i\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.2.min.js\": \"TX0gSQTdXTTeScqxj6PVQxTiRW8DOoGVwinyi1D3kxv7wuxQ02XkOxv0xwiypcAH\"};\n\n for (let i = 0; i < js_urls.length; i++) {\n const url = js_urls[i];\n const element = document.createElement('script');\n element.onload = on_load;\n element.onerror = on_error.bind(null, url);\n element.async = false;\n element.src = url;\n if (url in hashes) {\n element.crossOrigin = \"anonymous\";\n element.integrity = \"sha384-\" + hashes[url];\n }\n console.debug(\"Bokeh: injecting script tag for BokehJS library: \", url);\n document.head.appendChild(element);\n }\n };\n\n function inject_raw_css(css) {\n const element = document.createElement(\"style\");\n element.appendChild(document.createTextNode(css));\n document.body.appendChild(element);\n }\n\n \n var js_urls = [\"https://cdn.bokeh.org/bokeh/release/bokeh-2.3.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-widgets-2.3.2.min.js\", \"https://cdn.bokeh.org/bokeh/release/bokeh-tables-2.3.2.min.js\"];\n var css_urls = [];\n \n\n var inline_js = [\n function(Bokeh) {\n Bokeh.set_log_level(\"info\");\n },\n function(Bokeh) {\n \n \n }\n ];\n\n function run_inline_js() {\n \n if (root.Bokeh !== undefined || force === true) {\n \n for (var i = 0; i < inline_js.length; i++) {\n inline_js[i].call(root, root.Bokeh);\n }\n if (force === true) {\n display_loaded();\n }} else if (Date.now() < root._bokeh_timeout) {\n setTimeout(run_inline_js, 100);\n } else if (!root._bokeh_failed_load) {\n console.log(\"Bokeh: BokehJS failed to load within specified timeout.\");\n root._bokeh_failed_load = true;\n } else if (force !== true) {\n var cell = $(document.getElementById(\"1002\")).parents('.cell').data().cell;\n cell.output_area.append_execute_result(NB_LOAD_WARNING)\n }\n\n }\n\n if (root._bokeh_is_loading === 0) {\n console.debug(\"Bokeh: BokehJS loaded, going straight to plotting\");\n run_inline_js();\n } else {\n load_libs(css_urls, js_urls, function() {\n console.debug(\"Bokeh: BokehJS plotting callback run at\", now());\n run_inline_js();\n });\n }\n}(window));"
}, },
"metadata": {}, "metadata": {},
"output_type": "display_data" "output_type": "display_data"
...@@ -934,13 +934,11 @@ ...@@ -934,13 +934,11 @@
"id": "936bfeb6", "id": "936bfeb6",
"metadata": {}, "metadata": {},
"source": [ "source": [
"Before we dive into the acutal intertextuality analyses, we first take a brief look at the inner workings of embeddings. Mathematically speaking, a word embedding is a vector **x** of dimension $n$, i.e. a vector consisting of $n$ scalars.\n", "Before we dive into the acutal intertextuality analyses, we first take a brief look at the inner workings of embeddings. Mathematically speaking, a word embedding is a vector **x** of dimension *n*, i.e. a vector consisting of *n* scalars.\n",
"\n", "\n",
"\\begin{equation*}\n", "$$\\mathbf{x}=(x_1, x_2, ..., x_{n-1}, x_n)$$\n",
"\\mathbf{x}=(x_1, x_2, ..., x_{n-1}, x_n)\n",
"\\end{equation*}\n",
"\n", "\n",
"For example, the compressed numberbatch embedding we use has $n=50$ and thus represents the word \"coffee\" with the following 50 scalar values:" "For example, the compressed numberbatch embedding we use has *n*=50 and thus represents the word \"coffee\" with the following 50 scalar values:"
] ]
}, },
{ {
...@@ -981,7 +979,7 @@ ...@@ -981,7 +979,7 @@
"source": [ "source": [
"Since the above representation is difficult to understand, we visualize the values of\n", "Since the above representation is difficult to understand, we visualize the values of\n",
"\n", "\n",
"\\begin{equation*}x_1, x_2, ..., x_{n-1}, x_n\\end{equation*}\n", "$$x_1, x_2, ..., x_{n-1}, x_n$$\n",
"\n", "\n",
"through different colors. By default, all values are normalized by ||**x**||&#x2082;, i.e. the dot product of these values gives the cosine similarity." "through different colors. By default, all values are normalized by ||**x**||&#x2082;, i.e. the dot product of these values gives the cosine similarity."
] ]
...@@ -1036,11 +1034,9 @@ ...@@ -1036,11 +1034,9 @@
"id": "90ef6760", "id": "90ef6760",
"metadata": {}, "metadata": {},
"source": [ "source": [
"A common approach to compute the similarity between two word vectors **u** and **v** in this kind of high-dimensional vector spaces is to compute the cosine of the angle $\\theta$ between the vectors, which is called **cosine similarity**:\n", "A common approach to compute the similarity between two word vectors **u** and **v** in this kind of high-dimensional vector spaces is to compute the cosine of the angle &theta; between the vectors, which is called **cosine similarity**:\n",
"\n", "\n",
"\\begin{equation*}\n", "$$cos \\theta = \\frac{\\mathbf{u} \\cdot \\mathbf{v}}{||\\mathbf{u}||_2 ||\\mathbf{v}||_2} = \\frac{\\sum_1^n \\mathbf{u}_i \\mathbf{v}_i}{\\sqrt{\\sum_1^n \\mathbf{u}_i^2} \\sqrt{\\sum_1^n \\mathbf{v}_i^2}} = \\sum_1^n \\left( \\frac{\\mathbf{u}}{||\\mathbf{u}||_2} \\right)_i \\left( \\frac{\\mathbf{v}}{||\\mathbf{v}||_2} \\right)_i$$"
"cos \\theta = \\frac{\\mathbf{u} \\cdot \\mathbf{v}}{||\\mathbf{u}||_2 ||\\mathbf{v}||_2} = \\frac{\\sum_1^n \\mathbf{u}_i \\mathbf{v}_i}{\\sqrt{\\sum_1^n \\mathbf{u}_i^2} \\sqrt{\\sum_1^n \\mathbf{v}_i^2}} = \\sum_1^n \\left( \\frac{\\mathbf{u}}{||\\mathbf{u}||_2} \\right)_i \\left( \\frac{\\mathbf{v}}{||\\mathbf{v}||_2} \\right)_i \n",
"\\end{equation*}"
] ]
}, },
{ {
...@@ -1048,15 +1044,13 @@ ...@@ -1048,15 +1044,13 @@
"id": "3d8876b1", "id": "3d8876b1",
"metadata": {}, "metadata": {},
"source": [ "source": [
"A large positive value (i.e. a small $\\theta$ between **u** and **v**) indicates higher similarity, whereas a small or even negative value (i.e. a large $\\theta$) indicates lower similarity. For a discussion of issues with this notion of similarity, see Faruqui et al. (2016).\n", "A large positive value (i.e. a small &theta; between **u** and **v**) indicates higher similarity, whereas a small or even negative value (i.e. a large &theta;) indicates lower similarity. For a discussion of issues with this notion of similarity, see Faruqui et al. (2016).\n",
"\n", "\n",
"The visualization below encodes\n", "The visualization below encodes\n",
"\n", "\n",
"\\begin{equation*}\n", "$$\\left( \\frac{\\mathbf{u}}{||\\mathbf{u}||_2} \\right)_i \\left( \\frac{\\mathbf{v}}{||\\mathbf{v}||_2} \\right)_i$$\n",
"\\left( \\frac{\\mathbf{u}}{||\\mathbf{u}||_2} \\right)_i \\left( \\frac{\\mathbf{v}}{||\\mathbf{v}||_2} \\right)_i \n",
"\\end{equation*}\n",
"\n", "\n",
"for different $i, 1 \\le i \\le n$ through colors to illustrate how different components contribute to the cosine similarity for two words. Brighter colors (orange/yellow) indicate dimensions with higher values." "for different i, 1 &le; i &le; n, through colors to illustrate how different components contribute to the cosine similarity for two words. Brighter colors (orange/yellow) indicate dimensions with higher values."
] ]
}, },
{ {
...@@ -2943,7 +2937,7 @@ ...@@ -2943,7 +2937,7 @@
"name": "python", "name": "python",
"nbconvert_exporter": "python", "nbconvert_exporter": "python",
"pygments_lexer": "ipython3", "pygments_lexer": "ipython3",
"version": "3.8.8" "version": "3.7.10"
} }
}, },
"nbformat": 4, "nbformat": 4,
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment