Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
fix prefix tree unit
  • Loading branch information
thomas--graf committed Oct 24, 2018
1 parent 720c203 commit 8280845
Show file tree
Hide file tree
Showing 15 changed files with 64 additions and 674 deletions.
2 changes: 1 addition & 1 deletion notebooks/02_n-grams/03_positive_grammars.ipynb
Expand Up @@ -303,7 +303,7 @@
"The original grammar is:\n",
"{'aa', 'ba'}\n",
"The opposite polarity version is:\n",
"{'b$', 'a$', '$a', 'bb', '$b', 'ab', '$$'}\n"
"{'$b', 'bb', 'ab', 'b$', 'a$', '$a', '$$'}\n"
]
}
],
Expand Down
4 changes: 2 additions & 2 deletions notebooks/02_n-grams/06_text_as_ngrams.ipynb
Expand Up @@ -76,11 +76,11 @@
"output_type": "stream",
"text": [
"Input: John is John, that much is obvious!\n",
"{'obvious', 'that', 'is', 'much', 'john'}\n",
"{'john', 'obvious', 'much', 'is', 'that'}\n",
"\n",
"\n",
"Input: The man and the woman are husband and wife.\n",
"{'are', 'and', 'husband', 'wife', 'the', 'man', 'woman'}\n",
"{'are', 'wife', 'man', 'the', 'and', 'husband', 'woman'}\n",
"\n",
"\n",
"Input: Police police police police police.\n",
Expand Down
18 changes: 9 additions & 9 deletions notebooks/02_n-grams/07_bagofwords.ipynb

Large diffs are not rendered by default.

14 changes: 7 additions & 7 deletions notebooks/04_representations/06_prefixtrees.ipynb
Expand Up @@ -104,8 +104,8 @@
"output_type": "stream",
"text": [
"3\n",
"CPU times: user 1.35 ms, sys: 127 µs, total: 1.48 ms\n",
"Wall time: 4.62 ms\n"
"CPU times: user 1.11 ms, sys: 100 µs, total: 1.21 ms\n",
"Wall time: 4.08 ms\n"
]
}
],
Expand All @@ -126,8 +126,8 @@
"output_type": "stream",
"text": [
"461853\n",
"CPU times: user 13.7 ms, sys: 0 ns, total: 13.7 ms\n",
"Wall time: 26.2 ms\n"
"CPU times: user 13.6 ms, sys: 159 µs, total: 13.8 ms\n",
"Wall time: 27.3 ms\n"
]
}
],
Expand Down Expand Up @@ -233,7 +233,7 @@
"Just like we added $\\emptystring$ earlier on even though it isn't part of the list, we will now require the tree to contain every proper prefix of a word, even if it is not part of the word list that the tree encodes.\n",
"So the tree above expands into the more verbose one below.\n",
"\n",
"\\input{./pseudoprefixtree_verbose.forest}\n",
"![med](./pseudoprefixtree_verbose.svg)\n",
"\n",
"Now adding a new word is guaranteed to never involve any node splitting.\n",
"However, the addition of the word itself may require multiple nodes to be added.\n",
Expand All @@ -243,12 +243,12 @@
"For example, *bat* has the prefixes *ba* and *b*, which are not words of English.\n",
"To remedy this, we assume that nodes come in two colors: blue nodes are parts of the lexicon, red nodes are not.\n",
"\n",
"\\input{./prefixtree_nodelabels.forest}\n",
"![med](./prefixtree_nodelabels.svg)\n",
"\n",
"This kind of structure is called a *prefix tree*.\n",
"Sometimes, prefix trees are drawn with labeled branches instead of labeled nodes.\n",
"\n",
"\\input{./prefixtree_branchlabels.forest}\n",
"![med](./prefixtree_branchlabels.svg)\n",
"\n",
"Going back to our initial comparison, we can now say that prefix trees beat lists on two counts:\n",
"\n",
Expand Down
358 changes: 0 additions & 358 deletions notebooks/04_representations/08_automata.ipynb

This file was deleted.

60 changes: 0 additions & 60 deletions notebooks/04_representations/09_transducers.ipynb

This file was deleted.

48 changes: 0 additions & 48 deletions notebooks/background/algebra/00_algebra.ipynb

This file was deleted.

48 changes: 0 additions & 48 deletions notebooks/background/algebra/01_monoid.ipynb

This file was deleted.

48 changes: 0 additions & 48 deletions notebooks/background/algebra/02_two_operations.ipynb

This file was deleted.

48 changes: 0 additions & 48 deletions notebooks/background/algebra/03_semiring.ipynb

This file was deleted.

4 changes: 2 additions & 2 deletions notebooks/background/functions/00_basic_notation.ipynb
Expand Up @@ -87,11 +87,11 @@
"text": [
"The output of random_output(5) is 10\n",
"The output of random_output(5) is 10\n",
"The output of random_output(5) is 15\n",
"The output of random_output(5) is 10\n",
"The output of random_output(5) is 15\n",
"The output of random_output(5) is 10\n",
"The output of random_output(5) is 10\n",
"The output of random_output(5) is 15\n",
"The output of random_output(5) is 10\n",
"The output of random_output(5) is 10\n",
"The output of random_output(5) is 15\n",
"The output of random_output(5) is 10\n"
Expand Down

0 comments on commit 8280845

Please sign in to comment.