From 098666fc68075705f7c27af535e8bbbe452f6725 Mon Sep 17 00:00:00 2001 From: Ian Culp <57159226+icculp@users.noreply.github.com> Date: Fri, 11 Jun 2021 21:25:11 -0500 Subject: [PATCH 01/12] Counts the words in each chapter, ignoring code blocks and digits --- word_count.ipynb | 266 +++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 266 insertions(+) create mode 100644 word_count.ipynb diff --git a/word_count.ipynb b/word_count.ipynb new file mode 100644 index 0000000..7a19a21 --- /dev/null +++ b/word_count.ipynb @@ -0,0 +1,266 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Untitled25.ipynb", + "provenance": [], + "authorship_tag": "ABX9TyOJqhnf6/YgfQMx6pfh6Fth", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "kT4wyWuy2szs" + }, + "source": [ + "import numpy as np\n", + "import os\n", + "import pandas as pd" + ], + "execution_count": 7, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "9J62Uh4H2Y9g", + "outputId": "f4147b98-f72a-4ad2-8b5b-c3bb9f0c86db" + }, + "source": [ + "!git clone https://github.com/icculp/Learning-Bitcoin-from-the-Command-Line.git" + ], + "execution_count": 2, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Cloning into 'Learning-Bitcoin-from-the-Command-Line'...\n", + "remote: Enumerating objects: 6634, done.\u001b[K\n", + "remote: Counting objects: 100% (238/238), done.\u001b[K\n", + "remote: Compressing objects: 100% (196/196), done.\u001b[K\n", + "remote: Total 6634 (delta 109), reused 82 (delta 42), pack-reused 6396\u001b[K\n", + "Receiving objects: 100% (6634/6634), 7.53 MiB | 13.87 MiB/s, done.\n", + "Resolving deltas: 100% (4068/4068), done.\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "k_g4-Fvn2yPy" + }, + "source": [ + "def count_words():\n", + " \"\"\" Counts words ignoring code blocks and digits \"\"\"\n", + " columns=['Chapter', 'Word Count']\n", + " counts = []\n", + " repo_path = '/content/Learning-Bitcoin-from-the-Command-Line/'\n", + " for chapter in os.listdir(repo_path):\n", + " if not chapter.endswith('.md'):\n", + " continue\n", + " count = 0\n", + " flag = 0 # ignores words between ``` code markdown\n", + " with open(repo_path + chapter) as ch:\n", + " for line in ch.readlines():\n", + " if flag:\n", + " if '```' in line:\n", + " flag = 0\n", + " continue\n", + " continue\n", + " if '```' in line:\n", + " flag = 1\n", + " continue\n", + " for word in line.split():\n", + " if any(ch.isdigit() for ch in word):\n", + " continue\n", + " count += 1\n", + " counts.append((chapter, count))\n", + " # print(chapter, count)\n", + " return pd.DataFrame(counts, columns=columns)" + ], + "execution_count": 35, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "2-pkEaYF3Uxm" + }, + "source": [ + "chapter_word_counts = count_words()\n", + "chapter_word_counts.sort_values(by=['Chapter'], inplace=True)" + ], + "execution_count": 38, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 631 + }, + "id": "IPkG4oQJ6f1e", + "outputId": "d057cf19-4d40-477a-964c-d2b6154e1e73" + }, + "source": [ + "from google.colab import data_table\n", + "data_table.DataTable(chapter_word_counts, include_index=False)" + ], + "execution_count": 39, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "application/vnd.google.colaboratory.module+javascript": "\n import \"https://ssl.gstatic.com/colaboratory/data_table/a6224c040fa35dcf/data_table.js\";\n\n window.createDataTable({\n data: [[\"01_0_Introduction.md\",\n{\n 'v': 1128,\n 'f': \"1128\",\n }],\n [\"01_1_Introducing_Bitcoin.md\",\n{\n 'v': 2784,\n 'f': \"2784\",\n }],\n [\"02_0_Setting_Up_a_Bitcoin-Core_VPS.md\",\n{\n 'v': 221,\n 'f': \"221\",\n }],\n [\"02_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md\",\n{\n 'v': 1937,\n 'f': \"1937\",\n }],\n [\"02_2_Setting_Up_Bitcoin_Core_Other.md\",\n{\n 'v': 245,\n 'f': \"245\",\n }],\n [\"03_0_Understanding_Your_Bitcoin_Setup.md\",\n{\n 'v': 225,\n 'f': \"225\",\n }],\n [\"03_1_Verifying_Your_Bitcoin_Setup.md\",\n{\n 'v': 801,\n 'f': \"801\",\n }],\n [\"03_2_Knowing_Your_Bitcoin_Setup.md\",\n{\n 'v': 540,\n 'f': \"540\",\n }],\n [\"03_3_Setting_Up_Your_Wallet.md\",\n{\n 'v': 1741,\n 'f': \"1741\",\n }],\n [\"03_3__Interlude_Using_Command-Line_Variables.md\",\n{\n 'v': 354,\n 'f': \"354\",\n }],\n [\"03_4_Receiving_a_Transaction.md\",\n{\n 'v': 1521,\n 'f': \"1521\",\n }],\n [\"03_5_Understanding_the_Descriptor.md\",\n{\n 'v': 1393,\n 'f': \"1393\",\n }],\n [\"04_0_Sending_Bitcoin_Transactions.md\",\n{\n 'v': 153,\n 'f': \"153\",\n }],\n [\"04_1_Sending_Coins_The_Easy_Way.md\",\n{\n 'v': 1087,\n 'f': \"1087\",\n }],\n [\"04_2_Creating_a_Raw_Transaction.md\",\n{\n 'v': 1840,\n 'f': \"1840\",\n }],\n [\"04_2__Interlude_Using_JQ.md\",\n{\n 'v': 2034,\n 'f': \"2034\",\n }],\n [\"04_3_Creating_a_Raw_Transaction_with_Named_Arguments.md\",\n{\n 'v': 428,\n 'f': \"428\",\n }],\n [\"04_4_Sending_Coins_with_a_Raw_Transaction.md\",\n{\n 'v': 1011,\n 'f': \"1011\",\n }],\n [\"04_4__Interlude_Using_Curl.md\",\n{\n 'v': 1247,\n 'f': \"1247\",\n }],\n [\"04_5_Sending_Coins_with_Automated_Raw_Transactions.md\",\n{\n 'v': 608,\n 'f': \"608\",\n }],\n [\"04_6_Creating_a_Segwit_Transaction.md\",\n{\n 'v': 1203,\n 'f': \"1203\",\n }],\n [\"05_0_Controlling_Bitcoin_Transactions.md\",\n{\n 'v': 144,\n 'f': \"144\",\n }],\n [\"05_1_Watching_for_Stuck_Transactions.md\",\n{\n 'v': 588,\n 'f': \"588\",\n }],\n [\"05_2_Resending_a_Transaction_with_RBF.md\",\n{\n 'v': 1412,\n 'f': \"1412\",\n }],\n [\"05_3_Funding_a_Transaction_with_CPFP.md\",\n{\n 'v': 846,\n 'f': \"846\",\n }],\n [\"06_0_Expanding_Bitcoin_Transactions_Multisigs.md\",\n{\n 'v': 148,\n 'f': \"148\",\n }],\n [\"06_1_Sending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1810,\n 'f': \"1810\",\n }],\n [\"06_2_Spending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1131,\n 'f': \"1131\",\n }],\n [\"06_3_Sending_an_Automated_Multisig.md\",\n{\n 'v': 625,\n 'f': \"625\",\n }],\n [\"07_0_Expanding_Bitcoin_Transactions_PSBTs.md\",\n{\n 'v': 163,\n 'f': \"163\",\n }],\n [\"07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1512,\n 'f': \"1512\",\n }],\n [\"07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1383,\n 'f': \"1383\",\n }],\n [\"07_3_Integrating_with_Hardware_Wallets.md\",\n{\n 'v': 2183,\n 'f': \"2183\",\n }],\n [\"08_0_Expanding_Bitcoin_Transactions_Other.md\",\n{\n 'v': 131,\n 'f': \"131\",\n }],\n [\"08_1_Sending_a_Transaction_with_a_Locktime.md\",\n{\n 'v': 1508,\n 'f': \"1508\",\n }],\n [\"08_2_Sending_a_Transaction_with_Data.md\",\n{\n 'v': 596,\n 'f': \"596\",\n }],\n [\"09_0_Introducing_Bitcoin_Scripts.md\",\n{\n 'v': 187,\n 'f': \"187\",\n }],\n [\"09_1_Understanding_the_Foundation_of_Transactions.md\",\n{\n 'v': 993,\n 'f': \"993\",\n }],\n [\"09_2_Running_a_Bitcoin_Script.md\",\n{\n 'v': 887,\n 'f': \"887\",\n }],\n [\"09_3_Testing_a_Bitcoin_Script.md\",\n{\n 'v': 1023,\n 'f': \"1023\",\n }],\n [\"09_4_Scripting_a_P2PKH.md\",\n{\n 'v': 889,\n 'f': \"889\",\n }],\n [\"09_5_Scripting_a_P2WPKH.md\",\n{\n 'v': 881,\n 'f': \"881\",\n }],\n [\"10_0_Embedding_Bitcoin_Scripts_in_P2SH_Transactions.md\",\n{\n 'v': 152,\n 'f': \"152\",\n }],\n [\"10_1_Understanding_the_Foundation_of_P2SH.md\",\n{\n 'v': 1179,\n 'f': \"1179\",\n }],\n [\"10_2_Building_the_Structure_of_P2SH.md\",\n{\n 'v': 1318,\n 'f': \"1318\",\n }],\n [\"10_3_Running_a_Bitcoin_Script_with_P2SH.md\",\n{\n 'v': 340,\n 'f': \"340\",\n }],\n [\"10_4_Scripting_a_Multisig.md\",\n{\n 'v': 1043,\n 'f': \"1043\",\n }],\n [\"10_5_Scripting_a_Segwit_Script.md\",\n{\n 'v': 751,\n 'f': \"751\",\n }],\n [\"10_6_Spending_a_P2SH_Transaction.md\",\n{\n 'v': 393,\n 'f': \"393\",\n }],\n [\"11_0_Empowering_Timelock_with_Bitcoin_Scripts.md\",\n{\n 'v': 99,\n 'f': \"99\",\n }],\n [\"11_1_Understanding_Timelock_Options.md\",\n{\n 'v': 571,\n 'f': \"571\",\n }],\n [\"11_2_Using_CLTV_in_Scripts.md\",\n{\n 'v': 1241,\n 'f': \"1241\",\n }],\n [\"11_3_Using_CSV_in_Scripts.md\",\n{\n 'v': 1544,\n 'f': \"1544\",\n }],\n [\"12_0_Expanding_Bitcoin_Scripts.md\",\n{\n 'v': 99,\n 'f': \"99\",\n }],\n [\"12_1_Using_Script_Conditionals.md\",\n{\n 'v': 1216,\n 'f': \"1216\",\n }],\n [\"12_2_Using_Other_Script_Commands.md\",\n{\n 'v': 483,\n 'f': \"483\",\n }],\n [\"13_0_Designing_Real_Bitcoin_Scripts.md\",\n{\n 'v': 112,\n 'f': \"112\",\n }],\n [\"13_1_Writing_Puzzle_Scripts.md\",\n{\n 'v': 1032,\n 'f': \"1032\",\n }],\n [\"13_2_Writing_Complex_Multisig_Scripts.md\",\n{\n 'v': 1031,\n 'f': \"1031\",\n }],\n [\"13_3_Empowering_Bitcoin_with_Scripts.md\",\n{\n 'v': 1493,\n 'f': \"1493\",\n }],\n [\"14_0_Using_Tor.md\",\n{\n 'v': 110,\n 'f': \"110\",\n }],\n [\"14_1_Verifying_Your_Tor_Setup.md\",\n{\n 'v': 1632,\n 'f': \"1632\",\n }],\n [\"14_2_Changing_Your_Bitcoin_Hidden_Services.md\",\n{\n 'v': 460,\n 'f': \"460\",\n }],\n [\"14_3_Adding_SSH_Hidden_Services.md\",\n{\n 'v': 339,\n 'f': \"339\",\n }],\n [\"15_0_Talking_to_Bitcoind.md\",\n{\n 'v': 251,\n 'f': \"251\",\n }],\n [\"15_1_Accessing_Bitcoind_with_C.md\",\n{\n 'v': 1315,\n 'f': \"1315\",\n }],\n [\"15_2_Programming_Bitcoind_with_C.md\",\n{\n 'v': 1484,\n 'f': \"1484\",\n }],\n [\"15_3_Receiving_Bitcoind_Notifications_with_C.md\",\n{\n 'v': 669,\n 'f': \"669\",\n }],\n [\"16_0_Programming_with_Libwally.md\",\n{\n 'v': 317,\n 'f': \"317\",\n }],\n [\"16_1_Setting_Up_Libwally.md\",\n{\n 'v': 583,\n 'f': \"583\",\n }],\n [\"16_2_Using_BIP39_in_Libwally.md\",\n{\n 'v': 958,\n 'f': \"958\",\n }],\n [\"16_3_Using_BIP32_in_Libwally.md\",\n{\n 'v': 978,\n 'f': \"978\",\n }],\n [\"16_4_Using_PSBTs_in_Libwally.md\",\n{\n 'v': 1005,\n 'f': \"1005\",\n }],\n [\"16_5_Using_Scripts_in_Libwally.md\",\n{\n 'v': 789,\n 'f': \"789\",\n }],\n [\"16_6_Using_Other_Functions_in_Libwally.md\",\n{\n 'v': 746,\n 'f': \"746\",\n }],\n [\"16_7_Integrating_Libwally_and_Bitcoin-CLI.md\",\n{\n 'v': 1401,\n 'f': \"1401\",\n }],\n [\"17_0_Talking_to_Bitcoind_Other.md\",\n{\n 'v': 272,\n 'f': \"272\",\n }],\n [\"17_1_Accessing_Bitcoind_with_Go.md\",\n{\n 'v': 697,\n 'f': \"697\",\n }],\n [\"17_2_Accessing_Bitcoind_with_Java.md\",\n{\n 'v': 782,\n 'f': \"782\",\n }],\n [\"17_3_Accessing_Bitcoind_with_NodeJS.md\",\n{\n 'v': 476,\n 'f': \"476\",\n }],\n [\"17_4_Accessing_Bitcoind_with_Python.md\",\n{\n 'v': 1246,\n 'f': \"1246\",\n }],\n [\"17_5_Accessing_Bitcoind_with_Rust.md\",\n{\n 'v': 905,\n 'f': \"905\",\n }],\n [\"17_6_Accessing_Bitcoind_with_Swift.md\",\n{\n 'v': 1588,\n 'f': \"1588\",\n }],\n [\"18_0_Understanding_Your_Lightning_Setup.md\",\n{\n 'v': 185,\n 'f': \"185\",\n }],\n [\"18_1_Verifying_Your_Lightning_Setup.md\",\n{\n 'v': 1347,\n 'f': \"1347\",\n }],\n [\"18_2_Knowing_Your_lightning_Setup.md\",\n{\n 'v': 421,\n 'f': \"421\",\n }],\n [\"18_2__Interlude_Accessing_a_Second_Lightning_Node.md\",\n{\n 'v': 882,\n 'f': \"882\",\n }],\n [\"18_3_Setting_Up_a_Channel.md\",\n{\n 'v': 1219,\n 'f': \"1219\",\n }],\n [\"19_0_Using_Lightning.md\",\n{\n 'v': 145,\n 'f': \"145\",\n }],\n [\"19_1_Generate_a_Payment_Request.md\",\n{\n 'v': 995,\n 'f': \"995\",\n }],\n [\"19_2_Paying_a_Invoice.md\",\n{\n 'v': 614,\n 'f': \"614\",\n }],\n [\"19_3_Closing_a_Channel.md\",\n{\n 'v': 866,\n 'f': \"866\",\n }],\n [\"19_4_Lightning_Network_Review.md\",\n{\n 'v': 677,\n 'f': \"677\",\n }],\n [\"A0_Appendices.md\",\n{\n 'v': 110,\n 'f': \"110\",\n }],\n [\"A1_0_Understanding_Bitcoin_Standup.md\",\n{\n 'v': 412,\n 'f': \"412\",\n }],\n [\"A2_0_Compiling_Bitcoin_from_Source.md\",\n{\n 'v': 414,\n 'f': \"414\",\n }],\n [\"A3_0_Using_Bitcoin_Regtest.md\",\n{\n 'v': 995,\n 'f': \"995\",\n }],\n [\"CLA.md\",\n{\n 'v': 512,\n 'f': \"512\",\n }],\n [\"CONTRIBUTING.md\",\n{\n 'v': 555,\n 'f': \"555\",\n }],\n [\"LICENSE-CC-BY-4.0.md\",\n{\n 'v': 2734,\n 'f': \"2734\",\n }],\n [\"README.md\",\n{\n 'v': 1366,\n 'f': \"1366\",\n }],\n [\"TODO-30.md\",\n{\n 'v': 122,\n 'f': \"122\",\n }],\n [\"TODO.md\",\n{\n 'v': 734,\n 'f': \"734\",\n }]],\n columns: [[\"string\", \"Chapter\"], [\"number\", \"Word Count\"]],\n columnOptions: [],\n rowsPerPage: 25,\n helpUrl: \"https://colab.research.google.com/notebooks/data_table.ipynb\",\n suppressOutputScrolling: true,\n minimumWidth: undefined,\n });\n ", + "text/plain": [ + "" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
ChapterWord Count
4401_0_Introduction.md1128
6901_1_Introducing_Bitcoin.md2784
9202_0_Setting_Up_a_Bitcoin-Core_VPS.md221
3302_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackS...1937
6602_2_Setting_Up_Bitcoin_Core_Other.md245
.........
45CONTRIBUTING.md555
34LICENSE-CC-BY-4.0.md2734
0README.md1366
52TODO-30.md122
29TODO.md734
\n", + "

103 rows × 2 columns

\n", + "
" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 39 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "4dFD792BBy0S", + "outputId": "945da188-2d3b-4061-8f23-08e39e6f97f4" + }, + "source": [ + "total_count = chapter_word_counts['Word Count'].sum()\n", + "total_count" + ], + "execution_count": 44, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "89946" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 44 + } + ] + } + ] +} \ No newline at end of file From 85df221a795b02bdd985f3f3a3491b5bda0beb83 Mon Sep 17 00:00:00 2001 From: Ian Culp <57159226+icculp@users.noreply.github.com> Date: Fri, 11 Jun 2021 21:27:53 -0500 Subject: [PATCH 02/12] removing np import, re-running output --- word_count.ipynb | 35 +++++++++++++++++------------------ 1 file changed, 17 insertions(+), 18 deletions(-) diff --git a/word_count.ipynb b/word_count.ipynb index 7a19a21..7722901 100644 --- a/word_count.ipynb +++ b/word_count.ipynb @@ -5,7 +5,7 @@ "colab": { "name": "Untitled25.ipynb", "provenance": [], - "authorship_tag": "ABX9TyOJqhnf6/YgfQMx6pfh6Fth", + "authorship_tag": "ABX9TyMioTaWOtZ3dcIebltCT4IN", "include_colab_link": true }, "kernelspec": { @@ -33,11 +33,10 @@ "id": "kT4wyWuy2szs" }, "source": [ - "import numpy as np\n", "import os\n", "import pandas as pd" ], - "execution_count": 7, + "execution_count": 1, "outputs": [] }, { @@ -47,7 +46,7 @@ "base_uri": "https://localhost:8080/" }, "id": "9J62Uh4H2Y9g", - "outputId": "f4147b98-f72a-4ad2-8b5b-c3bb9f0c86db" + "outputId": "0ac3147d-fdb4-4b9c-d96b-4da334730a93" }, "source": [ "!git clone https://github.com/icculp/Learning-Bitcoin-from-the-Command-Line.git" @@ -58,12 +57,12 @@ "output_type": "stream", "text": [ "Cloning into 'Learning-Bitcoin-from-the-Command-Line'...\n", - "remote: Enumerating objects: 6634, done.\u001b[K\n", - "remote: Counting objects: 100% (238/238), done.\u001b[K\n", - "remote: Compressing objects: 100% (196/196), done.\u001b[K\n", - "remote: Total 6634 (delta 109), reused 82 (delta 42), pack-reused 6396\u001b[K\n", - "Receiving objects: 100% (6634/6634), 7.53 MiB | 13.87 MiB/s, done.\n", - "Resolving deltas: 100% (4068/4068), done.\n" + "remote: Enumerating objects: 6637, done.\u001b[K\n", + "remote: Counting objects: 100% (241/241), done.\u001b[K\n", + "remote: Compressing objects: 100% (199/199), done.\u001b[K\n", + "remote: Total 6637 (delta 110), reused 82 (delta 42), pack-reused 6396\u001b[K\n", + "Receiving objects: 100% (6637/6637), 7.53 MiB | 18.46 MiB/s, done.\n", + "Resolving deltas: 100% (4069/4069), done.\n" ], "name": "stdout" } @@ -103,7 +102,7 @@ " # print(chapter, count)\n", " return pd.DataFrame(counts, columns=columns)" ], - "execution_count": 35, + "execution_count": 3, "outputs": [] }, { @@ -115,7 +114,7 @@ "chapter_word_counts = count_words()\n", "chapter_word_counts.sort_values(by=['Chapter'], inplace=True)" ], - "execution_count": 38, + "execution_count": 4, "outputs": [] }, { @@ -126,13 +125,13 @@ "height": 631 }, "id": "IPkG4oQJ6f1e", - "outputId": "d057cf19-4d40-477a-964c-d2b6154e1e73" + "outputId": "eea2f4b6-c3d3-48b5-dc62-97885c18d48d" }, "source": [ "from google.colab import data_table\n", "data_table.DataTable(chapter_word_counts, include_index=False)" ], - "execution_count": 39, + "execution_count": 5, "outputs": [ { "output_type": "execute_result", @@ -229,7 +228,7 @@ "metadata": { "tags": [] }, - "execution_count": 39 + "execution_count": 5 } ] }, @@ -240,13 +239,13 @@ "base_uri": "https://localhost:8080/" }, "id": "4dFD792BBy0S", - "outputId": "945da188-2d3b-4061-8f23-08e39e6f97f4" + "outputId": "3c4dc4ff-ceb3-4ff5-d40d-c606eec83a8c" }, "source": [ "total_count = chapter_word_counts['Word Count'].sum()\n", "total_count" ], - "execution_count": 44, + "execution_count": 6, "outputs": [ { "output_type": "execute_result", @@ -258,7 +257,7 @@ "metadata": { "tags": [] }, - "execution_count": 44 + "execution_count": 6 } ] } From ae7c0f6c21a12c7677550ef6aa35eec57097914e Mon Sep 17 00:00:00 2001 From: Ian Culp <57159226+icculp@users.noreply.github.com> Date: Wed, 16 Jun 2021 21:33:52 -0500 Subject: [PATCH 03/12] Rename word_count.ipynb to word_count_old.ipynb --- word_count.ipynb => word_count_old.ipynb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) rename word_count.ipynb => word_count_old.ipynb (99%) diff --git a/word_count.ipynb b/word_count_old.ipynb similarity index 99% rename from word_count.ipynb rename to word_count_old.ipynb index 7722901..62bd3e6 100644 --- a/word_count.ipynb +++ b/word_count_old.ipynb @@ -262,4 +262,4 @@ ] } ] -} \ No newline at end of file +} From db2d05f8705e1b291a71246720110ce22a839035 Mon Sep 17 00:00:00 2001 From: Ian Culp <57159226+icculp@users.noreply.github.com> Date: Wed, 16 Jun 2021 21:34:56 -0500 Subject: [PATCH 04/12] Updated for markdown + edge cases --- Chapter_word_count.ipynb | 362 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 362 insertions(+) create mode 100644 Chapter_word_count.ipynb diff --git a/Chapter_word_count.ipynb b/Chapter_word_count.ipynb new file mode 100644 index 0000000..8ce5aff --- /dev/null +++ b/Chapter_word_count.ipynb @@ -0,0 +1,362 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Untitled25.ipynb", + "provenance": [], + "authorship_tag": "ABX9TyNJdlLdL56gLSWYqG177B0A", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "TQUe8ZZed-Bp" + }, + "source": [ + "Run in colab by clicking the link above to view the results as a paginated table with word counts for each chapter near the bottom of the notebook. Total word count at the very bottom." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "X7D8JEIgy9fV" + }, + "source": [ + "This notebook counts through the translatable words of each chapter, including chapter links; ignores code blocks, markdown characters, and tokens containing digits." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "kT4wyWuy2szs" + }, + "source": [ + "import os\n", + "import pandas as pd\n", + "import re" + ], + "execution_count": 1, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "9J62Uh4H2Y9g", + "outputId": "8d2c4675-ddf9-4cd5-8fb2-ee4cae9b034d" + }, + "source": [ + "!git clone https://github.com/icculp/Learning-Bitcoin-from-the-Command-Line.git" + ], + "execution_count": 2, + "outputs": [ + { + "output_type": "stream", + "text": [ + "fatal: destination path 'Learning-Bitcoin-from-the-Command-Line' already exists and is not an empty directory.\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "k_g4-Fvn2yPy" + }, + "source": [ + "def count_words():\n", + " \"\"\" Counts words ignoring code blocks and digits\n", + "\n", + " To test for quality:\n", + " lines 14-16 to test a single chapter\n", + " uncomment line 45 to view accepted word tokens\n", + " uncomment line \n", + " \"\"\"\n", + " columns=['Chapter', 'Word Count']\n", + " counts = []\n", + " repo_path = '/content/Learning-Bitcoin-from-the-Command-Line/'\n", + " for chapter in os.listdir(repo_path):\n", + " ''' uncomment lines 8-10 to test a single chapter, replacing ch_name\n", + " with the name you want to test\n", + " '''\n", + " #ch_name = '03_2_Knowing_Your_Bitcoin_Setup.md'\n", + " #if chapter != ch_name:\n", + " # continue\n", + " ignore_list = ['bitcoin.conf-annotated.txt', 'TODO.md', 'TODO-30.md']\n", + " if chapter in ignore_list or\\\n", + " not chapter.endswith('md'): # g\n", + " continue\n", + " count = 0\n", + " flag = 0 # ignores words between code markdown ```\n", + " with open(repo_path + chapter) as ch:\n", + " for line in ch.readlines():\n", + " if flag:\n", + " if '```' in line[:3].replace(' ', ''):\n", + " flag = 0\n", + " continue\n", + " continue\n", + " if '```' in line:\n", + " flag = 1\n", + " continue\n", + " for word in line.split():\n", + " if '.md' in word:\n", + " ch_link_tokens = word.split('_')\n", + " if ']' in word: # indicates trailing link with chapter name; counts last word of trailing link before chapter name\n", + " count += 1\n", + " link_tokens_count = len(ch_link_tokens[2:]) # ignoring chapter numbers in chapter link tokens\n", + " count += link_tokens_count\n", + " # print(word, '[TOK]', link_tokens_count, end='[SEPTOK]')\n", + " continue\n", + " ignore = ['*', '**', '#', '##', '###', '####',\n", + " '-', '—', '>', '`', '/', '&', '|', '~']\n", + " if any(ch.isdigit() for ch in word) or\\\n", + " word in ignore or\\\n", + " '`' in word or\\\n", + " '~/' in word or\\\n", + " '/.' in word or\\\n", + " '|-' in word or\\\n", + " (word[0] == ':' and word[-1] == ':') or\\\n", + " (word[0] == '\"' and word[-1] == '\"'):\n", + " # print(word) # , end='[SEP]') # view rejected tokens\n", + " continue\n", + " # print(word, count) # , end='[SEP]') # view accepted tokens\n", + " count += 1\n", + " counts.append((chapter, count))\n", + " # print(chapter, count)\n", + " return pd.DataFrame(counts, columns=columns)" + ], + "execution_count": 3, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "2-pkEaYF3Uxm" + }, + "source": [ + "chapter_word_counts = count_words()\n", + "chapter_word_counts.sort_values(by=['Chapter'], inplace=True)\n", + "# view accepted or rejected tokens below if line 53 or 51 uncommented in count_words(), respectively" + ], + "execution_count": 4, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 631 + }, + "id": "K73GH7UFmwI5", + "outputId": "d1430339-8b1b-43f3-cdcf-1019948c7b9c" + }, + "source": [ + "from google.colab import data_table\n", + "data_table.DataTable(chapter_word_counts, include_index=False)" + ], + "execution_count": 5, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "application/vnd.google.colaboratory.module+javascript": "\n import \"https://ssl.gstatic.com/colaboratory/data_table/a6224c040fa35dcf/data_table.js\";\n\n window.createDataTable({\n data: [[\"01_0_Introduction.md\",\n{\n 'v': 1144,\n 'f': \"1144\",\n }],\n [\"01_1_Introducing_Bitcoin.md\",\n{\n 'v': 2735,\n 'f': \"2735\",\n }],\n [\"02_0_Setting_Up_a_Bitcoin-Core_VPS.md\",\n{\n 'v': 226,\n 'f': \"226\",\n }],\n [\"02_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md\",\n{\n 'v': 2723,\n 'f': \"2723\",\n }],\n [\"02_2_Setting_Up_Bitcoin_Core_Other.md\",\n{\n 'v': 254,\n 'f': \"254\",\n }],\n [\"03_0_Understanding_Your_Bitcoin_Setup.md\",\n{\n 'v': 248,\n 'f': \"248\",\n }],\n [\"03_1_Verifying_Your_Bitcoin_Setup.md\",\n{\n 'v': 773,\n 'f': \"773\",\n }],\n [\"03_2_Knowing_Your_Bitcoin_Setup.md\",\n{\n 'v': 517,\n 'f': \"517\",\n }],\n [\"03_3_Setting_Up_Your_Wallet.md\",\n{\n 'v': 1699,\n 'f': \"1699\",\n }],\n [\"03_3__Interlude_Using_Command-Line_Variables.md\",\n{\n 'v': 347,\n 'f': \"347\",\n }],\n [\"03_4_Receiving_a_Transaction.md\",\n{\n 'v': 1479,\n 'f': \"1479\",\n }],\n [\"03_5_Understanding_the_Descriptor.md\",\n{\n 'v': 1349,\n 'f': \"1349\",\n }],\n [\"04_0_Sending_Bitcoin_Transactions.md\",\n{\n 'v': 176,\n 'f': \"176\",\n }],\n [\"04_1_Sending_Coins_The_Easy_Way.md\",\n{\n 'v': 1068,\n 'f': \"1068\",\n }],\n [\"04_2_Creating_a_Raw_Transaction.md\",\n{\n 'v': 1720,\n 'f': \"1720\",\n }],\n [\"04_2__Interlude_Using_JQ.md\",\n{\n 'v': 1956,\n 'f': \"1956\",\n }],\n [\"04_3_Creating_a_Raw_Transaction_with_Named_Arguments.md\",\n{\n 'v': 413,\n 'f': \"413\",\n }],\n [\"04_4_Sending_Coins_with_a_Raw_Transaction.md\",\n{\n 'v': 1024,\n 'f': \"1024\",\n }],\n [\"04_4__Interlude_Using_Curl.md\",\n{\n 'v': 1643,\n 'f': \"1643\",\n }],\n [\"04_5_Sending_Coins_with_Automated_Raw_Transactions.md\",\n{\n 'v': 614,\n 'f': \"614\",\n }],\n [\"04_6_Creating_a_Segwit_Transaction.md\",\n{\n 'v': 1172,\n 'f': \"1172\",\n }],\n [\"05_0_Controlling_Bitcoin_Transactions.md\",\n{\n 'v': 149,\n 'f': \"149\",\n }],\n [\"05_1_Watching_for_Stuck_Transactions.md\",\n{\n 'v': 595,\n 'f': \"595\",\n }],\n [\"05_2_Resending_a_Transaction_with_RBF.md\",\n{\n 'v': 1372,\n 'f': \"1372\",\n }],\n [\"05_3_Funding_a_Transaction_with_CPFP.md\",\n{\n 'v': 827,\n 'f': \"827\",\n }],\n [\"06_0_Expanding_Bitcoin_Transactions_Multisigs.md\",\n{\n 'v': 155,\n 'f': \"155\",\n }],\n [\"06_1_Sending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1764,\n 'f': \"1764\",\n }],\n [\"06_2_Spending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1079,\n 'f': \"1079\",\n }],\n [\"06_3_Sending_an_Automated_Multisig.md\",\n{\n 'v': 613,\n 'f': \"613\",\n }],\n [\"07_0_Expanding_Bitcoin_Transactions_PSBTs.md\",\n{\n 'v': 169,\n 'f': \"169\",\n }],\n [\"07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1470,\n 'f': \"1470\",\n }],\n [\"07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1393,\n 'f': \"1393\",\n }],\n [\"07_3_Integrating_with_Hardware_Wallets.md\",\n{\n 'v': 2150,\n 'f': \"2150\",\n }],\n [\"08_0_Expanding_Bitcoin_Transactions_Other.md\",\n{\n 'v': 139,\n 'f': \"139\",\n }],\n [\"08_1_Sending_a_Transaction_with_a_Locktime.md\",\n{\n 'v': 1483,\n 'f': \"1483\",\n }],\n [\"08_2_Sending_a_Transaction_with_Data.md\",\n{\n 'v': 580,\n 'f': \"580\",\n }],\n [\"09_0_Introducing_Bitcoin_Scripts.md\",\n{\n 'v': 196,\n 'f': \"196\",\n }],\n [\"09_1_Understanding_the_Foundation_of_Transactions.md\",\n{\n 'v': 989,\n 'f': \"989\",\n }],\n [\"09_2_Running_a_Bitcoin_Script.md\",\n{\n 'v': 863,\n 'f': \"863\",\n }],\n [\"09_3_Testing_a_Bitcoin_Script.md\",\n{\n 'v': 1000,\n 'f': \"1000\",\n }],\n [\"09_4_Scripting_a_P2PKH.md\",\n{\n 'v': 838,\n 'f': \"838\",\n }],\n [\"09_5_Scripting_a_P2WPKH.md\",\n{\n 'v': 845,\n 'f': \"845\",\n }],\n [\"10_0_Embedding_Bitcoin_Scripts_in_P2SH_Transactions.md\",\n{\n 'v': 170,\n 'f': \"170\",\n }],\n [\"10_1_Understanding_the_Foundation_of_P2SH.md\",\n{\n 'v': 1164,\n 'f': \"1164\",\n }],\n [\"10_2_Building_the_Structure_of_P2SH.md\",\n{\n 'v': 1284,\n 'f': \"1284\",\n }],\n [\"10_3_Running_a_Bitcoin_Script_with_P2SH.md\",\n{\n 'v': 323,\n 'f': \"323\",\n }],\n [\"10_4_Scripting_a_Multisig.md\",\n{\n 'v': 1016,\n 'f': \"1016\",\n }],\n [\"10_5_Scripting_a_Segwit_Script.md\",\n{\n 'v': 750,\n 'f': \"750\",\n }],\n [\"10_6_Spending_a_P2SH_Transaction.md\",\n{\n 'v': 384,\n 'f': \"384\",\n }],\n [\"11_0_Empowering_Timelock_with_Bitcoin_Scripts.md\",\n{\n 'v': 108,\n 'f': \"108\",\n }],\n [\"11_1_Understanding_Timelock_Options.md\",\n{\n 'v': 557,\n 'f': \"557\",\n }],\n [\"11_2_Using_CLTV_in_Scripts.md\",\n{\n 'v': 1197,\n 'f': \"1197\",\n }],\n [\"11_3_Using_CSV_in_Scripts.md\",\n{\n 'v': 1470,\n 'f': \"1470\",\n }],\n [\"12_0_Expanding_Bitcoin_Scripts.md\",\n{\n 'v': 99,\n 'f': \"99\",\n }],\n [\"12_1_Using_Script_Conditionals.md\",\n{\n 'v': 1120,\n 'f': \"1120\",\n }],\n [\"12_2_Using_Other_Script_Commands.md\",\n{\n 'v': 407,\n 'f': \"407\",\n }],\n [\"13_0_Designing_Real_Bitcoin_Scripts.md\",\n{\n 'v': 116,\n 'f': \"116\",\n }],\n [\"13_1_Writing_Puzzle_Scripts.md\",\n{\n 'v': 998,\n 'f': \"998\",\n }],\n [\"13_2_Writing_Complex_Multisig_Scripts.md\",\n{\n 'v': 996,\n 'f': \"996\",\n }],\n [\"13_3_Empowering_Bitcoin_with_Scripts.md\",\n{\n 'v': 1467,\n 'f': \"1467\",\n }],\n [\"14_0_Using_Tor.md\",\n{\n 'v': 116,\n 'f': \"116\",\n }],\n [\"14_1_Verifying_Your_Tor_Setup.md\",\n{\n 'v': 1568,\n 'f': \"1568\",\n }],\n [\"14_2_Changing_Your_Bitcoin_Hidden_Services.md\",\n{\n 'v': 434,\n 'f': \"434\",\n }],\n [\"14_3_Adding_SSH_Hidden_Services.md\",\n{\n 'v': 330,\n 'f': \"330\",\n }],\n [\"15_0_Talking_to_Bitcoind.md\",\n{\n 'v': 254,\n 'f': \"254\",\n }],\n [\"15_1_Accessing_Bitcoind_with_C.md\",\n{\n 'v': 1238,\n 'f': \"1238\",\n }],\n [\"15_2_Programming_Bitcoind_with_C.md\",\n{\n 'v': 1427,\n 'f': \"1427\",\n }],\n [\"15_3_Receiving_Bitcoind_Notifications_with_C.md\",\n{\n 'v': 650,\n 'f': \"650\",\n }],\n [\"16_0_Programming_with_Libwally.md\",\n{\n 'v': 333,\n 'f': \"333\",\n }],\n [\"16_1_Setting_Up_Libwally.md\",\n{\n 'v': 559,\n 'f': \"559\",\n }],\n [\"16_2_Using_BIP39_in_Libwally.md\",\n{\n 'v': 939,\n 'f': \"939\",\n }],\n [\"16_3_Using_BIP32_in_Libwally.md\",\n{\n 'v': 959,\n 'f': \"959\",\n }],\n [\"16_4_Using_PSBTs_in_Libwally.md\",\n{\n 'v': 989,\n 'f': \"989\",\n }],\n [\"16_5_Using_Scripts_in_Libwally.md\",\n{\n 'v': 785,\n 'f': \"785\",\n }],\n [\"16_6_Using_Other_Functions_in_Libwally.md\",\n{\n 'v': 655,\n 'f': \"655\",\n }],\n [\"16_7_Integrating_Libwally_and_Bitcoin-CLI.md\",\n{\n 'v': 1380,\n 'f': \"1380\",\n }],\n [\"17_0_Talking_to_Bitcoind_Other.md\",\n{\n 'v': 286,\n 'f': \"286\",\n }],\n [\"17_1_Accessing_Bitcoind_with_Go.md\",\n{\n 'v': 547,\n 'f': \"547\",\n }],\n [\"17_2_Accessing_Bitcoind_with_Java.md\",\n{\n 'v': 821,\n 'f': \"821\",\n }],\n [\"17_3_Accessing_Bitcoind_with_NodeJS.md\",\n{\n 'v': 393,\n 'f': \"393\",\n }],\n [\"17_4_Accessing_Bitcoind_with_Python.md\",\n{\n 'v': 1158,\n 'f': \"1158\",\n }],\n [\"17_5_Accessing_Bitcoind_with_Rust.md\",\n{\n 'v': 829,\n 'f': \"829\",\n }],\n [\"17_6_Accessing_Bitcoind_with_Swift.md\",\n{\n 'v': 1503,\n 'f': \"1503\",\n }],\n [\"18_0_Understanding_Your_Lightning_Setup.md\",\n{\n 'v': 192,\n 'f': \"192\",\n }],\n [\"18_1_Verifying_Your_Lightning_Setup.md\",\n{\n 'v': 1294,\n 'f': \"1294\",\n }],\n [\"18_2_Knowing_Your_lightning_Setup.md\",\n{\n 'v': 399,\n 'f': \"399\",\n }],\n [\"18_2__Interlude_Accessing_a_Second_Lightning_Node.md\",\n{\n 'v': 886,\n 'f': \"886\",\n }],\n [\"18_3_Setting_Up_a_Channel.md\",\n{\n 'v': 1173,\n 'f': \"1173\",\n }],\n [\"19_0_Using_Lightning.md\",\n{\n 'v': 146,\n 'f': \"146\",\n }],\n [\"19_1_Generate_a_Payment_Request.md\",\n{\n 'v': 968,\n 'f': \"968\",\n }],\n [\"19_2_Paying_a_Invoice.md\",\n{\n 'v': 604,\n 'f': \"604\",\n }],\n [\"19_3_Closing_a_Channel.md\",\n{\n 'v': 848,\n 'f': \"848\",\n }],\n [\"19_4_Lightning_Network_Review.md\",\n{\n 'v': 626,\n 'f': \"626\",\n }],\n [\"A0_Appendices.md\",\n{\n 'v': 112,\n 'f': \"112\",\n }],\n [\"A1_0_Understanding_Bitcoin_Standup.md\",\n{\n 'v': 420,\n 'f': \"420\",\n }],\n [\"A2_0_Compiling_Bitcoin_from_Source.md\",\n{\n 'v': 412,\n 'f': \"412\",\n }],\n [\"A3_0_Using_Bitcoin_Regtest.md\",\n{\n 'v': 980,\n 'f': \"980\",\n }],\n [\"CLA.md\",\n{\n 'v': 495,\n 'f': \"495\",\n }],\n [\"CONTRIBUTING.md\",\n{\n 'v': 529,\n 'f': \"529\",\n }],\n [\"LICENSE-CC-BY-4.0.md\",\n{\n 'v': 2716,\n 'f': \"2716\",\n }],\n [\"README.md\",\n{\n 'v': 1687,\n 'f': \"1687\",\n }]],\n columns: [[\"string\", \"Chapter\"], [\"number\", \"Word Count\"]],\n columnOptions: [],\n rowsPerPage: 25,\n helpUrl: \"https://colab.research.google.com/notebooks/data_table.ipynb\",\n suppressOutputScrolling: true,\n minimumWidth: undefined,\n });\n ", + "text/plain": [ + "" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
ChapterWord Count
7201_0_Introduction.md1144
2101_1_Introducing_Bitcoin.md2735
2002_0_Setting_Up_a_Bitcoin-Core_VPS.md226
9702_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackS...2723
9402_2_Setting_Up_Bitcoin_Core_Other.md254
.........
45A3_0_Using_Bitcoin_Regtest.md980
38CLA.md495
74CONTRIBUTING.md529
53LICENSE-CC-BY-4.0.md2716
2README.md1687
\n", + "

101 rows × 2 columns

\n", + "
" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 5 + } + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "_gGsbGDckIrC", + "outputId": "a9811107-2a07-464a-d96a-c6767e5ea7d4" + }, + "source": [ + "total_count = chapter_word_counts['Word Count'].sum()\n", + "total_count" + ], + "execution_count": 6, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "88215" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 6 + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "14kdusmNzcfz" + }, + "source": [ + "To convert the table to a markdown format and save as 'Chapter_word_counts.md', run the cells below" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "uc7eKo9TkidD" + }, + "source": [ + "from IPython.display import Markdown, display\n", + "from tabulate import tabulate\n", + "\n", + "\n", + "# borrowed from https://stackoverflow.com/questions/33181846/programmatically-convert-pandas-dataframe-to-markdown-table\n", + "\n", + "def pandas_df_to_markdown_table(df):\n", + " fmt = ['---' for i in range(len(df.columns))]\n", + " df_fmt = pd.DataFrame([fmt], columns=df.columns)\n", + " df_formatted = pd.concat([df_fmt, df])\n", + " return Markdown(df_formatted.to_csv(sep=\"|\", index=False))\n", + "\n", + "def df_to_markdown(df, y_index=False):\n", + " blob = tabulate(df, headers='keys', tablefmt='pipe')\n", + " if not y_index:\n", + " return '\\n'.join(['| {}'.format(row.split('|', 2)[-1]) for row in blob.split('\\n')])\n", + " return blob" + ], + "execution_count": 7, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "Y0QVAGKqzWX6" + }, + "source": [ + "mkt = pandas_df_to_markdown_table(chapter_word_counts)\n", + "\n", + "with open('Chapter_word_counts.md', 'w') as m:\n", + " m.write(str(mkt.data))" + ], + "execution_count": 8, + "outputs": [] + } + ] +} \ No newline at end of file From 0568399ecc153077948193c91e3c7543f37eacb1 Mon Sep 17 00:00:00 2001 From: Ian Culp <57159226+icculp@users.noreply.github.com> Date: Wed, 16 Jun 2021 22:14:09 -0500 Subject: [PATCH 05/12] Created using Colaboratory --- Chapter_word_counts.ipynb | 377 ++++++++++++++++++++++++++++++++++++++ 1 file changed, 377 insertions(+) create mode 100644 Chapter_word_counts.ipynb diff --git a/Chapter_word_counts.ipynb b/Chapter_word_counts.ipynb new file mode 100644 index 0000000..e404454 --- /dev/null +++ b/Chapter_word_counts.ipynb @@ -0,0 +1,377 @@ +{ + "nbformat": 4, + "nbformat_minor": 0, + "metadata": { + "colab": { + "name": "Untitled25.ipynb", + "provenance": [], + "authorship_tag": "ABX9TyNHQ/J52I0G+daf1wNCNdAI", + "include_colab_link": true + }, + "kernelspec": { + "name": "python3", + "display_name": "Python 3" + }, + "language_info": { + "name": "python" + } + }, + "cells": [ + { + "cell_type": "markdown", + "metadata": { + "id": "view-in-github", + "colab_type": "text" + }, + "source": [ + "\"Open" + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "X7D8JEIgy9fV" + }, + "source": [ + "This notebook counts through the translatable words of each chapter, including chapter links; ignores code blocks, markdown characters, and tokens containing digits." + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "TQUe8ZZed-Bp" + }, + "source": [ + "Run in colab by clicking the link above to view the results as a paginated table with word counts for each chapter near the bottom of the notebook. Total word count at the very bottom." + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "kT4wyWuy2szs" + }, + "source": [ + "import os\n", + "import pandas as pd" + ], + "execution_count": 1, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "9J62Uh4H2Y9g", + "outputId": "3295f8b2-5255-4eac-bc78-3da247037c41" + }, + "source": [ + "!git clone https://github.com/icculp/Learning-Bitcoin-from-the-Command-Line.git" + ], + "execution_count": 2, + "outputs": [ + { + "output_type": "stream", + "text": [ + "Cloning into 'Learning-Bitcoin-from-the-Command-Line'...\n", + "remote: Enumerating objects: 6715, done.\u001b[K\n", + "remote: Counting objects: 100% (319/319), done.\u001b[K\n", + "remote: Compressing objects: 100% (193/193), done.\u001b[K\n", + "remote: Total 6715 (delta 157), reused 277 (delta 125), pack-reused 6396\u001b[K\n", + "Receiving objects: 100% (6715/6715), 7.56 MiB | 22.84 MiB/s, done.\n", + "Resolving deltas: 100% (4116/4116), done.\n" + ], + "name": "stdout" + } + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "k_g4-Fvn2yPy" + }, + "source": [ + "def count_words():\n", + " \"\"\" Counts words ignoring code blocks and digits\n", + " To test for quality:\n", + " lines 16-18 to test a single chapter\n", + " uncomment line 31 to view skipped code block sections\n", + " uncomment line 55 to view rejected word tokens (not including code blocks)\n", + " uncomment line 57 to view accepted word tokens\n", + " but not at the same time, and best one chapter at a time\n", + " \"\"\"\n", + " counts = []\n", + " repo_path = '/content/Learning-Bitcoin-from-the-Command-Line/'\n", + " for chapter in os.listdir(repo_path):\n", + " ''' uncomment lines 16-18 to test a single chapter, replacing\n", + " ch_name with the name you want to test\n", + " '''\n", + " #ch_name = '04_2__Interlude_Using_JQ.md'\n", + " #if chapter != ch_name:\n", + " # continue\n", + " ignore_list = ['bitcoin.conf-annotated.txt', 'TODO.md', 'TODO-30.md']\n", + " if chapter in ignore_list or\\\n", + " not chapter.endswith('md'):\n", + " continue\n", + " count = 0\n", + " flag = 0 # ignores words between code markdown ```\n", + " with open(repo_path + chapter) as ch:\n", + " for line in ch.readlines():\n", + " if flag:\n", + " if '```' in line[:3].replace(' ', ''): # chars can't precede code closing markdown\n", + " flag = 0\n", + " continue\n", + " # print(line) # view uncounted code blocks\n", + " continue\n", + " if '```' in line:\n", + " flag = 1\n", + " continue\n", + " for word in line.split():\n", + " if '.md' in word: # indicates trailing link with chapter name;\n", + " ch_link_tokens = word.split('_')\n", + " if ']' in word: # counts last word of trailing link before chapter name\n", + " count += 1\n", + " link_tokens_count = len(ch_link_tokens[2:]) # ignoring chapter numbers\n", + " count += link_tokens_count\n", + " # print(word, '[TOK]', link_tokens_count, end='[SEPTOK]')\n", + " continue\n", + " ignore = ['*', '**', '#', '##', '###', '####',\n", + " '-', '—', '>', '`', '/', '&', '|', '~']\n", + " if any(ch.isdigit() for ch in word) or\\\n", + " word in ignore or\\\n", + " '`' in word or\\\n", + " '~/' in word or\\\n", + " '/.' in word or\\\n", + " '|-' in word or\\\n", + " (word[0] == ':' and word[-1] == ':') or\\\n", + " (word[0] == '\"' and word[-1] == '\"'):\n", + " # print(word) # , end='[SEP]') # view rejected tokens\n", + " continue\n", + " # print(word, count) # , end='[SEP]') # view accepted tokens\n", + " count += 1\n", + " counts.append((chapter, count))\n", + " # print(chapter, count)\n", + " return pd.DataFrame(counts, columns=['Chapter', 'Word Count'])" + ], + "execution_count": 3, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "2-pkEaYF3Uxm" + }, + "source": [ + "chapter_word_counts = count_words()\n", + "chapter_word_counts.sort_values(by=['Chapter'], inplace=True)\n", + "# view accepted or rejected tokens below if line 55 or 53 uncommented in count_words(), respectively" + ], + "execution_count": 4, + "outputs": [] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "ZIUumQnh9C_1" + }, + "source": [ + "View in colab for paginated table" + ] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/", + "height": 631 + }, + "id": "K73GH7UFmwI5", + "outputId": "246c0b17-0854-4811-c67f-8081d7950272" + }, + "source": [ + "from google.colab import data_table\n", + "data_table.DataTable(chapter_word_counts, include_index=False)" + ], + "execution_count": 5, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "application/vnd.google.colaboratory.module+javascript": "\n import \"https://ssl.gstatic.com/colaboratory/data_table/a6224c040fa35dcf/data_table.js\";\n\n window.createDataTable({\n data: [[\"01_0_Introduction.md\",\n{\n 'v': 1144,\n 'f': \"1144\",\n }],\n [\"01_1_Introducing_Bitcoin.md\",\n{\n 'v': 2735,\n 'f': \"2735\",\n }],\n [\"02_0_Setting_Up_a_Bitcoin-Core_VPS.md\",\n{\n 'v': 226,\n 'f': \"226\",\n }],\n [\"02_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md\",\n{\n 'v': 2746,\n 'f': \"2746\",\n }],\n [\"02_2_Setting_Up_Bitcoin_Core_Other.md\",\n{\n 'v': 254,\n 'f': \"254\",\n }],\n [\"03_0_Understanding_Your_Bitcoin_Setup.md\",\n{\n 'v': 248,\n 'f': \"248\",\n }],\n [\"03_1_Verifying_Your_Bitcoin_Setup.md\",\n{\n 'v': 773,\n 'f': \"773\",\n }],\n [\"03_2_Knowing_Your_Bitcoin_Setup.md\",\n{\n 'v': 517,\n 'f': \"517\",\n }],\n [\"03_3_Setting_Up_Your_Wallet.md\",\n{\n 'v': 1699,\n 'f': \"1699\",\n }],\n [\"03_3__Interlude_Using_Command-Line_Variables.md\",\n{\n 'v': 347,\n 'f': \"347\",\n }],\n [\"03_4_Receiving_a_Transaction.md\",\n{\n 'v': 1479,\n 'f': \"1479\",\n }],\n [\"03_5_Understanding_the_Descriptor.md\",\n{\n 'v': 1349,\n 'f': \"1349\",\n }],\n [\"04_0_Sending_Bitcoin_Transactions.md\",\n{\n 'v': 176,\n 'f': \"176\",\n }],\n [\"04_1_Sending_Coins_The_Easy_Way.md\",\n{\n 'v': 1195,\n 'f': \"1195\",\n }],\n [\"04_2_Creating_a_Raw_Transaction.md\",\n{\n 'v': 1720,\n 'f': \"1720\",\n }],\n [\"04_2__Interlude_Using_JQ.md\",\n{\n 'v': 1956,\n 'f': \"1956\",\n }],\n [\"04_3_Creating_a_Raw_Transaction_with_Named_Arguments.md\",\n{\n 'v': 413,\n 'f': \"413\",\n }],\n [\"04_4_Sending_Coins_with_a_Raw_Transaction.md\",\n{\n 'v': 1024,\n 'f': \"1024\",\n }],\n [\"04_4__Interlude_Using_Curl.md\",\n{\n 'v': 1643,\n 'f': \"1643\",\n }],\n [\"04_5_Sending_Coins_with_Automated_Raw_Transactions.md\",\n{\n 'v': 614,\n 'f': \"614\",\n }],\n [\"04_6_Creating_a_Segwit_Transaction.md\",\n{\n 'v': 1172,\n 'f': \"1172\",\n }],\n [\"05_0_Controlling_Bitcoin_Transactions.md\",\n{\n 'v': 149,\n 'f': \"149\",\n }],\n [\"05_1_Watching_for_Stuck_Transactions.md\",\n{\n 'v': 595,\n 'f': \"595\",\n }],\n [\"05_2_Resending_a_Transaction_with_RBF.md\",\n{\n 'v': 1372,\n 'f': \"1372\",\n }],\n [\"05_3_Funding_a_Transaction_with_CPFP.md\",\n{\n 'v': 827,\n 'f': \"827\",\n }],\n [\"06_0_Expanding_Bitcoin_Transactions_Multisigs.md\",\n{\n 'v': 155,\n 'f': \"155\",\n }],\n [\"06_1_Sending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1764,\n 'f': \"1764\",\n }],\n [\"06_2_Spending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1079,\n 'f': \"1079\",\n }],\n [\"06_3_Sending_an_Automated_Multisig.md\",\n{\n 'v': 613,\n 'f': \"613\",\n }],\n [\"07_0_Expanding_Bitcoin_Transactions_PSBTs.md\",\n{\n 'v': 169,\n 'f': \"169\",\n }],\n [\"07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1470,\n 'f': \"1470\",\n }],\n [\"07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1393,\n 'f': \"1393\",\n }],\n [\"07_3_Integrating_with_Hardware_Wallets.md\",\n{\n 'v': 2150,\n 'f': \"2150\",\n }],\n [\"08_0_Expanding_Bitcoin_Transactions_Other.md\",\n{\n 'v': 139,\n 'f': \"139\",\n }],\n [\"08_1_Sending_a_Transaction_with_a_Locktime.md\",\n{\n 'v': 1483,\n 'f': \"1483\",\n }],\n [\"08_2_Sending_a_Transaction_with_Data.md\",\n{\n 'v': 580,\n 'f': \"580\",\n }],\n [\"09_0_Introducing_Bitcoin_Scripts.md\",\n{\n 'v': 196,\n 'f': \"196\",\n }],\n [\"09_1_Understanding_the_Foundation_of_Transactions.md\",\n{\n 'v': 989,\n 'f': \"989\",\n }],\n [\"09_2_Running_a_Bitcoin_Script.md\",\n{\n 'v': 863,\n 'f': \"863\",\n }],\n [\"09_3_Testing_a_Bitcoin_Script.md\",\n{\n 'v': 1000,\n 'f': \"1000\",\n }],\n [\"09_4_Scripting_a_P2PKH.md\",\n{\n 'v': 838,\n 'f': \"838\",\n }],\n [\"09_5_Scripting_a_P2WPKH.md\",\n{\n 'v': 845,\n 'f': \"845\",\n }],\n [\"10_0_Embedding_Bitcoin_Scripts_in_P2SH_Transactions.md\",\n{\n 'v': 170,\n 'f': \"170\",\n }],\n [\"10_1_Understanding_the_Foundation_of_P2SH.md\",\n{\n 'v': 1164,\n 'f': \"1164\",\n }],\n [\"10_2_Building_the_Structure_of_P2SH.md\",\n{\n 'v': 1284,\n 'f': \"1284\",\n }],\n [\"10_3_Running_a_Bitcoin_Script_with_P2SH.md\",\n{\n 'v': 323,\n 'f': \"323\",\n }],\n [\"10_4_Scripting_a_Multisig.md\",\n{\n 'v': 1016,\n 'f': \"1016\",\n }],\n [\"10_5_Scripting_a_Segwit_Script.md\",\n{\n 'v': 750,\n 'f': \"750\",\n }],\n [\"10_6_Spending_a_P2SH_Transaction.md\",\n{\n 'v': 384,\n 'f': \"384\",\n }],\n [\"11_0_Empowering_Timelock_with_Bitcoin_Scripts.md\",\n{\n 'v': 108,\n 'f': \"108\",\n }],\n [\"11_1_Understanding_Timelock_Options.md\",\n{\n 'v': 557,\n 'f': \"557\",\n }],\n [\"11_2_Using_CLTV_in_Scripts.md\",\n{\n 'v': 1197,\n 'f': \"1197\",\n }],\n [\"11_3_Using_CSV_in_Scripts.md\",\n{\n 'v': 1470,\n 'f': \"1470\",\n }],\n [\"12_0_Expanding_Bitcoin_Scripts.md\",\n{\n 'v': 99,\n 'f': \"99\",\n }],\n [\"12_1_Using_Script_Conditionals.md\",\n{\n 'v': 1120,\n 'f': \"1120\",\n }],\n [\"12_2_Using_Other_Script_Commands.md\",\n{\n 'v': 407,\n 'f': \"407\",\n }],\n [\"13_0_Designing_Real_Bitcoin_Scripts.md\",\n{\n 'v': 116,\n 'f': \"116\",\n }],\n [\"13_1_Writing_Puzzle_Scripts.md\",\n{\n 'v': 998,\n 'f': \"998\",\n }],\n [\"13_2_Writing_Complex_Multisig_Scripts.md\",\n{\n 'v': 996,\n 'f': \"996\",\n }],\n [\"13_3_Empowering_Bitcoin_with_Scripts.md\",\n{\n 'v': 1467,\n 'f': \"1467\",\n }],\n [\"14_0_Using_Tor.md\",\n{\n 'v': 116,\n 'f': \"116\",\n }],\n [\"14_1_Verifying_Your_Tor_Setup.md\",\n{\n 'v': 1568,\n 'f': \"1568\",\n }],\n [\"14_2_Changing_Your_Bitcoin_Hidden_Services.md\",\n{\n 'v': 434,\n 'f': \"434\",\n }],\n [\"14_3_Adding_SSH_Hidden_Services.md\",\n{\n 'v': 330,\n 'f': \"330\",\n }],\n [\"15_0_Talking_to_Bitcoind.md\",\n{\n 'v': 254,\n 'f': \"254\",\n }],\n [\"15_1_Accessing_Bitcoind_with_C.md\",\n{\n 'v': 1238,\n 'f': \"1238\",\n }],\n [\"15_2_Programming_Bitcoind_with_C.md\",\n{\n 'v': 1427,\n 'f': \"1427\",\n }],\n [\"15_3_Receiving_Bitcoind_Notifications_with_C.md\",\n{\n 'v': 650,\n 'f': \"650\",\n }],\n [\"16_0_Programming_with_Libwally.md\",\n{\n 'v': 333,\n 'f': \"333\",\n }],\n [\"16_1_Setting_Up_Libwally.md\",\n{\n 'v': 559,\n 'f': \"559\",\n }],\n [\"16_2_Using_BIP39_in_Libwally.md\",\n{\n 'v': 939,\n 'f': \"939\",\n }],\n [\"16_3_Using_BIP32_in_Libwally.md\",\n{\n 'v': 959,\n 'f': \"959\",\n }],\n [\"16_4_Using_PSBTs_in_Libwally.md\",\n{\n 'v': 989,\n 'f': \"989\",\n }],\n [\"16_5_Using_Scripts_in_Libwally.md\",\n{\n 'v': 785,\n 'f': \"785\",\n }],\n [\"16_6_Using_Other_Functions_in_Libwally.md\",\n{\n 'v': 655,\n 'f': \"655\",\n }],\n [\"16_7_Integrating_Libwally_and_Bitcoin-CLI.md\",\n{\n 'v': 1380,\n 'f': \"1380\",\n }],\n [\"17_0_Talking_to_Bitcoind_Other.md\",\n{\n 'v': 286,\n 'f': \"286\",\n }],\n [\"17_1_Accessing_Bitcoind_with_Go.md\",\n{\n 'v': 547,\n 'f': \"547\",\n }],\n [\"17_2_Accessing_Bitcoind_with_Java.md\",\n{\n 'v': 821,\n 'f': \"821\",\n }],\n [\"17_3_Accessing_Bitcoind_with_NodeJS.md\",\n{\n 'v': 393,\n 'f': \"393\",\n }],\n [\"17_4_Accessing_Bitcoind_with_Python.md\",\n{\n 'v': 1158,\n 'f': \"1158\",\n }],\n [\"17_5_Accessing_Bitcoind_with_Rust.md\",\n{\n 'v': 829,\n 'f': \"829\",\n }],\n [\"17_6_Accessing_Bitcoind_with_Swift.md\",\n{\n 'v': 1503,\n 'f': \"1503\",\n }],\n [\"18_0_Understanding_Your_Lightning_Setup.md\",\n{\n 'v': 192,\n 'f': \"192\",\n }],\n [\"18_1_Verifying_Your_Lightning_Setup.md\",\n{\n 'v': 1294,\n 'f': \"1294\",\n }],\n [\"18_2_Knowing_Your_lightning_Setup.md\",\n{\n 'v': 399,\n 'f': \"399\",\n }],\n [\"18_2__Interlude_Accessing_a_Second_Lightning_Node.md\",\n{\n 'v': 886,\n 'f': \"886\",\n }],\n [\"18_3_Setting_Up_a_Channel.md\",\n{\n 'v': 1173,\n 'f': \"1173\",\n }],\n [\"19_0_Using_Lightning.md\",\n{\n 'v': 146,\n 'f': \"146\",\n }],\n [\"19_1_Generate_a_Payment_Request.md\",\n{\n 'v': 968,\n 'f': \"968\",\n }],\n [\"19_2_Paying_a_Invoice.md\",\n{\n 'v': 604,\n 'f': \"604\",\n }],\n [\"19_3_Closing_a_Channel.md\",\n{\n 'v': 848,\n 'f': \"848\",\n }],\n [\"19_4_Lightning_Network_Review.md\",\n{\n 'v': 626,\n 'f': \"626\",\n }],\n [\"A0_Appendices.md\",\n{\n 'v': 112,\n 'f': \"112\",\n }],\n [\"A1_0_Understanding_Bitcoin_Standup.md\",\n{\n 'v': 420,\n 'f': \"420\",\n }],\n [\"A2_0_Compiling_Bitcoin_from_Source.md\",\n{\n 'v': 412,\n 'f': \"412\",\n }],\n [\"A3_0_Using_Bitcoin_Regtest.md\",\n{\n 'v': 980,\n 'f': \"980\",\n }],\n [\"CLA.md\",\n{\n 'v': 495,\n 'f': \"495\",\n }],\n [\"CONTRIBUTING.md\",\n{\n 'v': 529,\n 'f': \"529\",\n }],\n [\"LICENSE-CC-BY-4.0.md\",\n{\n 'v': 2716,\n 'f': \"2716\",\n }],\n [\"README.md\",\n{\n 'v': 1705,\n 'f': \"1705\",\n }],\n [\"TRANSLATING.md\",\n{\n 'v': 686,\n 'f': \"686\",\n }]],\n columns: [[\"string\", \"Chapter\"], [\"number\", \"Word Count\"]],\n columnOptions: [],\n rowsPerPage: 25,\n helpUrl: \"https://colab.research.google.com/notebooks/data_table.ipynb\",\n suppressOutputScrolling: true,\n minimumWidth: undefined,\n });\n ", + "text/plain": [ + "" + ], + "text/html": [ + "
\n", + "\n", + "\n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + " \n", + "
ChapterWord Count
6601_0_Introduction.md1144
6401_1_Introducing_Bitcoin.md2735
8202_0_Setting_Up_a_Bitcoin-Core_VPS.md226
7102_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackS...2746
5902_2_Setting_Up_Bitcoin_Core_Other.md254
.........
5CLA.md495
0CONTRIBUTING.md529
34LICENSE-CC-BY-4.0.md2716
29README.md1705
22TRANSLATING.md686
\n", + "

102 rows × 2 columns

\n", + "
" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 5 + } + ] + }, + { + "cell_type": "markdown", + "metadata": { + "id": "14kdusmNzcfz" + }, + "source": [ + "To convert the table to a markdown format and save as 'Chapter_word_counts.md'" + ] + }, + { + "cell_type": "code", + "metadata": { + "id": "uc7eKo9TkidD" + }, + "source": [ + "from IPython.display import Markdown, display\n", + "from tabulate import tabulate\n", + "\n", + "\n", + "# borrowed from https://stackoverflow.com/questions/33181846/programmatically-convert-pandas-dataframe-to-markdown-table\n", + "\n", + "def pandas_df_to_markdown_table(df):\n", + " fmt = ['---' for i in range(len(df.columns))]\n", + " df_fmt = pd.DataFrame([fmt], columns=df.columns)\n", + " df_formatted = pd.concat([df_fmt, df])\n", + " return Markdown(df_formatted.to_csv(sep=\"|\", index=False))\n", + "\n", + "def df_to_markdown(df, y_index=False):\n", + " blob = tabulate(df, headers='keys', tablefmt='pipe')\n", + " if not y_index:\n", + " return '\\n'.join(['| {}'.format(row.split('|', 2)[-1]) for row in blob.split('\\n')])\n", + " return blob" + ], + "execution_count": 6, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "id": "Y0QVAGKqzWX6" + }, + "source": [ + "mkdt = pandas_df_to_markdown_table(chapter_word_counts)\n", + "\n", + "with open('Chapter_word_counts.md', 'w') as m:\n", + " m.write(str(mkdt.data))" + ], + "execution_count": 7, + "outputs": [] + }, + { + "cell_type": "code", + "metadata": { + "colab": { + "base_uri": "https://localhost:8080/" + }, + "id": "_gGsbGDckIrC", + "outputId": "8d4bbec6-aa6e-465b-fec7-4251f7f4cecf" + }, + "source": [ + "total_count_translatable = chapter_word_counts['Word Count'].sum()\n", + "total_count_translatable" + ], + "execution_count": 8, + "outputs": [ + { + "output_type": "execute_result", + "data": { + "text/plain": [ + "89069" + ] + }, + "metadata": { + "tags": [] + }, + "execution_count": 8 + } + ] + } + ] +} \ No newline at end of file From 238d5b396db0b5753896f95d5e619813844e64b3 Mon Sep 17 00:00:00 2001 From: Ian Culp <57159226+icculp@users.noreply.github.com> Date: Wed, 16 Jun 2021 22:17:13 -0500 Subject: [PATCH 06/12] Add files via upload --- Chapter_word_counts.md | 104 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 104 insertions(+) create mode 100644 Chapter_word_counts.md diff --git a/Chapter_word_counts.md b/Chapter_word_counts.md new file mode 100644 index 0000000..ba0c304 --- /dev/null +++ b/Chapter_word_counts.md @@ -0,0 +1,104 @@ +Chapter|Word Count +---|--- +01_0_Introduction.md|1144 +01_1_Introducing_Bitcoin.md|2735 +02_0_Setting_Up_a_Bitcoin-Core_VPS.md|226 +02_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md|2746 +02_2_Setting_Up_Bitcoin_Core_Other.md|254 +03_0_Understanding_Your_Bitcoin_Setup.md|248 +03_1_Verifying_Your_Bitcoin_Setup.md|773 +03_2_Knowing_Your_Bitcoin_Setup.md|517 +03_3_Setting_Up_Your_Wallet.md|1699 +03_3__Interlude_Using_Command-Line_Variables.md|347 +03_4_Receiving_a_Transaction.md|1479 +03_5_Understanding_the_Descriptor.md|1349 +04_0_Sending_Bitcoin_Transactions.md|176 +04_1_Sending_Coins_The_Easy_Way.md|1195 +04_2_Creating_a_Raw_Transaction.md|1720 +04_2__Interlude_Using_JQ.md|1956 +04_3_Creating_a_Raw_Transaction_with_Named_Arguments.md|413 +04_4_Sending_Coins_with_a_Raw_Transaction.md|1024 +04_4__Interlude_Using_Curl.md|1643 +04_5_Sending_Coins_with_Automated_Raw_Transactions.md|614 +04_6_Creating_a_Segwit_Transaction.md|1172 +05_0_Controlling_Bitcoin_Transactions.md|149 +05_1_Watching_for_Stuck_Transactions.md|595 +05_2_Resending_a_Transaction_with_RBF.md|1372 +05_3_Funding_a_Transaction_with_CPFP.md|827 +06_0_Expanding_Bitcoin_Transactions_Multisigs.md|155 +06_1_Sending_a_Transaction_to_a_Multisig.md|1764 +06_2_Spending_a_Transaction_to_a_Multisig.md|1079 +06_3_Sending_an_Automated_Multisig.md|613 +07_0_Expanding_Bitcoin_Transactions_PSBTs.md|169 +07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md|1470 +07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md|1393 +07_3_Integrating_with_Hardware_Wallets.md|2150 +08_0_Expanding_Bitcoin_Transactions_Other.md|139 +08_1_Sending_a_Transaction_with_a_Locktime.md|1483 +08_2_Sending_a_Transaction_with_Data.md|580 +09_0_Introducing_Bitcoin_Scripts.md|196 +09_1_Understanding_the_Foundation_of_Transactions.md|989 +09_2_Running_a_Bitcoin_Script.md|863 +09_3_Testing_a_Bitcoin_Script.md|1000 +09_4_Scripting_a_P2PKH.md|838 +09_5_Scripting_a_P2WPKH.md|845 +10_0_Embedding_Bitcoin_Scripts_in_P2SH_Transactions.md|170 +10_1_Understanding_the_Foundation_of_P2SH.md|1164 +10_2_Building_the_Structure_of_P2SH.md|1284 +10_3_Running_a_Bitcoin_Script_with_P2SH.md|323 +10_4_Scripting_a_Multisig.md|1016 +10_5_Scripting_a_Segwit_Script.md|750 +10_6_Spending_a_P2SH_Transaction.md|384 +11_0_Empowering_Timelock_with_Bitcoin_Scripts.md|108 +11_1_Understanding_Timelock_Options.md|557 +11_2_Using_CLTV_in_Scripts.md|1197 +11_3_Using_CSV_in_Scripts.md|1470 +12_0_Expanding_Bitcoin_Scripts.md|99 +12_1_Using_Script_Conditionals.md|1120 +12_2_Using_Other_Script_Commands.md|407 +13_0_Designing_Real_Bitcoin_Scripts.md|116 +13_1_Writing_Puzzle_Scripts.md|998 +13_2_Writing_Complex_Multisig_Scripts.md|996 +13_3_Empowering_Bitcoin_with_Scripts.md|1467 +14_0_Using_Tor.md|116 +14_1_Verifying_Your_Tor_Setup.md|1568 +14_2_Changing_Your_Bitcoin_Hidden_Services.md|434 +14_3_Adding_SSH_Hidden_Services.md|330 +15_0_Talking_to_Bitcoind.md|254 +15_1_Accessing_Bitcoind_with_C.md|1238 +15_2_Programming_Bitcoind_with_C.md|1427 +15_3_Receiving_Bitcoind_Notifications_with_C.md|650 +16_0_Programming_with_Libwally.md|333 +16_1_Setting_Up_Libwally.md|559 +16_2_Using_BIP39_in_Libwally.md|939 +16_3_Using_BIP32_in_Libwally.md|959 +16_4_Using_PSBTs_in_Libwally.md|989 +16_5_Using_Scripts_in_Libwally.md|785 +16_6_Using_Other_Functions_in_Libwally.md|655 +16_7_Integrating_Libwally_and_Bitcoin-CLI.md|1380 +17_0_Talking_to_Bitcoind_Other.md|286 +17_1_Accessing_Bitcoind_with_Go.md|547 +17_2_Accessing_Bitcoind_with_Java.md|821 +17_3_Accessing_Bitcoind_with_NodeJS.md|393 +17_4_Accessing_Bitcoind_with_Python.md|1158 +17_5_Accessing_Bitcoind_with_Rust.md|829 +17_6_Accessing_Bitcoind_with_Swift.md|1503 +18_0_Understanding_Your_Lightning_Setup.md|192 +18_1_Verifying_Your_Lightning_Setup.md|1294 +18_2_Knowing_Your_lightning_Setup.md|399 +18_2__Interlude_Accessing_a_Second_Lightning_Node.md|886 +18_3_Setting_Up_a_Channel.md|1173 +19_0_Using_Lightning.md|146 +19_1_Generate_a_Payment_Request.md|968 +19_2_Paying_a_Invoice.md|604 +19_3_Closing_a_Channel.md|848 +19_4_Lightning_Network_Review.md|626 +A0_Appendices.md|112 +A1_0_Understanding_Bitcoin_Standup.md|420 +A2_0_Compiling_Bitcoin_from_Source.md|412 +A3_0_Using_Bitcoin_Regtest.md|980 +CLA.md|495 +CONTRIBUTING.md|529 +LICENSE-CC-BY-4.0.md|2716 +README.md|1705 +TRANSLATING.md|686 From c5306f6885a165513f1f0b5381d3c19db609ca1e Mon Sep 17 00:00:00 2001 From: Ian Culp <57159226+icculp@users.noreply.github.com> Date: Wed, 16 Jun 2021 22:39:48 -0500 Subject: [PATCH 07/12] Adding total to last row --- Chapter_word_counts.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/Chapter_word_counts.md b/Chapter_word_counts.md index ba0c304..5f2bf3a 100644 --- a/Chapter_word_counts.md +++ b/Chapter_word_counts.md @@ -1,3 +1,4 @@ +## Translatable word counts by chapter Chapter|Word Count ---|--- 01_0_Introduction.md|1144 @@ -102,3 +103,4 @@ CONTRIBUTING.md|529 LICENSE-CC-BY-4.0.md|2716 README.md|1705 TRANSLATING.md|686 +TOTAL|89069 From 56ff02ee758ef791e3e5b9518ae567c116f456dd Mon Sep 17 00:00:00 2001 From: Ian Culp <57159226+icculp@users.noreply.github.com> Date: Wed, 16 Jun 2021 22:41:11 -0500 Subject: [PATCH 08/12] Update Chapter_word_counts.md --- Chapter_word_counts.md | 3 +++ 1 file changed, 3 insertions(+) diff --git a/Chapter_word_counts.md b/Chapter_word_counts.md index 5f2bf3a..4945dd2 100644 --- a/Chapter_word_counts.md +++ b/Chapter_word_counts.md @@ -1,4 +1,7 @@ ## Translatable word counts by chapter + +Ignores code blocks and other non-translateable characters + Chapter|Word Count ---|--- 01_0_Introduction.md|1144 From d33808e68ca8f89bda059c689740ee653e011c63 Mon Sep 17 00:00:00 2001 From: Ian Culp <57159226+icculp@users.noreply.github.com> Date: Wed, 16 Jun 2021 22:47:31 -0500 Subject: [PATCH 09/12] Delete word_count_old.ipynb --- word_count_old.ipynb | 265 ------------------------------------------- 1 file changed, 265 deletions(-) delete mode 100644 word_count_old.ipynb diff --git a/word_count_old.ipynb b/word_count_old.ipynb deleted file mode 100644 index 62bd3e6..0000000 --- a/word_count_old.ipynb +++ /dev/null @@ -1,265 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "name": "Untitled25.ipynb", - "provenance": [], - "authorship_tag": "ABX9TyMioTaWOtZ3dcIebltCT4IN", - "include_colab_link": true - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - } - }, - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "kT4wyWuy2szs" - }, - "source": [ - "import os\n", - "import pandas as pd" - ], - "execution_count": 1, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "9J62Uh4H2Y9g", - "outputId": "0ac3147d-fdb4-4b9c-d96b-4da334730a93" - }, - "source": [ - "!git clone https://github.com/icculp/Learning-Bitcoin-from-the-Command-Line.git" - ], - "execution_count": 2, - "outputs": [ - { - "output_type": "stream", - "text": [ - "Cloning into 'Learning-Bitcoin-from-the-Command-Line'...\n", - "remote: Enumerating objects: 6637, done.\u001b[K\n", - "remote: Counting objects: 100% (241/241), done.\u001b[K\n", - "remote: Compressing objects: 100% (199/199), done.\u001b[K\n", - "remote: Total 6637 (delta 110), reused 82 (delta 42), pack-reused 6396\u001b[K\n", - "Receiving objects: 100% (6637/6637), 7.53 MiB | 18.46 MiB/s, done.\n", - "Resolving deltas: 100% (4069/4069), done.\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "k_g4-Fvn2yPy" - }, - "source": [ - "def count_words():\n", - " \"\"\" Counts words ignoring code blocks and digits \"\"\"\n", - " columns=['Chapter', 'Word Count']\n", - " counts = []\n", - " repo_path = '/content/Learning-Bitcoin-from-the-Command-Line/'\n", - " for chapter in os.listdir(repo_path):\n", - " if not chapter.endswith('.md'):\n", - " continue\n", - " count = 0\n", - " flag = 0 # ignores words between ``` code markdown\n", - " with open(repo_path + chapter) as ch:\n", - " for line in ch.readlines():\n", - " if flag:\n", - " if '```' in line:\n", - " flag = 0\n", - " continue\n", - " continue\n", - " if '```' in line:\n", - " flag = 1\n", - " continue\n", - " for word in line.split():\n", - " if any(ch.isdigit() for ch in word):\n", - " continue\n", - " count += 1\n", - " counts.append((chapter, count))\n", - " # print(chapter, count)\n", - " return pd.DataFrame(counts, columns=columns)" - ], - "execution_count": 3, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "2-pkEaYF3Uxm" - }, - "source": [ - "chapter_word_counts = count_words()\n", - "chapter_word_counts.sort_values(by=['Chapter'], inplace=True)" - ], - "execution_count": 4, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 631 - }, - "id": "IPkG4oQJ6f1e", - "outputId": "eea2f4b6-c3d3-48b5-dc62-97885c18d48d" - }, - "source": [ - "from google.colab import data_table\n", - "data_table.DataTable(chapter_word_counts, include_index=False)" - ], - "execution_count": 5, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "application/vnd.google.colaboratory.module+javascript": "\n import \"https://ssl.gstatic.com/colaboratory/data_table/a6224c040fa35dcf/data_table.js\";\n\n window.createDataTable({\n data: [[\"01_0_Introduction.md\",\n{\n 'v': 1128,\n 'f': \"1128\",\n }],\n [\"01_1_Introducing_Bitcoin.md\",\n{\n 'v': 2784,\n 'f': \"2784\",\n }],\n [\"02_0_Setting_Up_a_Bitcoin-Core_VPS.md\",\n{\n 'v': 221,\n 'f': \"221\",\n }],\n [\"02_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md\",\n{\n 'v': 1937,\n 'f': \"1937\",\n }],\n [\"02_2_Setting_Up_Bitcoin_Core_Other.md\",\n{\n 'v': 245,\n 'f': \"245\",\n }],\n [\"03_0_Understanding_Your_Bitcoin_Setup.md\",\n{\n 'v': 225,\n 'f': \"225\",\n }],\n [\"03_1_Verifying_Your_Bitcoin_Setup.md\",\n{\n 'v': 801,\n 'f': \"801\",\n }],\n [\"03_2_Knowing_Your_Bitcoin_Setup.md\",\n{\n 'v': 540,\n 'f': \"540\",\n }],\n [\"03_3_Setting_Up_Your_Wallet.md\",\n{\n 'v': 1741,\n 'f': \"1741\",\n }],\n [\"03_3__Interlude_Using_Command-Line_Variables.md\",\n{\n 'v': 354,\n 'f': \"354\",\n }],\n [\"03_4_Receiving_a_Transaction.md\",\n{\n 'v': 1521,\n 'f': \"1521\",\n }],\n [\"03_5_Understanding_the_Descriptor.md\",\n{\n 'v': 1393,\n 'f': \"1393\",\n }],\n [\"04_0_Sending_Bitcoin_Transactions.md\",\n{\n 'v': 153,\n 'f': \"153\",\n }],\n [\"04_1_Sending_Coins_The_Easy_Way.md\",\n{\n 'v': 1087,\n 'f': \"1087\",\n }],\n [\"04_2_Creating_a_Raw_Transaction.md\",\n{\n 'v': 1840,\n 'f': \"1840\",\n }],\n [\"04_2__Interlude_Using_JQ.md\",\n{\n 'v': 2034,\n 'f': \"2034\",\n }],\n [\"04_3_Creating_a_Raw_Transaction_with_Named_Arguments.md\",\n{\n 'v': 428,\n 'f': \"428\",\n }],\n [\"04_4_Sending_Coins_with_a_Raw_Transaction.md\",\n{\n 'v': 1011,\n 'f': \"1011\",\n }],\n [\"04_4__Interlude_Using_Curl.md\",\n{\n 'v': 1247,\n 'f': \"1247\",\n }],\n [\"04_5_Sending_Coins_with_Automated_Raw_Transactions.md\",\n{\n 'v': 608,\n 'f': \"608\",\n }],\n [\"04_6_Creating_a_Segwit_Transaction.md\",\n{\n 'v': 1203,\n 'f': \"1203\",\n }],\n [\"05_0_Controlling_Bitcoin_Transactions.md\",\n{\n 'v': 144,\n 'f': \"144\",\n }],\n [\"05_1_Watching_for_Stuck_Transactions.md\",\n{\n 'v': 588,\n 'f': \"588\",\n }],\n [\"05_2_Resending_a_Transaction_with_RBF.md\",\n{\n 'v': 1412,\n 'f': \"1412\",\n }],\n [\"05_3_Funding_a_Transaction_with_CPFP.md\",\n{\n 'v': 846,\n 'f': \"846\",\n }],\n [\"06_0_Expanding_Bitcoin_Transactions_Multisigs.md\",\n{\n 'v': 148,\n 'f': \"148\",\n }],\n [\"06_1_Sending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1810,\n 'f': \"1810\",\n }],\n [\"06_2_Spending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1131,\n 'f': \"1131\",\n }],\n [\"06_3_Sending_an_Automated_Multisig.md\",\n{\n 'v': 625,\n 'f': \"625\",\n }],\n [\"07_0_Expanding_Bitcoin_Transactions_PSBTs.md\",\n{\n 'v': 163,\n 'f': \"163\",\n }],\n [\"07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1512,\n 'f': \"1512\",\n }],\n [\"07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1383,\n 'f': \"1383\",\n }],\n [\"07_3_Integrating_with_Hardware_Wallets.md\",\n{\n 'v': 2183,\n 'f': \"2183\",\n }],\n [\"08_0_Expanding_Bitcoin_Transactions_Other.md\",\n{\n 'v': 131,\n 'f': \"131\",\n }],\n [\"08_1_Sending_a_Transaction_with_a_Locktime.md\",\n{\n 'v': 1508,\n 'f': \"1508\",\n }],\n [\"08_2_Sending_a_Transaction_with_Data.md\",\n{\n 'v': 596,\n 'f': \"596\",\n }],\n [\"09_0_Introducing_Bitcoin_Scripts.md\",\n{\n 'v': 187,\n 'f': \"187\",\n }],\n [\"09_1_Understanding_the_Foundation_of_Transactions.md\",\n{\n 'v': 993,\n 'f': \"993\",\n }],\n [\"09_2_Running_a_Bitcoin_Script.md\",\n{\n 'v': 887,\n 'f': \"887\",\n }],\n [\"09_3_Testing_a_Bitcoin_Script.md\",\n{\n 'v': 1023,\n 'f': \"1023\",\n }],\n [\"09_4_Scripting_a_P2PKH.md\",\n{\n 'v': 889,\n 'f': \"889\",\n }],\n [\"09_5_Scripting_a_P2WPKH.md\",\n{\n 'v': 881,\n 'f': \"881\",\n }],\n [\"10_0_Embedding_Bitcoin_Scripts_in_P2SH_Transactions.md\",\n{\n 'v': 152,\n 'f': \"152\",\n }],\n [\"10_1_Understanding_the_Foundation_of_P2SH.md\",\n{\n 'v': 1179,\n 'f': \"1179\",\n }],\n [\"10_2_Building_the_Structure_of_P2SH.md\",\n{\n 'v': 1318,\n 'f': \"1318\",\n }],\n [\"10_3_Running_a_Bitcoin_Script_with_P2SH.md\",\n{\n 'v': 340,\n 'f': \"340\",\n }],\n [\"10_4_Scripting_a_Multisig.md\",\n{\n 'v': 1043,\n 'f': \"1043\",\n }],\n [\"10_5_Scripting_a_Segwit_Script.md\",\n{\n 'v': 751,\n 'f': \"751\",\n }],\n [\"10_6_Spending_a_P2SH_Transaction.md\",\n{\n 'v': 393,\n 'f': \"393\",\n }],\n [\"11_0_Empowering_Timelock_with_Bitcoin_Scripts.md\",\n{\n 'v': 99,\n 'f': \"99\",\n }],\n [\"11_1_Understanding_Timelock_Options.md\",\n{\n 'v': 571,\n 'f': \"571\",\n }],\n [\"11_2_Using_CLTV_in_Scripts.md\",\n{\n 'v': 1241,\n 'f': \"1241\",\n }],\n [\"11_3_Using_CSV_in_Scripts.md\",\n{\n 'v': 1544,\n 'f': \"1544\",\n }],\n [\"12_0_Expanding_Bitcoin_Scripts.md\",\n{\n 'v': 99,\n 'f': \"99\",\n }],\n [\"12_1_Using_Script_Conditionals.md\",\n{\n 'v': 1216,\n 'f': \"1216\",\n }],\n [\"12_2_Using_Other_Script_Commands.md\",\n{\n 'v': 483,\n 'f': \"483\",\n }],\n [\"13_0_Designing_Real_Bitcoin_Scripts.md\",\n{\n 'v': 112,\n 'f': \"112\",\n }],\n [\"13_1_Writing_Puzzle_Scripts.md\",\n{\n 'v': 1032,\n 'f': \"1032\",\n }],\n [\"13_2_Writing_Complex_Multisig_Scripts.md\",\n{\n 'v': 1031,\n 'f': \"1031\",\n }],\n [\"13_3_Empowering_Bitcoin_with_Scripts.md\",\n{\n 'v': 1493,\n 'f': \"1493\",\n }],\n [\"14_0_Using_Tor.md\",\n{\n 'v': 110,\n 'f': \"110\",\n }],\n [\"14_1_Verifying_Your_Tor_Setup.md\",\n{\n 'v': 1632,\n 'f': \"1632\",\n }],\n [\"14_2_Changing_Your_Bitcoin_Hidden_Services.md\",\n{\n 'v': 460,\n 'f': \"460\",\n }],\n [\"14_3_Adding_SSH_Hidden_Services.md\",\n{\n 'v': 339,\n 'f': \"339\",\n }],\n [\"15_0_Talking_to_Bitcoind.md\",\n{\n 'v': 251,\n 'f': \"251\",\n }],\n [\"15_1_Accessing_Bitcoind_with_C.md\",\n{\n 'v': 1315,\n 'f': \"1315\",\n }],\n [\"15_2_Programming_Bitcoind_with_C.md\",\n{\n 'v': 1484,\n 'f': \"1484\",\n }],\n [\"15_3_Receiving_Bitcoind_Notifications_with_C.md\",\n{\n 'v': 669,\n 'f': \"669\",\n }],\n [\"16_0_Programming_with_Libwally.md\",\n{\n 'v': 317,\n 'f': \"317\",\n }],\n [\"16_1_Setting_Up_Libwally.md\",\n{\n 'v': 583,\n 'f': \"583\",\n }],\n [\"16_2_Using_BIP39_in_Libwally.md\",\n{\n 'v': 958,\n 'f': \"958\",\n }],\n [\"16_3_Using_BIP32_in_Libwally.md\",\n{\n 'v': 978,\n 'f': \"978\",\n }],\n [\"16_4_Using_PSBTs_in_Libwally.md\",\n{\n 'v': 1005,\n 'f': \"1005\",\n }],\n [\"16_5_Using_Scripts_in_Libwally.md\",\n{\n 'v': 789,\n 'f': \"789\",\n }],\n [\"16_6_Using_Other_Functions_in_Libwally.md\",\n{\n 'v': 746,\n 'f': \"746\",\n }],\n [\"16_7_Integrating_Libwally_and_Bitcoin-CLI.md\",\n{\n 'v': 1401,\n 'f': \"1401\",\n }],\n [\"17_0_Talking_to_Bitcoind_Other.md\",\n{\n 'v': 272,\n 'f': \"272\",\n }],\n [\"17_1_Accessing_Bitcoind_with_Go.md\",\n{\n 'v': 697,\n 'f': \"697\",\n }],\n [\"17_2_Accessing_Bitcoind_with_Java.md\",\n{\n 'v': 782,\n 'f': \"782\",\n }],\n [\"17_3_Accessing_Bitcoind_with_NodeJS.md\",\n{\n 'v': 476,\n 'f': \"476\",\n }],\n [\"17_4_Accessing_Bitcoind_with_Python.md\",\n{\n 'v': 1246,\n 'f': \"1246\",\n }],\n [\"17_5_Accessing_Bitcoind_with_Rust.md\",\n{\n 'v': 905,\n 'f': \"905\",\n }],\n [\"17_6_Accessing_Bitcoind_with_Swift.md\",\n{\n 'v': 1588,\n 'f': \"1588\",\n }],\n [\"18_0_Understanding_Your_Lightning_Setup.md\",\n{\n 'v': 185,\n 'f': \"185\",\n }],\n [\"18_1_Verifying_Your_Lightning_Setup.md\",\n{\n 'v': 1347,\n 'f': \"1347\",\n }],\n [\"18_2_Knowing_Your_lightning_Setup.md\",\n{\n 'v': 421,\n 'f': \"421\",\n }],\n [\"18_2__Interlude_Accessing_a_Second_Lightning_Node.md\",\n{\n 'v': 882,\n 'f': \"882\",\n }],\n [\"18_3_Setting_Up_a_Channel.md\",\n{\n 'v': 1219,\n 'f': \"1219\",\n }],\n [\"19_0_Using_Lightning.md\",\n{\n 'v': 145,\n 'f': \"145\",\n }],\n [\"19_1_Generate_a_Payment_Request.md\",\n{\n 'v': 995,\n 'f': \"995\",\n }],\n [\"19_2_Paying_a_Invoice.md\",\n{\n 'v': 614,\n 'f': \"614\",\n }],\n [\"19_3_Closing_a_Channel.md\",\n{\n 'v': 866,\n 'f': \"866\",\n }],\n [\"19_4_Lightning_Network_Review.md\",\n{\n 'v': 677,\n 'f': \"677\",\n }],\n [\"A0_Appendices.md\",\n{\n 'v': 110,\n 'f': \"110\",\n }],\n [\"A1_0_Understanding_Bitcoin_Standup.md\",\n{\n 'v': 412,\n 'f': \"412\",\n }],\n [\"A2_0_Compiling_Bitcoin_from_Source.md\",\n{\n 'v': 414,\n 'f': \"414\",\n }],\n [\"A3_0_Using_Bitcoin_Regtest.md\",\n{\n 'v': 995,\n 'f': \"995\",\n }],\n [\"CLA.md\",\n{\n 'v': 512,\n 'f': \"512\",\n }],\n [\"CONTRIBUTING.md\",\n{\n 'v': 555,\n 'f': \"555\",\n }],\n [\"LICENSE-CC-BY-4.0.md\",\n{\n 'v': 2734,\n 'f': \"2734\",\n }],\n [\"README.md\",\n{\n 'v': 1366,\n 'f': \"1366\",\n }],\n [\"TODO-30.md\",\n{\n 'v': 122,\n 'f': \"122\",\n }],\n [\"TODO.md\",\n{\n 'v': 734,\n 'f': \"734\",\n }]],\n columns: [[\"string\", \"Chapter\"], [\"number\", \"Word Count\"]],\n columnOptions: [],\n rowsPerPage: 25,\n helpUrl: \"https://colab.research.google.com/notebooks/data_table.ipynb\",\n suppressOutputScrolling: true,\n minimumWidth: undefined,\n });\n ", - "text/plain": [ - "" - ], - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
ChapterWord Count
4401_0_Introduction.md1128
6901_1_Introducing_Bitcoin.md2784
9202_0_Setting_Up_a_Bitcoin-Core_VPS.md221
3302_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackS...1937
6602_2_Setting_Up_Bitcoin_Core_Other.md245
.........
45CONTRIBUTING.md555
34LICENSE-CC-BY-4.0.md2734
0README.md1366
52TODO-30.md122
29TODO.md734
\n", - "

103 rows × 2 columns

\n", - "
" - ] - }, - "metadata": { - "tags": [] - }, - "execution_count": 5 - } - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "4dFD792BBy0S", - "outputId": "3c4dc4ff-ceb3-4ff5-d40d-c606eec83a8c" - }, - "source": [ - "total_count = chapter_word_counts['Word Count'].sum()\n", - "total_count" - ], - "execution_count": 6, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "89946" - ] - }, - "metadata": { - "tags": [] - }, - "execution_count": 6 - } - ] - } - ] -} From 77aa33b5f953df1060ccf439a06e8a18258feaae Mon Sep 17 00:00:00 2001 From: Ian Culp <57159226+icculp@users.noreply.github.com> Date: Wed, 16 Jun 2021 22:48:42 -0500 Subject: [PATCH 10/12] Delete Chapter_word_count.ipynb --- Chapter_word_count.ipynb | 362 --------------------------------------- 1 file changed, 362 deletions(-) delete mode 100644 Chapter_word_count.ipynb diff --git a/Chapter_word_count.ipynb b/Chapter_word_count.ipynb deleted file mode 100644 index 8ce5aff..0000000 --- a/Chapter_word_count.ipynb +++ /dev/null @@ -1,362 +0,0 @@ -{ - "nbformat": 4, - "nbformat_minor": 0, - "metadata": { - "colab": { - "name": "Untitled25.ipynb", - "provenance": [], - "authorship_tag": "ABX9TyNJdlLdL56gLSWYqG177B0A", - "include_colab_link": true - }, - "kernelspec": { - "name": "python3", - "display_name": "Python 3" - }, - "language_info": { - "name": "python" - } - }, - "cells": [ - { - "cell_type": "markdown", - "metadata": { - "id": "view-in-github", - "colab_type": "text" - }, - "source": [ - "\"Open" - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "TQUe8ZZed-Bp" - }, - "source": [ - "Run in colab by clicking the link above to view the results as a paginated table with word counts for each chapter near the bottom of the notebook. Total word count at the very bottom." - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "X7D8JEIgy9fV" - }, - "source": [ - "This notebook counts through the translatable words of each chapter, including chapter links; ignores code blocks, markdown characters, and tokens containing digits." - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "kT4wyWuy2szs" - }, - "source": [ - "import os\n", - "import pandas as pd\n", - "import re" - ], - "execution_count": 1, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "9J62Uh4H2Y9g", - "outputId": "8d2c4675-ddf9-4cd5-8fb2-ee4cae9b034d" - }, - "source": [ - "!git clone https://github.com/icculp/Learning-Bitcoin-from-the-Command-Line.git" - ], - "execution_count": 2, - "outputs": [ - { - "output_type": "stream", - "text": [ - "fatal: destination path 'Learning-Bitcoin-from-the-Command-Line' already exists and is not an empty directory.\n" - ], - "name": "stdout" - } - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "k_g4-Fvn2yPy" - }, - "source": [ - "def count_words():\n", - " \"\"\" Counts words ignoring code blocks and digits\n", - "\n", - " To test for quality:\n", - " lines 14-16 to test a single chapter\n", - " uncomment line 45 to view accepted word tokens\n", - " uncomment line \n", - " \"\"\"\n", - " columns=['Chapter', 'Word Count']\n", - " counts = []\n", - " repo_path = '/content/Learning-Bitcoin-from-the-Command-Line/'\n", - " for chapter in os.listdir(repo_path):\n", - " ''' uncomment lines 8-10 to test a single chapter, replacing ch_name\n", - " with the name you want to test\n", - " '''\n", - " #ch_name = '03_2_Knowing_Your_Bitcoin_Setup.md'\n", - " #if chapter != ch_name:\n", - " # continue\n", - " ignore_list = ['bitcoin.conf-annotated.txt', 'TODO.md', 'TODO-30.md']\n", - " if chapter in ignore_list or\\\n", - " not chapter.endswith('md'): # g\n", - " continue\n", - " count = 0\n", - " flag = 0 # ignores words between code markdown ```\n", - " with open(repo_path + chapter) as ch:\n", - " for line in ch.readlines():\n", - " if flag:\n", - " if '```' in line[:3].replace(' ', ''):\n", - " flag = 0\n", - " continue\n", - " continue\n", - " if '```' in line:\n", - " flag = 1\n", - " continue\n", - " for word in line.split():\n", - " if '.md' in word:\n", - " ch_link_tokens = word.split('_')\n", - " if ']' in word: # indicates trailing link with chapter name; counts last word of trailing link before chapter name\n", - " count += 1\n", - " link_tokens_count = len(ch_link_tokens[2:]) # ignoring chapter numbers in chapter link tokens\n", - " count += link_tokens_count\n", - " # print(word, '[TOK]', link_tokens_count, end='[SEPTOK]')\n", - " continue\n", - " ignore = ['*', '**', '#', '##', '###', '####',\n", - " '-', '—', '>', '`', '/', '&', '|', '~']\n", - " if any(ch.isdigit() for ch in word) or\\\n", - " word in ignore or\\\n", - " '`' in word or\\\n", - " '~/' in word or\\\n", - " '/.' in word or\\\n", - " '|-' in word or\\\n", - " (word[0] == ':' and word[-1] == ':') or\\\n", - " (word[0] == '\"' and word[-1] == '\"'):\n", - " # print(word) # , end='[SEP]') # view rejected tokens\n", - " continue\n", - " # print(word, count) # , end='[SEP]') # view accepted tokens\n", - " count += 1\n", - " counts.append((chapter, count))\n", - " # print(chapter, count)\n", - " return pd.DataFrame(counts, columns=columns)" - ], - "execution_count": 3, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "2-pkEaYF3Uxm" - }, - "source": [ - "chapter_word_counts = count_words()\n", - "chapter_word_counts.sort_values(by=['Chapter'], inplace=True)\n", - "# view accepted or rejected tokens below if line 53 or 51 uncommented in count_words(), respectively" - ], - "execution_count": 4, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/", - "height": 631 - }, - "id": "K73GH7UFmwI5", - "outputId": "d1430339-8b1b-43f3-cdcf-1019948c7b9c" - }, - "source": [ - "from google.colab import data_table\n", - "data_table.DataTable(chapter_word_counts, include_index=False)" - ], - "execution_count": 5, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "application/vnd.google.colaboratory.module+javascript": "\n import \"https://ssl.gstatic.com/colaboratory/data_table/a6224c040fa35dcf/data_table.js\";\n\n window.createDataTable({\n data: [[\"01_0_Introduction.md\",\n{\n 'v': 1144,\n 'f': \"1144\",\n }],\n [\"01_1_Introducing_Bitcoin.md\",\n{\n 'v': 2735,\n 'f': \"2735\",\n }],\n [\"02_0_Setting_Up_a_Bitcoin-Core_VPS.md\",\n{\n 'v': 226,\n 'f': \"226\",\n }],\n [\"02_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md\",\n{\n 'v': 2723,\n 'f': \"2723\",\n }],\n [\"02_2_Setting_Up_Bitcoin_Core_Other.md\",\n{\n 'v': 254,\n 'f': \"254\",\n }],\n [\"03_0_Understanding_Your_Bitcoin_Setup.md\",\n{\n 'v': 248,\n 'f': \"248\",\n }],\n [\"03_1_Verifying_Your_Bitcoin_Setup.md\",\n{\n 'v': 773,\n 'f': \"773\",\n }],\n [\"03_2_Knowing_Your_Bitcoin_Setup.md\",\n{\n 'v': 517,\n 'f': \"517\",\n }],\n [\"03_3_Setting_Up_Your_Wallet.md\",\n{\n 'v': 1699,\n 'f': \"1699\",\n }],\n [\"03_3__Interlude_Using_Command-Line_Variables.md\",\n{\n 'v': 347,\n 'f': \"347\",\n }],\n [\"03_4_Receiving_a_Transaction.md\",\n{\n 'v': 1479,\n 'f': \"1479\",\n }],\n [\"03_5_Understanding_the_Descriptor.md\",\n{\n 'v': 1349,\n 'f': \"1349\",\n }],\n [\"04_0_Sending_Bitcoin_Transactions.md\",\n{\n 'v': 176,\n 'f': \"176\",\n }],\n [\"04_1_Sending_Coins_The_Easy_Way.md\",\n{\n 'v': 1068,\n 'f': \"1068\",\n }],\n [\"04_2_Creating_a_Raw_Transaction.md\",\n{\n 'v': 1720,\n 'f': \"1720\",\n }],\n [\"04_2__Interlude_Using_JQ.md\",\n{\n 'v': 1956,\n 'f': \"1956\",\n }],\n [\"04_3_Creating_a_Raw_Transaction_with_Named_Arguments.md\",\n{\n 'v': 413,\n 'f': \"413\",\n }],\n [\"04_4_Sending_Coins_with_a_Raw_Transaction.md\",\n{\n 'v': 1024,\n 'f': \"1024\",\n }],\n [\"04_4__Interlude_Using_Curl.md\",\n{\n 'v': 1643,\n 'f': \"1643\",\n }],\n [\"04_5_Sending_Coins_with_Automated_Raw_Transactions.md\",\n{\n 'v': 614,\n 'f': \"614\",\n }],\n [\"04_6_Creating_a_Segwit_Transaction.md\",\n{\n 'v': 1172,\n 'f': \"1172\",\n }],\n [\"05_0_Controlling_Bitcoin_Transactions.md\",\n{\n 'v': 149,\n 'f': \"149\",\n }],\n [\"05_1_Watching_for_Stuck_Transactions.md\",\n{\n 'v': 595,\n 'f': \"595\",\n }],\n [\"05_2_Resending_a_Transaction_with_RBF.md\",\n{\n 'v': 1372,\n 'f': \"1372\",\n }],\n [\"05_3_Funding_a_Transaction_with_CPFP.md\",\n{\n 'v': 827,\n 'f': \"827\",\n }],\n [\"06_0_Expanding_Bitcoin_Transactions_Multisigs.md\",\n{\n 'v': 155,\n 'f': \"155\",\n }],\n [\"06_1_Sending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1764,\n 'f': \"1764\",\n }],\n [\"06_2_Spending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1079,\n 'f': \"1079\",\n }],\n [\"06_3_Sending_an_Automated_Multisig.md\",\n{\n 'v': 613,\n 'f': \"613\",\n }],\n [\"07_0_Expanding_Bitcoin_Transactions_PSBTs.md\",\n{\n 'v': 169,\n 'f': \"169\",\n }],\n [\"07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1470,\n 'f': \"1470\",\n }],\n [\"07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1393,\n 'f': \"1393\",\n }],\n [\"07_3_Integrating_with_Hardware_Wallets.md\",\n{\n 'v': 2150,\n 'f': \"2150\",\n }],\n [\"08_0_Expanding_Bitcoin_Transactions_Other.md\",\n{\n 'v': 139,\n 'f': \"139\",\n }],\n [\"08_1_Sending_a_Transaction_with_a_Locktime.md\",\n{\n 'v': 1483,\n 'f': \"1483\",\n }],\n [\"08_2_Sending_a_Transaction_with_Data.md\",\n{\n 'v': 580,\n 'f': \"580\",\n }],\n [\"09_0_Introducing_Bitcoin_Scripts.md\",\n{\n 'v': 196,\n 'f': \"196\",\n }],\n [\"09_1_Understanding_the_Foundation_of_Transactions.md\",\n{\n 'v': 989,\n 'f': \"989\",\n }],\n [\"09_2_Running_a_Bitcoin_Script.md\",\n{\n 'v': 863,\n 'f': \"863\",\n }],\n [\"09_3_Testing_a_Bitcoin_Script.md\",\n{\n 'v': 1000,\n 'f': \"1000\",\n }],\n [\"09_4_Scripting_a_P2PKH.md\",\n{\n 'v': 838,\n 'f': \"838\",\n }],\n [\"09_5_Scripting_a_P2WPKH.md\",\n{\n 'v': 845,\n 'f': \"845\",\n }],\n [\"10_0_Embedding_Bitcoin_Scripts_in_P2SH_Transactions.md\",\n{\n 'v': 170,\n 'f': \"170\",\n }],\n [\"10_1_Understanding_the_Foundation_of_P2SH.md\",\n{\n 'v': 1164,\n 'f': \"1164\",\n }],\n [\"10_2_Building_the_Structure_of_P2SH.md\",\n{\n 'v': 1284,\n 'f': \"1284\",\n }],\n [\"10_3_Running_a_Bitcoin_Script_with_P2SH.md\",\n{\n 'v': 323,\n 'f': \"323\",\n }],\n [\"10_4_Scripting_a_Multisig.md\",\n{\n 'v': 1016,\n 'f': \"1016\",\n }],\n [\"10_5_Scripting_a_Segwit_Script.md\",\n{\n 'v': 750,\n 'f': \"750\",\n }],\n [\"10_6_Spending_a_P2SH_Transaction.md\",\n{\n 'v': 384,\n 'f': \"384\",\n }],\n [\"11_0_Empowering_Timelock_with_Bitcoin_Scripts.md\",\n{\n 'v': 108,\n 'f': \"108\",\n }],\n [\"11_1_Understanding_Timelock_Options.md\",\n{\n 'v': 557,\n 'f': \"557\",\n }],\n [\"11_2_Using_CLTV_in_Scripts.md\",\n{\n 'v': 1197,\n 'f': \"1197\",\n }],\n [\"11_3_Using_CSV_in_Scripts.md\",\n{\n 'v': 1470,\n 'f': \"1470\",\n }],\n [\"12_0_Expanding_Bitcoin_Scripts.md\",\n{\n 'v': 99,\n 'f': \"99\",\n }],\n [\"12_1_Using_Script_Conditionals.md\",\n{\n 'v': 1120,\n 'f': \"1120\",\n }],\n [\"12_2_Using_Other_Script_Commands.md\",\n{\n 'v': 407,\n 'f': \"407\",\n }],\n [\"13_0_Designing_Real_Bitcoin_Scripts.md\",\n{\n 'v': 116,\n 'f': \"116\",\n }],\n [\"13_1_Writing_Puzzle_Scripts.md\",\n{\n 'v': 998,\n 'f': \"998\",\n }],\n [\"13_2_Writing_Complex_Multisig_Scripts.md\",\n{\n 'v': 996,\n 'f': \"996\",\n }],\n [\"13_3_Empowering_Bitcoin_with_Scripts.md\",\n{\n 'v': 1467,\n 'f': \"1467\",\n }],\n [\"14_0_Using_Tor.md\",\n{\n 'v': 116,\n 'f': \"116\",\n }],\n [\"14_1_Verifying_Your_Tor_Setup.md\",\n{\n 'v': 1568,\n 'f': \"1568\",\n }],\n [\"14_2_Changing_Your_Bitcoin_Hidden_Services.md\",\n{\n 'v': 434,\n 'f': \"434\",\n }],\n [\"14_3_Adding_SSH_Hidden_Services.md\",\n{\n 'v': 330,\n 'f': \"330\",\n }],\n [\"15_0_Talking_to_Bitcoind.md\",\n{\n 'v': 254,\n 'f': \"254\",\n }],\n [\"15_1_Accessing_Bitcoind_with_C.md\",\n{\n 'v': 1238,\n 'f': \"1238\",\n }],\n [\"15_2_Programming_Bitcoind_with_C.md\",\n{\n 'v': 1427,\n 'f': \"1427\",\n }],\n [\"15_3_Receiving_Bitcoind_Notifications_with_C.md\",\n{\n 'v': 650,\n 'f': \"650\",\n }],\n [\"16_0_Programming_with_Libwally.md\",\n{\n 'v': 333,\n 'f': \"333\",\n }],\n [\"16_1_Setting_Up_Libwally.md\",\n{\n 'v': 559,\n 'f': \"559\",\n }],\n [\"16_2_Using_BIP39_in_Libwally.md\",\n{\n 'v': 939,\n 'f': \"939\",\n }],\n [\"16_3_Using_BIP32_in_Libwally.md\",\n{\n 'v': 959,\n 'f': \"959\",\n }],\n [\"16_4_Using_PSBTs_in_Libwally.md\",\n{\n 'v': 989,\n 'f': \"989\",\n }],\n [\"16_5_Using_Scripts_in_Libwally.md\",\n{\n 'v': 785,\n 'f': \"785\",\n }],\n [\"16_6_Using_Other_Functions_in_Libwally.md\",\n{\n 'v': 655,\n 'f': \"655\",\n }],\n [\"16_7_Integrating_Libwally_and_Bitcoin-CLI.md\",\n{\n 'v': 1380,\n 'f': \"1380\",\n }],\n [\"17_0_Talking_to_Bitcoind_Other.md\",\n{\n 'v': 286,\n 'f': \"286\",\n }],\n [\"17_1_Accessing_Bitcoind_with_Go.md\",\n{\n 'v': 547,\n 'f': \"547\",\n }],\n [\"17_2_Accessing_Bitcoind_with_Java.md\",\n{\n 'v': 821,\n 'f': \"821\",\n }],\n [\"17_3_Accessing_Bitcoind_with_NodeJS.md\",\n{\n 'v': 393,\n 'f': \"393\",\n }],\n [\"17_4_Accessing_Bitcoind_with_Python.md\",\n{\n 'v': 1158,\n 'f': \"1158\",\n }],\n [\"17_5_Accessing_Bitcoind_with_Rust.md\",\n{\n 'v': 829,\n 'f': \"829\",\n }],\n [\"17_6_Accessing_Bitcoind_with_Swift.md\",\n{\n 'v': 1503,\n 'f': \"1503\",\n }],\n [\"18_0_Understanding_Your_Lightning_Setup.md\",\n{\n 'v': 192,\n 'f': \"192\",\n }],\n [\"18_1_Verifying_Your_Lightning_Setup.md\",\n{\n 'v': 1294,\n 'f': \"1294\",\n }],\n [\"18_2_Knowing_Your_lightning_Setup.md\",\n{\n 'v': 399,\n 'f': \"399\",\n }],\n [\"18_2__Interlude_Accessing_a_Second_Lightning_Node.md\",\n{\n 'v': 886,\n 'f': \"886\",\n }],\n [\"18_3_Setting_Up_a_Channel.md\",\n{\n 'v': 1173,\n 'f': \"1173\",\n }],\n [\"19_0_Using_Lightning.md\",\n{\n 'v': 146,\n 'f': \"146\",\n }],\n [\"19_1_Generate_a_Payment_Request.md\",\n{\n 'v': 968,\n 'f': \"968\",\n }],\n [\"19_2_Paying_a_Invoice.md\",\n{\n 'v': 604,\n 'f': \"604\",\n }],\n [\"19_3_Closing_a_Channel.md\",\n{\n 'v': 848,\n 'f': \"848\",\n }],\n [\"19_4_Lightning_Network_Review.md\",\n{\n 'v': 626,\n 'f': \"626\",\n }],\n [\"A0_Appendices.md\",\n{\n 'v': 112,\n 'f': \"112\",\n }],\n [\"A1_0_Understanding_Bitcoin_Standup.md\",\n{\n 'v': 420,\n 'f': \"420\",\n }],\n [\"A2_0_Compiling_Bitcoin_from_Source.md\",\n{\n 'v': 412,\n 'f': \"412\",\n }],\n [\"A3_0_Using_Bitcoin_Regtest.md\",\n{\n 'v': 980,\n 'f': \"980\",\n }],\n [\"CLA.md\",\n{\n 'v': 495,\n 'f': \"495\",\n }],\n [\"CONTRIBUTING.md\",\n{\n 'v': 529,\n 'f': \"529\",\n }],\n [\"LICENSE-CC-BY-4.0.md\",\n{\n 'v': 2716,\n 'f': \"2716\",\n }],\n [\"README.md\",\n{\n 'v': 1687,\n 'f': \"1687\",\n }]],\n columns: [[\"string\", \"Chapter\"], [\"number\", \"Word Count\"]],\n columnOptions: [],\n rowsPerPage: 25,\n helpUrl: \"https://colab.research.google.com/notebooks/data_table.ipynb\",\n suppressOutputScrolling: true,\n minimumWidth: undefined,\n });\n ", - "text/plain": [ - "" - ], - "text/html": [ - "
\n", - "\n", - "\n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - " \n", - "
ChapterWord Count
7201_0_Introduction.md1144
2101_1_Introducing_Bitcoin.md2735
2002_0_Setting_Up_a_Bitcoin-Core_VPS.md226
9702_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackS...2723
9402_2_Setting_Up_Bitcoin_Core_Other.md254
.........
45A3_0_Using_Bitcoin_Regtest.md980
38CLA.md495
74CONTRIBUTING.md529
53LICENSE-CC-BY-4.0.md2716
2README.md1687
\n", - "

101 rows × 2 columns

\n", - "
" - ] - }, - "metadata": { - "tags": [] - }, - "execution_count": 5 - } - ] - }, - { - "cell_type": "code", - "metadata": { - "colab": { - "base_uri": "https://localhost:8080/" - }, - "id": "_gGsbGDckIrC", - "outputId": "a9811107-2a07-464a-d96a-c6767e5ea7d4" - }, - "source": [ - "total_count = chapter_word_counts['Word Count'].sum()\n", - "total_count" - ], - "execution_count": 6, - "outputs": [ - { - "output_type": "execute_result", - "data": { - "text/plain": [ - "88215" - ] - }, - "metadata": { - "tags": [] - }, - "execution_count": 6 - } - ] - }, - { - "cell_type": "markdown", - "metadata": { - "id": "14kdusmNzcfz" - }, - "source": [ - "To convert the table to a markdown format and save as 'Chapter_word_counts.md', run the cells below" - ] - }, - { - "cell_type": "code", - "metadata": { - "id": "uc7eKo9TkidD" - }, - "source": [ - "from IPython.display import Markdown, display\n", - "from tabulate import tabulate\n", - "\n", - "\n", - "# borrowed from https://stackoverflow.com/questions/33181846/programmatically-convert-pandas-dataframe-to-markdown-table\n", - "\n", - "def pandas_df_to_markdown_table(df):\n", - " fmt = ['---' for i in range(len(df.columns))]\n", - " df_fmt = pd.DataFrame([fmt], columns=df.columns)\n", - " df_formatted = pd.concat([df_fmt, df])\n", - " return Markdown(df_formatted.to_csv(sep=\"|\", index=False))\n", - "\n", - "def df_to_markdown(df, y_index=False):\n", - " blob = tabulate(df, headers='keys', tablefmt='pipe')\n", - " if not y_index:\n", - " return '\\n'.join(['| {}'.format(row.split('|', 2)[-1]) for row in blob.split('\\n')])\n", - " return blob" - ], - "execution_count": 7, - "outputs": [] - }, - { - "cell_type": "code", - "metadata": { - "id": "Y0QVAGKqzWX6" - }, - "source": [ - "mkt = pandas_df_to_markdown_table(chapter_word_counts)\n", - "\n", - "with open('Chapter_word_counts.md', 'w') as m:\n", - " m.write(str(mkt.data))" - ], - "execution_count": 8, - "outputs": [] - } - ] -} \ No newline at end of file From 9916b65adc48317826ff1e82b744327fa497c8de Mon Sep 17 00:00:00 2001 From: Ian Culp <57159226+icculp@users.noreply.github.com> Date: Wed, 16 Jun 2021 23:02:24 -0500 Subject: [PATCH 11/12] Adding total to dataframe --- Chapter_word_counts.ipynb | 71 ++++++++++++++++++++++----------------- 1 file changed, 41 insertions(+), 30 deletions(-) diff --git a/Chapter_word_counts.ipynb b/Chapter_word_counts.ipynb index e404454..0c85721 100644 --- a/Chapter_word_counts.ipynb +++ b/Chapter_word_counts.ipynb @@ -5,7 +5,7 @@ "colab": { "name": "Untitled25.ipynb", "provenance": [], - "authorship_tag": "ABX9TyNHQ/J52I0G+daf1wNCNdAI", + "authorship_tag": "ABX9TyMjw6y4q6XdjW6h80beORDK", "include_colab_link": true }, "kernelspec": { @@ -33,7 +33,7 @@ "id": "X7D8JEIgy9fV" }, "source": [ - "This notebook counts through the translatable words of each chapter, including chapter links; ignores code blocks, markdown characters, and tokens containing digits." + "This notebook counts through the translatable words of each chapter, including chapter links; ignores code blocks, markdown characters, and other non-translatable characters." ] }, { @@ -42,7 +42,7 @@ "id": "TQUe8ZZed-Bp" }, "source": [ - "Run in colab by clicking the link above to view the results as a paginated table with word counts for each chapter near the bottom of the notebook. Total word count at the very bottom." + "Run in colab by clicking the link above to view the results as a paginated table with word counts for each chapter near the bottom of the notebook. Total word count at the very bottom. Markdown friendly table created in Chapter_word_counts.md" ] }, { @@ -64,10 +64,10 @@ "base_uri": "https://localhost:8080/" }, "id": "9J62Uh4H2Y9g", - "outputId": "3295f8b2-5255-4eac-bc78-3da247037c41" + "outputId": "05d36385-659c-4f88-a82c-6dd877efd645" }, "source": [ - "!git clone https://github.com/icculp/Learning-Bitcoin-from-the-Command-Line.git" + "!git clone https://github.com/BlockchainCommons/Learning-Bitcoin-from-the-Command-Line.git" ], "execution_count": 2, "outputs": [ @@ -75,12 +75,12 @@ "output_type": "stream", "text": [ "Cloning into 'Learning-Bitcoin-from-the-Command-Line'...\n", - "remote: Enumerating objects: 6715, done.\u001b[K\n", - "remote: Counting objects: 100% (319/319), done.\u001b[K\n", - "remote: Compressing objects: 100% (193/193), done.\u001b[K\n", - "remote: Total 6715 (delta 157), reused 277 (delta 125), pack-reused 6396\u001b[K\n", - "Receiving objects: 100% (6715/6715), 7.56 MiB | 22.84 MiB/s, done.\n", - "Resolving deltas: 100% (4116/4116), done.\n" + "remote: Enumerating objects: 6705, done.\u001b[K\n", + "remote: Counting objects: 100% (309/309), done.\u001b[K\n", + "remote: Compressing objects: 100% (192/192), done.\u001b[K\n", + "remote: Total 6705 (delta 147), reused 267 (delta 112), pack-reused 6396\u001b[K\n", + "Receiving objects: 100% (6705/6705), 7.55 MiB | 25.61 MiB/s, done.\n", + "Resolving deltas: 100% (4106/4106), done.\n" ], "name": "stdout" } @@ -164,12 +164,24 @@ }, "source": [ "chapter_word_counts = count_words()\n", - "chapter_word_counts.sort_values(by=['Chapter'], inplace=True)\n", "# view accepted or rejected tokens below if line 55 or 53 uncommented in count_words(), respectively" ], "execution_count": 4, "outputs": [] }, + { + "cell_type": "code", + "metadata": { + "id": "Tc9IsNpC-vwR" + }, + "source": [ + "chapter_word_counts.sort_values(by=['Chapter'], inplace=True)\n", + "total_count_translatable = chapter_word_counts['Word Count'].sum()\n", + "chapter_word_counts.loc[len(chapter_word_counts.index)] = ['TOTAL', total_count_translatable] " + ], + "execution_count": 5, + "outputs": [] + }, { "cell_type": "markdown", "metadata": { @@ -187,18 +199,18 @@ "height": 631 }, "id": "K73GH7UFmwI5", - "outputId": "246c0b17-0854-4811-c67f-8081d7950272" + "outputId": "a4361d36-caf3-4bb7-ac6d-4cdc71f49afc" }, "source": [ "from google.colab import data_table\n", "data_table.DataTable(chapter_word_counts, include_index=False)" ], - "execution_count": 5, + "execution_count": 6, "outputs": [ { "output_type": "execute_result", "data": { - "application/vnd.google.colaboratory.module+javascript": "\n import \"https://ssl.gstatic.com/colaboratory/data_table/a6224c040fa35dcf/data_table.js\";\n\n window.createDataTable({\n data: [[\"01_0_Introduction.md\",\n{\n 'v': 1144,\n 'f': \"1144\",\n }],\n [\"01_1_Introducing_Bitcoin.md\",\n{\n 'v': 2735,\n 'f': \"2735\",\n }],\n [\"02_0_Setting_Up_a_Bitcoin-Core_VPS.md\",\n{\n 'v': 226,\n 'f': \"226\",\n }],\n [\"02_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md\",\n{\n 'v': 2746,\n 'f': \"2746\",\n }],\n [\"02_2_Setting_Up_Bitcoin_Core_Other.md\",\n{\n 'v': 254,\n 'f': \"254\",\n }],\n [\"03_0_Understanding_Your_Bitcoin_Setup.md\",\n{\n 'v': 248,\n 'f': \"248\",\n }],\n [\"03_1_Verifying_Your_Bitcoin_Setup.md\",\n{\n 'v': 773,\n 'f': \"773\",\n }],\n [\"03_2_Knowing_Your_Bitcoin_Setup.md\",\n{\n 'v': 517,\n 'f': \"517\",\n }],\n [\"03_3_Setting_Up_Your_Wallet.md\",\n{\n 'v': 1699,\n 'f': \"1699\",\n }],\n [\"03_3__Interlude_Using_Command-Line_Variables.md\",\n{\n 'v': 347,\n 'f': \"347\",\n }],\n [\"03_4_Receiving_a_Transaction.md\",\n{\n 'v': 1479,\n 'f': \"1479\",\n }],\n [\"03_5_Understanding_the_Descriptor.md\",\n{\n 'v': 1349,\n 'f': \"1349\",\n }],\n [\"04_0_Sending_Bitcoin_Transactions.md\",\n{\n 'v': 176,\n 'f': \"176\",\n }],\n [\"04_1_Sending_Coins_The_Easy_Way.md\",\n{\n 'v': 1195,\n 'f': \"1195\",\n }],\n [\"04_2_Creating_a_Raw_Transaction.md\",\n{\n 'v': 1720,\n 'f': \"1720\",\n }],\n [\"04_2__Interlude_Using_JQ.md\",\n{\n 'v': 1956,\n 'f': \"1956\",\n }],\n [\"04_3_Creating_a_Raw_Transaction_with_Named_Arguments.md\",\n{\n 'v': 413,\n 'f': \"413\",\n }],\n [\"04_4_Sending_Coins_with_a_Raw_Transaction.md\",\n{\n 'v': 1024,\n 'f': \"1024\",\n }],\n [\"04_4__Interlude_Using_Curl.md\",\n{\n 'v': 1643,\n 'f': \"1643\",\n }],\n [\"04_5_Sending_Coins_with_Automated_Raw_Transactions.md\",\n{\n 'v': 614,\n 'f': \"614\",\n }],\n [\"04_6_Creating_a_Segwit_Transaction.md\",\n{\n 'v': 1172,\n 'f': \"1172\",\n }],\n [\"05_0_Controlling_Bitcoin_Transactions.md\",\n{\n 'v': 149,\n 'f': \"149\",\n }],\n [\"05_1_Watching_for_Stuck_Transactions.md\",\n{\n 'v': 595,\n 'f': \"595\",\n }],\n [\"05_2_Resending_a_Transaction_with_RBF.md\",\n{\n 'v': 1372,\n 'f': \"1372\",\n }],\n [\"05_3_Funding_a_Transaction_with_CPFP.md\",\n{\n 'v': 827,\n 'f': \"827\",\n }],\n [\"06_0_Expanding_Bitcoin_Transactions_Multisigs.md\",\n{\n 'v': 155,\n 'f': \"155\",\n }],\n [\"06_1_Sending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1764,\n 'f': \"1764\",\n }],\n [\"06_2_Spending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1079,\n 'f': \"1079\",\n }],\n [\"06_3_Sending_an_Automated_Multisig.md\",\n{\n 'v': 613,\n 'f': \"613\",\n }],\n [\"07_0_Expanding_Bitcoin_Transactions_PSBTs.md\",\n{\n 'v': 169,\n 'f': \"169\",\n }],\n [\"07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1470,\n 'f': \"1470\",\n }],\n [\"07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1393,\n 'f': \"1393\",\n }],\n [\"07_3_Integrating_with_Hardware_Wallets.md\",\n{\n 'v': 2150,\n 'f': \"2150\",\n }],\n [\"08_0_Expanding_Bitcoin_Transactions_Other.md\",\n{\n 'v': 139,\n 'f': \"139\",\n }],\n [\"08_1_Sending_a_Transaction_with_a_Locktime.md\",\n{\n 'v': 1483,\n 'f': \"1483\",\n }],\n [\"08_2_Sending_a_Transaction_with_Data.md\",\n{\n 'v': 580,\n 'f': \"580\",\n }],\n [\"09_0_Introducing_Bitcoin_Scripts.md\",\n{\n 'v': 196,\n 'f': \"196\",\n }],\n [\"09_1_Understanding_the_Foundation_of_Transactions.md\",\n{\n 'v': 989,\n 'f': \"989\",\n }],\n [\"09_2_Running_a_Bitcoin_Script.md\",\n{\n 'v': 863,\n 'f': \"863\",\n }],\n [\"09_3_Testing_a_Bitcoin_Script.md\",\n{\n 'v': 1000,\n 'f': \"1000\",\n }],\n [\"09_4_Scripting_a_P2PKH.md\",\n{\n 'v': 838,\n 'f': \"838\",\n }],\n [\"09_5_Scripting_a_P2WPKH.md\",\n{\n 'v': 845,\n 'f': \"845\",\n }],\n [\"10_0_Embedding_Bitcoin_Scripts_in_P2SH_Transactions.md\",\n{\n 'v': 170,\n 'f': \"170\",\n }],\n [\"10_1_Understanding_the_Foundation_of_P2SH.md\",\n{\n 'v': 1164,\n 'f': \"1164\",\n }],\n [\"10_2_Building_the_Structure_of_P2SH.md\",\n{\n 'v': 1284,\n 'f': \"1284\",\n }],\n [\"10_3_Running_a_Bitcoin_Script_with_P2SH.md\",\n{\n 'v': 323,\n 'f': \"323\",\n }],\n [\"10_4_Scripting_a_Multisig.md\",\n{\n 'v': 1016,\n 'f': \"1016\",\n }],\n [\"10_5_Scripting_a_Segwit_Script.md\",\n{\n 'v': 750,\n 'f': \"750\",\n }],\n [\"10_6_Spending_a_P2SH_Transaction.md\",\n{\n 'v': 384,\n 'f': \"384\",\n }],\n [\"11_0_Empowering_Timelock_with_Bitcoin_Scripts.md\",\n{\n 'v': 108,\n 'f': \"108\",\n }],\n [\"11_1_Understanding_Timelock_Options.md\",\n{\n 'v': 557,\n 'f': \"557\",\n }],\n [\"11_2_Using_CLTV_in_Scripts.md\",\n{\n 'v': 1197,\n 'f': \"1197\",\n }],\n [\"11_3_Using_CSV_in_Scripts.md\",\n{\n 'v': 1470,\n 'f': \"1470\",\n }],\n [\"12_0_Expanding_Bitcoin_Scripts.md\",\n{\n 'v': 99,\n 'f': \"99\",\n }],\n [\"12_1_Using_Script_Conditionals.md\",\n{\n 'v': 1120,\n 'f': \"1120\",\n }],\n [\"12_2_Using_Other_Script_Commands.md\",\n{\n 'v': 407,\n 'f': \"407\",\n }],\n [\"13_0_Designing_Real_Bitcoin_Scripts.md\",\n{\n 'v': 116,\n 'f': \"116\",\n }],\n [\"13_1_Writing_Puzzle_Scripts.md\",\n{\n 'v': 998,\n 'f': \"998\",\n }],\n [\"13_2_Writing_Complex_Multisig_Scripts.md\",\n{\n 'v': 996,\n 'f': \"996\",\n }],\n [\"13_3_Empowering_Bitcoin_with_Scripts.md\",\n{\n 'v': 1467,\n 'f': \"1467\",\n }],\n [\"14_0_Using_Tor.md\",\n{\n 'v': 116,\n 'f': \"116\",\n }],\n [\"14_1_Verifying_Your_Tor_Setup.md\",\n{\n 'v': 1568,\n 'f': \"1568\",\n }],\n [\"14_2_Changing_Your_Bitcoin_Hidden_Services.md\",\n{\n 'v': 434,\n 'f': \"434\",\n }],\n [\"14_3_Adding_SSH_Hidden_Services.md\",\n{\n 'v': 330,\n 'f': \"330\",\n }],\n [\"15_0_Talking_to_Bitcoind.md\",\n{\n 'v': 254,\n 'f': \"254\",\n }],\n [\"15_1_Accessing_Bitcoind_with_C.md\",\n{\n 'v': 1238,\n 'f': \"1238\",\n }],\n [\"15_2_Programming_Bitcoind_with_C.md\",\n{\n 'v': 1427,\n 'f': \"1427\",\n }],\n [\"15_3_Receiving_Bitcoind_Notifications_with_C.md\",\n{\n 'v': 650,\n 'f': \"650\",\n }],\n [\"16_0_Programming_with_Libwally.md\",\n{\n 'v': 333,\n 'f': \"333\",\n }],\n [\"16_1_Setting_Up_Libwally.md\",\n{\n 'v': 559,\n 'f': \"559\",\n }],\n [\"16_2_Using_BIP39_in_Libwally.md\",\n{\n 'v': 939,\n 'f': \"939\",\n }],\n [\"16_3_Using_BIP32_in_Libwally.md\",\n{\n 'v': 959,\n 'f': \"959\",\n }],\n [\"16_4_Using_PSBTs_in_Libwally.md\",\n{\n 'v': 989,\n 'f': \"989\",\n }],\n [\"16_5_Using_Scripts_in_Libwally.md\",\n{\n 'v': 785,\n 'f': \"785\",\n }],\n [\"16_6_Using_Other_Functions_in_Libwally.md\",\n{\n 'v': 655,\n 'f': \"655\",\n }],\n [\"16_7_Integrating_Libwally_and_Bitcoin-CLI.md\",\n{\n 'v': 1380,\n 'f': \"1380\",\n }],\n [\"17_0_Talking_to_Bitcoind_Other.md\",\n{\n 'v': 286,\n 'f': \"286\",\n }],\n [\"17_1_Accessing_Bitcoind_with_Go.md\",\n{\n 'v': 547,\n 'f': \"547\",\n }],\n [\"17_2_Accessing_Bitcoind_with_Java.md\",\n{\n 'v': 821,\n 'f': \"821\",\n }],\n [\"17_3_Accessing_Bitcoind_with_NodeJS.md\",\n{\n 'v': 393,\n 'f': \"393\",\n }],\n [\"17_4_Accessing_Bitcoind_with_Python.md\",\n{\n 'v': 1158,\n 'f': \"1158\",\n }],\n [\"17_5_Accessing_Bitcoind_with_Rust.md\",\n{\n 'v': 829,\n 'f': \"829\",\n }],\n [\"17_6_Accessing_Bitcoind_with_Swift.md\",\n{\n 'v': 1503,\n 'f': \"1503\",\n }],\n [\"18_0_Understanding_Your_Lightning_Setup.md\",\n{\n 'v': 192,\n 'f': \"192\",\n }],\n [\"18_1_Verifying_Your_Lightning_Setup.md\",\n{\n 'v': 1294,\n 'f': \"1294\",\n }],\n [\"18_2_Knowing_Your_lightning_Setup.md\",\n{\n 'v': 399,\n 'f': \"399\",\n }],\n [\"18_2__Interlude_Accessing_a_Second_Lightning_Node.md\",\n{\n 'v': 886,\n 'f': \"886\",\n }],\n [\"18_3_Setting_Up_a_Channel.md\",\n{\n 'v': 1173,\n 'f': \"1173\",\n }],\n [\"19_0_Using_Lightning.md\",\n{\n 'v': 146,\n 'f': \"146\",\n }],\n [\"19_1_Generate_a_Payment_Request.md\",\n{\n 'v': 968,\n 'f': \"968\",\n }],\n [\"19_2_Paying_a_Invoice.md\",\n{\n 'v': 604,\n 'f': \"604\",\n }],\n [\"19_3_Closing_a_Channel.md\",\n{\n 'v': 848,\n 'f': \"848\",\n }],\n [\"19_4_Lightning_Network_Review.md\",\n{\n 'v': 626,\n 'f': \"626\",\n }],\n [\"A0_Appendices.md\",\n{\n 'v': 112,\n 'f': \"112\",\n }],\n [\"A1_0_Understanding_Bitcoin_Standup.md\",\n{\n 'v': 420,\n 'f': \"420\",\n }],\n [\"A2_0_Compiling_Bitcoin_from_Source.md\",\n{\n 'v': 412,\n 'f': \"412\",\n }],\n [\"A3_0_Using_Bitcoin_Regtest.md\",\n{\n 'v': 980,\n 'f': \"980\",\n }],\n [\"CLA.md\",\n{\n 'v': 495,\n 'f': \"495\",\n }],\n [\"CONTRIBUTING.md\",\n{\n 'v': 529,\n 'f': \"529\",\n }],\n [\"LICENSE-CC-BY-4.0.md\",\n{\n 'v': 2716,\n 'f': \"2716\",\n }],\n [\"README.md\",\n{\n 'v': 1705,\n 'f': \"1705\",\n }],\n [\"TRANSLATING.md\",\n{\n 'v': 686,\n 'f': \"686\",\n }]],\n columns: [[\"string\", \"Chapter\"], [\"number\", \"Word Count\"]],\n columnOptions: [],\n rowsPerPage: 25,\n helpUrl: \"https://colab.research.google.com/notebooks/data_table.ipynb\",\n suppressOutputScrolling: true,\n minimumWidth: undefined,\n });\n ", + "application/vnd.google.colaboratory.module+javascript": "\n import \"https://ssl.gstatic.com/colaboratory/data_table/a6224c040fa35dcf/data_table.js\";\n\n window.createDataTable({\n data: [[\"01_0_Introduction.md\",\n{\n 'v': 1144,\n 'f': \"1144\",\n }],\n [\"01_1_Introducing_Bitcoin.md\",\n{\n 'v': 2735,\n 'f': \"2735\",\n }],\n [\"02_0_Setting_Up_a_Bitcoin-Core_VPS.md\",\n{\n 'v': 226,\n 'f': \"226\",\n }],\n [\"02_1_Setting_Up_a_Bitcoin-Core_VPS_with_StackScript.md\",\n{\n 'v': 2746,\n 'f': \"2746\",\n }],\n [\"02_2_Setting_Up_Bitcoin_Core_Other.md\",\n{\n 'v': 254,\n 'f': \"254\",\n }],\n [\"03_0_Understanding_Your_Bitcoin_Setup.md\",\n{\n 'v': 248,\n 'f': \"248\",\n }],\n [\"03_1_Verifying_Your_Bitcoin_Setup.md\",\n{\n 'v': 773,\n 'f': \"773\",\n }],\n [\"03_2_Knowing_Your_Bitcoin_Setup.md\",\n{\n 'v': 517,\n 'f': \"517\",\n }],\n [\"03_3_Setting_Up_Your_Wallet.md\",\n{\n 'v': 1699,\n 'f': \"1699\",\n }],\n [\"03_3__Interlude_Using_Command-Line_Variables.md\",\n{\n 'v': 347,\n 'f': \"347\",\n }],\n [\"03_4_Receiving_a_Transaction.md\",\n{\n 'v': 1479,\n 'f': \"1479\",\n }],\n [\"03_5_Understanding_the_Descriptor.md\",\n{\n 'v': 1349,\n 'f': \"1349\",\n }],\n [\"04_0_Sending_Bitcoin_Transactions.md\",\n{\n 'v': 176,\n 'f': \"176\",\n }],\n [\"04_1_Sending_Coins_The_Easy_Way.md\",\n{\n 'v': 1195,\n 'f': \"1195\",\n }],\n [\"04_2_Creating_a_Raw_Transaction.md\",\n{\n 'v': 1720,\n 'f': \"1720\",\n }],\n [\"04_2__Interlude_Using_JQ.md\",\n{\n 'v': 1956,\n 'f': \"1956\",\n }],\n [\"04_3_Creating_a_Raw_Transaction_with_Named_Arguments.md\",\n{\n 'v': 413,\n 'f': \"413\",\n }],\n [\"04_4_Sending_Coins_with_a_Raw_Transaction.md\",\n{\n 'v': 1024,\n 'f': \"1024\",\n }],\n [\"04_4__Interlude_Using_Curl.md\",\n{\n 'v': 1643,\n 'f': \"1643\",\n }],\n [\"04_5_Sending_Coins_with_Automated_Raw_Transactions.md\",\n{\n 'v': 614,\n 'f': \"614\",\n }],\n [\"04_6_Creating_a_Segwit_Transaction.md\",\n{\n 'v': 1172,\n 'f': \"1172\",\n }],\n [\"05_0_Controlling_Bitcoin_Transactions.md\",\n{\n 'v': 149,\n 'f': \"149\",\n }],\n [\"05_1_Watching_for_Stuck_Transactions.md\",\n{\n 'v': 595,\n 'f': \"595\",\n }],\n [\"05_2_Resending_a_Transaction_with_RBF.md\",\n{\n 'v': 1372,\n 'f': \"1372\",\n }],\n [\"05_3_Funding_a_Transaction_with_CPFP.md\",\n{\n 'v': 827,\n 'f': \"827\",\n }],\n [\"06_0_Expanding_Bitcoin_Transactions_Multisigs.md\",\n{\n 'v': 155,\n 'f': \"155\",\n }],\n [\"06_1_Sending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1764,\n 'f': \"1764\",\n }],\n [\"06_2_Spending_a_Transaction_to_a_Multisig.md\",\n{\n 'v': 1079,\n 'f': \"1079\",\n }],\n [\"06_3_Sending_an_Automated_Multisig.md\",\n{\n 'v': 613,\n 'f': \"613\",\n }],\n [\"07_0_Expanding_Bitcoin_Transactions_PSBTs.md\",\n{\n 'v': 169,\n 'f': \"169\",\n }],\n [\"07_1_Creating_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1470,\n 'f': \"1470\",\n }],\n [\"07_2_Using_a_Partially_Signed_Bitcoin_Transaction.md\",\n{\n 'v': 1393,\n 'f': \"1393\",\n }],\n [\"07_3_Integrating_with_Hardware_Wallets.md\",\n{\n 'v': 2150,\n 'f': \"2150\",\n }],\n [\"08_0_Expanding_Bitcoin_Transactions_Other.md\",\n{\n 'v': 139,\n 'f': \"139\",\n }],\n [\"08_1_Sending_a_Transaction_with_a_Locktime.md\",\n{\n 'v': 1483,\n 'f': \"1483\",\n }],\n [\"08_2_Sending_a_Transaction_with_Data.md\",\n{\n 'v': 580,\n 'f': \"580\",\n }],\n [\"09_0_Introducing_Bitcoin_Scripts.md\",\n{\n 'v': 196,\n 'f': \"196\",\n }],\n [\"09_1_Understanding_the_Foundation_of_Transactions.md\",\n{\n 'v': 989,\n 'f': \"989\",\n }],\n [\"09_2_Running_a_Bitcoin_Script.md\",\n{\n 'v': 863,\n 'f': \"863\",\n }],\n [\"09_3_Testing_a_Bitcoin_Script.md\",\n{\n 'v': 1000,\n 'f': \"1000\",\n }],\n [\"09_4_Scripting_a_P2PKH.md\",\n{\n 'v': 838,\n 'f': \"838\",\n }],\n [\"09_5_Scripting_a_P2WPKH.md\",\n{\n 'v': 845,\n 'f': \"845\",\n }],\n [\"10_0_Embedding_Bitcoin_Scripts_in_P2SH_Transactions.md\",\n{\n 'v': 170,\n 'f': \"170\",\n }],\n [\"10_1_Understanding_the_Foundation_of_P2SH.md\",\n{\n 'v': 1164,\n 'f': \"1164\",\n }],\n [\"10_2_Building_the_Structure_of_P2SH.md\",\n{\n 'v': 1284,\n 'f': \"1284\",\n }],\n [\"10_3_Running_a_Bitcoin_Script_with_P2SH.md\",\n{\n 'v': 323,\n 'f': \"323\",\n }],\n [\"10_4_Scripting_a_Multisig.md\",\n{\n 'v': 1016,\n 'f': \"1016\",\n }],\n [\"10_5_Scripting_a_Segwit_Script.md\",\n{\n 'v': 750,\n 'f': \"750\",\n }],\n [\"10_6_Spending_a_P2SH_Transaction.md\",\n{\n 'v': 384,\n 'f': \"384\",\n }],\n [\"11_0_Empowering_Timelock_with_Bitcoin_Scripts.md\",\n{\n 'v': 108,\n 'f': \"108\",\n }],\n [\"11_1_Understanding_Timelock_Options.md\",\n{\n 'v': 557,\n 'f': \"557\",\n }],\n [\"11_2_Using_CLTV_in_Scripts.md\",\n{\n 'v': 1197,\n 'f': \"1197\",\n }],\n [\"11_3_Using_CSV_in_Scripts.md\",\n{\n 'v': 1470,\n 'f': \"1470\",\n }],\n [\"12_0_Expanding_Bitcoin_Scripts.md\",\n{\n 'v': 99,\n 'f': \"99\",\n }],\n [\"12_1_Using_Script_Conditionals.md\",\n{\n 'v': 1120,\n 'f': \"1120\",\n }],\n [\"12_2_Using_Other_Script_Commands.md\",\n{\n 'v': 407,\n 'f': \"407\",\n }],\n [\"13_0_Designing_Real_Bitcoin_Scripts.md\",\n{\n 'v': 116,\n 'f': \"116\",\n }],\n [\"13_1_Writing_Puzzle_Scripts.md\",\n{\n 'v': 998,\n 'f': \"998\",\n }],\n [\"13_2_Writing_Complex_Multisig_Scripts.md\",\n{\n 'v': 996,\n 'f': \"996\",\n }],\n [\"13_3_Empowering_Bitcoin_with_Scripts.md\",\n{\n 'v': 1467,\n 'f': \"1467\",\n }],\n [\"14_0_Using_Tor.md\",\n{\n 'v': 116,\n 'f': \"116\",\n }],\n [\"14_1_Verifying_Your_Tor_Setup.md\",\n{\n 'v': 1568,\n 'f': \"1568\",\n }],\n [\"14_2_Changing_Your_Bitcoin_Hidden_Services.md\",\n{\n 'v': 434,\n 'f': \"434\",\n }],\n [\"14_3_Adding_SSH_Hidden_Services.md\",\n{\n 'v': 330,\n 'f': \"330\",\n }],\n [\"15_0_Talking_to_Bitcoind.md\",\n{\n 'v': 254,\n 'f': \"254\",\n }],\n [\"15_1_Accessing_Bitcoind_with_C.md\",\n{\n 'v': 1238,\n 'f': \"1238\",\n }],\n [\"15_2_Programming_Bitcoind_with_C.md\",\n{\n 'v': 1427,\n 'f': \"1427\",\n }],\n [\"15_3_Receiving_Bitcoind_Notifications_with_C.md\",\n{\n 'v': 650,\n 'f': \"650\",\n }],\n [\"16_0_Programming_with_Libwally.md\",\n{\n 'v': 333,\n 'f': \"333\",\n }],\n [\"16_1_Setting_Up_Libwally.md\",\n{\n 'v': 559,\n 'f': \"559\",\n }],\n [\"16_2_Using_BIP39_in_Libwally.md\",\n{\n 'v': 939,\n 'f': \"939\",\n }],\n [\"16_3_Using_BIP32_in_Libwally.md\",\n{\n 'v': 959,\n 'f': \"959\",\n }],\n [\"16_4_Using_PSBTs_in_Libwally.md\",\n{\n 'v': 989,\n 'f': \"989\",\n }],\n [\"16_5_Using_Scripts_in_Libwally.md\",\n{\n 'v': 785,\n 'f': \"785\",\n }],\n [\"16_6_Using_Other_Functions_in_Libwally.md\",\n{\n 'v': 655,\n 'f': \"655\",\n }],\n [\"16_7_Integrating_Libwally_and_Bitcoin-CLI.md\",\n{\n 'v': 1380,\n 'f': \"1380\",\n }],\n [\"17_0_Talking_to_Bitcoind_Other.md\",\n{\n 'v': 286,\n 'f': \"286\",\n }],\n [\"17_1_Accessing_Bitcoind_with_Go.md\",\n{\n 'v': 547,\n 'f': \"547\",\n }],\n [\"17_2_Accessing_Bitcoind_with_Java.md\",\n{\n 'v': 821,\n 'f': \"821\",\n }],\n [\"17_3_Accessing_Bitcoind_with_NodeJS.md\",\n{\n 'v': 393,\n 'f': \"393\",\n }],\n [\"17_4_Accessing_Bitcoind_with_Python.md\",\n{\n 'v': 1158,\n 'f': \"1158\",\n }],\n [\"17_5_Accessing_Bitcoind_with_Rust.md\",\n{\n 'v': 829,\n 'f': \"829\",\n }],\n [\"17_6_Accessing_Bitcoind_with_Swift.md\",\n{\n 'v': 1503,\n 'f': \"1503\",\n }],\n [\"18_0_Understanding_Your_Lightning_Setup.md\",\n{\n 'v': 192,\n 'f': \"192\",\n }],\n [\"18_1_Verifying_Your_Lightning_Setup.md\",\n{\n 'v': 1294,\n 'f': \"1294\",\n }],\n [\"18_2_Knowing_Your_lightning_Setup.md\",\n{\n 'v': 399,\n 'f': \"399\",\n }],\n [\"18_2__Interlude_Accessing_a_Second_Lightning_Node.md\",\n{\n 'v': 886,\n 'f': \"886\",\n }],\n [\"18_3_Setting_Up_a_Channel.md\",\n{\n 'v': 1173,\n 'f': \"1173\",\n }],\n [\"19_0_Using_Lightning.md\",\n{\n 'v': 146,\n 'f': \"146\",\n }],\n [\"19_1_Generate_a_Payment_Request.md\",\n{\n 'v': 968,\n 'f': \"968\",\n }],\n [\"19_2_Paying_a_Invoice.md\",\n{\n 'v': 604,\n 'f': \"604\",\n }],\n [\"19_3_Closing_a_Channel.md\",\n{\n 'v': 848,\n 'f': \"848\",\n }],\n [\"19_4_Lightning_Network_Review.md\",\n{\n 'v': 626,\n 'f': \"626\",\n }],\n [\"A0_Appendices.md\",\n{\n 'v': 112,\n 'f': \"112\",\n }],\n [\"A1_0_Understanding_Bitcoin_Standup.md\",\n{\n 'v': 420,\n 'f': \"420\",\n }],\n [\"A2_0_Compiling_Bitcoin_from_Source.md\",\n{\n 'v': 412,\n 'f': \"412\",\n }],\n [\"A3_0_Using_Bitcoin_Regtest.md\",\n{\n 'v': 980,\n 'f': \"980\",\n }],\n [\"CLA.md\",\n{\n 'v': 495,\n 'f': \"495\",\n }],\n [\"CONTRIBUTING.md\",\n{\n 'v': 529,\n 'f': \"529\",\n }],\n [\"LICENSE-CC-BY-4.0.md\",\n{\n 'v': 2716,\n 'f': \"2716\",\n }],\n [\"README.md\",\n{\n 'v': 1705,\n 'f': \"1705\",\n }],\n [\"TRANSLATING.md\",\n{\n 'v': 686,\n 'f': \"686\",\n }],\n [\"TOTAL\",\n{\n 'v': 89069,\n 'f': \"89069\",\n }]],\n columns: [[\"string\", \"Chapter\"], [\"number\", \"Word Count\"]],\n columnOptions: [],\n rowsPerPage: 25,\n helpUrl: \"https://colab.research.google.com/notebooks/data_table.ipynb\",\n suppressOutputScrolling: true,\n minimumWidth: undefined,\n });\n ", "text/plain": [ "" ], @@ -257,11 +269,6 @@ " ...\n", " \n", " \n", - " 5\n", - " CLA.md\n", - " 495\n", - " \n", - " \n", " 0\n", " CONTRIBUTING.md\n", " 529\n", @@ -281,16 +288,21 @@ " TRANSLATING.md\n", " 686\n", " \n", + " \n", + " 102\n", + " TOTAL\n", + " 89069\n", + " \n", " \n", "\n", - "

102 rows × 2 columns

\n", + "

103 rows × 2 columns

\n", "" ] }, "metadata": { "tags": [] }, - "execution_count": 5 + "execution_count": 6 } ] }, @@ -300,7 +312,7 @@ "id": "14kdusmNzcfz" }, "source": [ - "To convert the table to a markdown format and save as 'Chapter_word_counts.md'" + "Converts the table to a markdown format and save as 'Chapter_word_counts.md'" ] }, { @@ -327,7 +339,7 @@ " return '\\n'.join(['| {}'.format(row.split('|', 2)[-1]) for row in blob.split('\\n')])\n", " return blob" ], - "execution_count": 6, + "execution_count": 7, "outputs": [] }, { @@ -341,7 +353,7 @@ "with open('Chapter_word_counts.md', 'w') as m:\n", " m.write(str(mkdt.data))" ], - "execution_count": 7, + "execution_count": 8, "outputs": [] }, { @@ -350,14 +362,13 @@ "colab": { "base_uri": "https://localhost:8080/" }, - "id": "_gGsbGDckIrC", - "outputId": "8d4bbec6-aa6e-465b-fec7-4251f7f4cecf" + "id": "kRKJUNcj_Fxl", + "outputId": "d826e833-2f4a-4f8f-b78f-cd07712c0f28" }, "source": [ - "total_count_translatable = chapter_word_counts['Word Count'].sum()\n", "total_count_translatable" ], - "execution_count": 8, + "execution_count": 9, "outputs": [ { "output_type": "execute_result", @@ -369,7 +380,7 @@ "metadata": { "tags": [] }, - "execution_count": 8 + "execution_count": 9 } ] } From cbf889f4cb5081c289703b369d6cbe80b8a4e344 Mon Sep 17 00:00:00 2001 From: Ian Culp <57159226+icculp@users.noreply.github.com> Date: Wed, 16 Jun 2021 23:05:17 -0500 Subject: [PATCH 12/12] typo in translatable --- Chapter_word_counts.md | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Chapter_word_counts.md b/Chapter_word_counts.md index 4945dd2..406c1ee 100644 --- a/Chapter_word_counts.md +++ b/Chapter_word_counts.md @@ -1,6 +1,6 @@ ## Translatable word counts by chapter -Ignores code blocks and other non-translateable characters +Ignores code blocks and other non-translatable characters Chapter|Word Count ---|---