[Question]
  [
# Goal
[Morse code](https://en.wikipedia.org/wiki/Morse_code) is often represented as sound. Given a stream of bits that represent whether sound is on or off, translate the stream into letters and numbers and spaces.
[![International Morse Code](https://i.stack.imgur.com/UFJqy.png)](https://i.stack.imgur.com/UFJqy.png)
# Specifics
* The bit stream is analysed based on the length of repeating ON/OFF bits.
	+ 1 ON bit is a dot
	+ 3 ON bits are a dash
	+ 1 OFF bit delimits dots and dashes
	+ 3 OFF bits delimits characters
	+ 7 OFF bits delimits words (space)
* The input may be a string or array. Only two unique characters/values of your choice are allowed in the input. (eg. 0/1, true/false, comma/space)
* The output returns a string or is printed to the standard output.
# Example
```
Input:    101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101
Analysis: \--H--/   E   \---L---/   \---L---/   \----O----/\-- --/\---W---/   \----O----/   \--R--/   \---L---/   \--D--/
Output:   HELLO WORLD
```
# Assumptions
* The stream always starts and ends with an ON bit.
* There is no leading or trailing whitespace.
* The input is always valid.
* All letters (case-insensitive) and digits are supported.
# Test Cases
```
101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101
HELLO WORLD
10100000001011100011101110000000101110000000101011101000101000101010001010101
I AM A FISH
1010111011101110001110111011101110111000101110111011101110001110111010101
2017
101010001110111011100010101
SOS
```
# Scoring
This is code golf. The lowest byte-count code by this time next week wins.
  
[Answer]
# [APL (Dyalog)](https://www.dyalog.com/), ~~65~~ ~~62~~ ~~60~~ 57 bytes
-3 thanks to ngn.
Tacit prefix function.
```
⎕CY'dfns'
morse'/|[-.]+'⎕S'&'∘(⊃∘'/. -'¨6|'1+|(00)+'⎕S 1)
```
[Try it online!](https://tio.run/##SyzI0U2pTMzJT///qKO96FHbhMy8zBIuEONR31RPfyBt8B/Ico5UT0nLK1bnSgOK5OYXFaeq69dE6@rFaqsDZYPV1dQfdczQeNTVDKTU9fUUdNUPrTCrUTfUrtEwMNCEKFIw1ARZwgWy4b8CGKQpqBsaQKABFBsaIvhIbENDOIYAZD6qLEwfFhMMDNW5UGxGNssAqw1wNrKpMBE4jW4umosMDTGwgQFWMUOEmzHMxOZToCoA "APL (Dyalog Unicode) – Try It Online") Header, `f←`, and Footer are just to allow calling the function from Input while retaining TIO's byte count. In a normal APL session (corresponding to TIO's Input field), [it would not be needed](https://tio.run/##SyzI0U2pTMzJT////1HfVE//R20TDMBM50j1lLS8YnUujdz8ouJUdf2aaF29WG11oFSwupr6o44ZGo@6moGUur6egq76oRVmNeqG2jUaBgaaEEUKhpqa6oYGEGgAxYaGCD4S29AQjiEAmY8qC9OHxQQDQ3UA "APL (Dyalog Unicode) – Try It Online").
`⎕CY'dfns'` **c**op**y** the *dfns* workspace (library)
`(`…`)` apply this tacit function:  
 `'1+|(00)+'⎕S 1` PCRE **S**earch 1-runs and even-length 0-runs and return matches' lengths  
 `6|` division remainder when divided by 6  
 `⊃∘'/. -'¨` for each match length, pick the corresponding character from this string  
`'/|[-.]+'⎕S'&'∘` PCRE **S**earch slashes and dash/dot-runs and return those  
`morse` translate from Morse code to regular text
[Answer]
# [Python 2](https://docs.python.org/2/), ~~142~~ 135 bytes
```
lambda s:''.join(' E-T----Z-Q---RSWU--2FH-V980NIMA--1CBYX-6--GDOK534PLJ-7'[int('0'+l.replace('111','3'),16)%57]for l in s.split('000'))
```
[Try it online!](https://tio.run/##bY9Lb8IwDMfvfIpckBuBK5v3kDgw2AZ78Rqwse1QGNU6hbZqufDpuyCgFFpHTmwn/58df7f99dxSZLe@ImVtlj@WCJsA5p/nuAaIO3xDbQsc6X08mU8RS/c9nN006LX/0kbkzu3HO9YQH7qDp2q5Mnx@xDp8Ou7WAIKCMoO1r6zV2gBmhiKUQRa5JvPV@rftBUIJxxWhGfrK2QuIQMrID7Rc2FpCh0VH14g4T8TMsR8smV/ennQZBGKQuYvWSRhltojjJPZUic8U@Gom5pQTZdb4PHUamvXZ/bPoHw "Python 2 – Try It Online")
**Explanation:**
Splits the string into letters on `000` (`0` thus means space)
Replaces each `111` with `3`, and converts into base 16.
Then each number is modded by `57`, which gives a range of `0..54`, which is the index of the current character.
---
Previous version that converted to base 3:
# [Python 2](https://docs.python.org/2/), ~~273~~ ~~252~~ 247 bytes
```
lambda s:''.join(chr(dict(zip([0,242,161,134,125,122,121,202,229,238,241]+[2]*7+[5,67,70,22,1,43,25,40,4,53,23,49,8,7,26,52,77,16,13,2,14,41,17,68,71,76],[32]+range(48,91)))[int('0'+l.replace('111','2').replace('0',''),3)])for l in s.split('000'))
```
[Try it online!](https://tio.run/##bY/bboMwDIbv9xTcJRm/KtsEUibtSRgXrIeViQGivdlenrnqSulKIis@/Z@d/vt06FoZ969vY1N9vW@r6PhizOqzq1u7OQx2W29O9qfubUEQL@CMwYkHS6qmsTCEBCI5JFlrD5dxIeVziIsUWUBQnbbBJ1CJJ3ik6ibwOdYIkAypIAQlKxja6uF1RkCmZUbIShSJlPFQtR8769fI2TlX1O3JGjJxsxp2fVNtdtYws4ER424p0oRxSFzp9t0QNVHdRsfVsW/qs5rIODf2g7KiverpcunPlDfFM595ssuZx/fVq26BQGzc093oOYwWR0z@HHvNTO8D@N9OzA9GtJjj29aP0KXPntvGXw "Python 2 – Try It Online")
Previous version that converted to binary:
# [Python 2](https://docs.python.org/2/), ~~282~~ ~~261~~ 256 bytes
```
lambda s:''.join(chr(dict(zip([0,489335,96119,22391,5495,1367,341,1877,7637,30581,122333]+[2]*7+[23,469,1885,117,1,349,477,85,5,6007,471,373,119,29,1911,1501,7639,93,21,7,87,343,375,1879,7543,1909],[32]+range(48,91)))[int('0'+l,2)])for l in s.split('000'))
```
[Try it online!](https://tio.run/##bU9BcoMwDLz3FdxsN5qMZGGMOtOXUA5p0jR0KGGAS/t5KpomIQ32yNZKq127/RoOx8aP@@eXsd58vu42Sf9kzPrjWDV2e@jsrtoO9rtqbYGQ5sIcQDIiAe9ZCEIqAYizCJwSUB4jxIwVYcgVK4m5XBW@fIx6MqSZKCvXGYpAOiSQ6owWAmSIUZFWI8OvhXKFVCYgTbICwuA1hXzyYyWGyVMgBkUkKCUU7MtVt2ne32yag5BzrqiawRo0qxq8K93@2CV1UjVJv@7buppaiMa5se2UmOytITxt/AuiK57lRJc4rTm@7Z7nFhSQjHu4sZ6L4aLFJZ/LniuX@07435uI7gJxsUbXV9@LLn12oo0/ "Python 2 – Try It Online")
[Answer]
# [Ruby](https://www.ruby-lang.org/), 123 bytes
```
->s{s.split(/0000?/).map{|r|r[0]?"YE9_0IZTO_BHKU58V_GR_SFA__1_4NP_60X_____C__D_ML7WQ3__2__J"[r.to_i(2)%253%132%74]:" "}*""}
```
[Try it online!](https://tio.run/##KypNqvyfZvtf1664ulivuCAns0RD3wAI7PU19XITC6primqKog1i7ZUiXS3jDTyjQvzjnTy8Q00twuLdg@KD3Rzj4w3jTfwC4s0MIuJBwDk@3iXe18c8PNA4Pt4oPt5LKbpIryQ/PlPDSFPVyNRY1dDYSNXcJNZKSUGpVktJqfZ/QWlJsUJatJKhAQQaQLGhIYKPxDY0hGMIQOajysL0YTHBwFAplgvZZmSzDLDaAGcjmwoTgdPo5qK5yNAQAxsYYBUzRLgZw0xsPgWp@g8A "Ruby – Try It Online")
Split the input string on character limit. Use 3 or 4 OFF bits so that spaces are converted to empty strings. Take the base 2 value of every character, and bring into a reasonable range (less than 60 possible values) using modulo on 3 successive divisions.
[Answer]
# [Python](https://tio.run/##bVHJboQwDL3zFbmZqGgUz3SZYnHovkzb6b4hDrQFNYgCmuTSr6dEMIG2OHqJ7Ze8OE71rT/LYlbXKsjjr7ePmGkvDQAmWSkLP3WB2P3R5dXe2fJkcfh0@3BHdPP6cvC8f35NF3T8eCp2aU5EO9TaNnbOtMGMNrcglIV2AWGjERMgU5aF6EdJrhKWsbRcNbMsmJyoKpfabOHcm/LIMNIw2jLCcLVOlH6PVRKEDqBoh@iA2McDH9GitWH8m12fG1EQCF575VBEjEpbfyi3ztjVCv6pAfEfhBjNYV9lLzb2qIZ2IqdvatdEv1qZ71Gu5NypfwA), ~~175~~ 168 bytes
```
s=lambda t,f=''.join:f('; TEMNAIOGKDWRUS;;QZYCXBJP;L;FVH09;8;;;7;;;;;;;61;;;;;;;2;;;3;45'[int('1'+f('0'if j[1:]else j for j in i.split('0')),2)]for i in t.split('000'))
```
First convert the string into list of 0(dash)/1(dot) string, add a prefix `1` (to prevent leading zeroes and deal with whitespaces), then convert to binary.
Since every code have length no more than 5, the result ranges from 0 to 63 and can be listed in a string.
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), ~~67~~ 62 bytes
```
ṣ0L€«2ḅ2“>.&" þ/7;=¥çı¿¢×ÆÐ¤æ€Œ©¦Çß÷µ¬£®Ñ½ðȷñ‘iịØB;⁶¤
œṣ0ẋ3¤Ç€
```
[Try it online!](https://tio.run/##y0rNyan8///hzsUGPo@a1hxabfRwR6vRo4Y5dnpqSgqH9@mbW9seWnp4@ZGNh/YfWnR4@uG2wxMOLTm8DKj26KRDKw8tO9x@eP7h7Ye2HlpzaPGhdYcnHtp7eMOJ7Yc3PmqYkflwd/fhGU7Wjxq3HVrCdXQyyJKHu7qNgfrbgfr///8fbaijYKCjACExEVzWEFUNsgimLDEmYFWDaTJWNVh14RE3jAUA "Jelly – Try It Online")
[Answer]
# [Visual Basic .NET (.NET Core)](https://www.microsoft.com/net/core/platform), 252 bytes
*-7 bytes thanks to @recursive*
```
Function A(i)
For Each w In i.Split({"0000000"},0)
For Each l In w.Split({"000"},0)
Dim c=0
For Each p In l.Split("0")
c=c*2+1+p.Length\2
Next
A &="!ETIANMSURWDKGOHVF!L!PJBXCYZQ!!54!3!!!2!!!!!!!16!!!!!!!7!!!8!90"(c)
Next
A+=" "
Next
End Function
```
A function that takes a string of `1`s and `0`s, and returns a string. (Actually, only the `0` for the `OFF` is a hard requirement. Anything not `OFF` is assumed to be `ON`).
The string literal is Morse code setup as a binary heap in array form. VB.NET lets you index strings as arrays of characters. The `\` is integer division, taking the left sub heap for `1` or the right sub heap for `111`.
I used `!` as a blank for when there isn't a value in that heap spot. It's only necessary to properly pad out the indices.
VB.NET lets you return by assigning a value to the function name (in this case, `A`). I just iteratively do string concatenations (`&`) to build up the output string. The very first time I need to use `&` because using `+` leaves a leading null char, but any other time I can use `+`, which behaves the same as `&` for strings.
[Try it online!](https://tio.run/##hVJbT4MwFH6WX9H2wYAoafH@wANu4KYwL6hT48vWNa4JlgXBmRh/Ow7LpSpxpzk5l37n1tO36Q5NUlaEySyPGQhJ4eeCZjwRwNW5oflJCrwJnYMlGArArWgR80z/QFgS@tzGCiguQUsVJAF9/gKog1vgogTGFRBhZGjUoVu2ScyFFTDxnM2fbG3E3jPNBZsOgt7N0B2F0e31uH9@ejG482EAL89O7nsPj1cQ7u/BXQihDSWRg0o5XPERPMZIp0aVzXQQQFL3xAzUwxZRPgXhhAtto5eI1yRm1jjlGQu4YLqrI4LlwRUT0tqKTkjDklT7520d15EBE2QY/zSipsadBRtdLVJ7GrmmzK9@CfnDGHf6SDvRuhJdzyKDyu2slvIt5ecsvgA "Visual Basic .NET (.NET Core) – Try It Online")
[Answer]
# JavaScript (ES6), ~~170~~ 131 bytes
```
s=>s.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=+`0b${1+e.replace(/0?(111|1)/g,d=>+(d>1))}`]||'473168290 5'[c%11]).join``
```
---
**How it works:**
If you change the dots to 0s and the dashes to 1s, and prefix with a 1, you get binary numbers, which when converted to decimal gives you:
1. Letters: 2 - 18, 20, and 22 - 29.  
These can be converted to the correct letters by indexing into `' ETIANMSURWDKGOHVF L PJBXCYZQ'`.
2. Numbers: 32, 33, 35, 39, 47, 48, 56, 60, 62, and 63.  
If we take these numbers modulus 11, we get the numbers 0 - 8 and 10, which can be converted to the correct numbers by indexing into `'473168290 5'`.
The program splits on characters, then converts each character into dots and dashes, which are converted into the appropriate output based on the above rules.
---
**Test Cases:**
```
let f=
s=>s.split`000`.map(e=>'  ETIANMSURWDKGOHVF L PJBXCYZQ'[c=+`0b${1+e.replace(/0?(111|1)/g,d=>+(d>1))}`]||'473168290 5'[c%11]).join``
console.log(f('101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101'))
console.log(f('10100000001011100011101110000000101110000000101011101000101000101010001010101'));
console.log(f('1010111011101110001110111011101110111000101110111011101110001110111010101'));
console.log(f('101010001110111011100010101'));
```
[Answer]
# [Python 2](https://docs.python.org/2/), 127 bytes
```
lambda s:''.join("IVMB  T  K 9LZF 1HWO3 GUS4 8 7A  E QR 26   NJX    Y0P 5D  C"[(int('0'+l)^2162146)%59]for l in s.split('000'))
```
[Try it online!](https://tio.run/##bY/dboJAEIXv@xQnJGbZmJgZCihNelGrrVb7o1bbqm2CMaQYBCLc@PQUY0UQdnN2Z2ZnvpkN9/Fv4GuJc7tMPHu7WtuIboRobALXV5X@7LkNvAMDWMP5A7j38XqNx@lERwvNO6CL0RiaCeDl6TM98UVvMDrAvbJQXT9WBYm6J380NjXWTVkzrG8n2MGD6yNqRKHnHnKIhJRJuEsr4KiC6bjpX8xnP2czZzquvF98PdVVEIiFvCq0zsOoskVm57GnSHaXwBczMZdEVBnj89RlaNVnD2nJHw "Python 2 – Try It Online")
Building off of **TFeld**'s solution by removing *replace* and by working in base 10, at the cost of a bitwise xor and a longer reference string.
[Answer]
# PHP, ~~321~~ 284 bytes
*Saved 37 bytes thanks to @ovs*
```
$a=array_flip([242,161,134,125,122,121,202,229,238,241,5,67,70,22,1,43,25,40,4,53,23,49,8,7,26,52,77,16,13,2,14,41,17,68,71,76]);foreach(split('0000000',$argv[1])as$w){foreach(split('000',$w)as$m){echo($v=$a[base_convert(str_replace([111,0],[2,],$m),3,10)])>9?chr($v+55):$v;}echo' ';}  
```
Previous version (321 bytes)
```
$a=array_flip([22222,12222,11222,11122,11112,11111,21111,22111,22211,22221,12,2111,2121,211,1,1121,221,1111,11,1222,212,1211,22,21,222,1221,2212,121,111,2,112,1112,122,2112,2122,2211]);foreach(split('0000000',$argv[1])as$w){foreach(split('000',$w)as$m){echo($v=$a[str_replace([111,0],[2,],$m)])>9?chr($v+55):$v;}echo' ';}
```
[Try it online!](https://eval.in/901674)
Ungolfed version : 
```
$a=array_flip(
// Building an array $a with every Morse letter representation (1=dot, 2=dash) and flip it
               [22222,12222,11222,11122,11112,
                // 01234
                11111,21111,22111,22211,22221,
                // 56789
                12,2111,2121,211,1,1121,221,
                // ABCDEFG
                1111,11,1222,212,1211,22,
                // HIJKLM
                21,222,1221,2212,121,111,2,
                // NOPQRST
                112,1112,122,2112,2122,2211]);
                // UVWXYZ
foreach (split('0000000', $argv[1]) as $w){
// for each word (separate with 7 consecutive zeroes)
    foreach (split('000',$w) as $m){
    // for each letter (separate with 3 consecutive zeroes)
        echo ($v = $a[str_replace([111,0],[2,],$m)]) > 9
        // Replace '111' with '2' and '0' with nothing and find $v, the corresponding entry in the array $a
            ? chr($v+55)
            // If > 9th element, then letter => echo the ASCII code equal to $v+55
            : $v;
            // Else echo $v
    }
    echo ' ';
    // Echo a space
}
```
[Answer]
# [GNU sed](https://www.gnu.org/software/sed/), 261 + 1 = 262 bytes
+1 byte for `-r` flag.
```
s/000/;/g
s/111/_/g
s/0//g
s/$/;:51111141111_3111__211___i1____6_11117__1118___119____10_____H1111V111_F11_1L1_11P1__1J1___B_111X_11_C_1_1Y_1__Z__11Q__1_S111U11_R1_1W1__D_11K_1_N__1G__1O___I11A1_M__E1T_/
:
s/([1_]+);(.*([^1_])\1)/\3\2/
t
y/i/1/
s/;/ /g
s/:.*//g
```
[Try it online!](https://tio.run/##bU/JUoNQELzzFR48QKxkphNXOLnvcV@DzkXL4mIsycWfF3sgIag8qnuWZvq9yV9fiiIXVZVE3oJcAIiVmUoZFiWJV@Bn2ckGTtZ3sszJVs2FNfOwbh42vA11tgMXb31oj8AJgXPO4ciHt3zonmTbRuWBZI9ucUGyK4o31C4p3VHZoXDM/pDiPnFGh0NgE3ZqtotrkyDmk8MR7GkpSsJeJxw9M49SRJIO0r4Ek@BLMoHwt0QWyg3jXoerFgW0@nQKXl7XjRyoUZ1m/VudzbU4KIKqmjtoq2@dN71mnTpWbn9uB/5BtbWH@fumTm27KL7HH5Ns/J4X3c8f "sed 4.2.2 – Try It Online")
## Explanation
This is a very basic lookup table solution.
The first three lines transform the input so dashes are `_`s and dots are `1`s. First, `000`s are replaced with `;`, so characters are separated by `;` and words by `;;0`. Then `111`s are replaced by `_` and all remaining `0`s are discarded, leaving `1`s for dots.
```
s/000/;/g
s/111/_/g
s/0//g
```
The next line appends the lookup table. It takes the form `cmcmcm...` where `c` is a character and `m` is the sequence of `_`s and `1`s representing it. `i` is substituted for `1` in the table for disambiguation. Since regular expressions in sed are always greedy, the table is sorted from longest to shortest code (so e.g. `1_` matches `A1_` instead of `i1____`).
```
s/$/;:51111141111_3111__211___i1____6_11117__1118___119____10_____H1111V111_F11_1L1_11P1__1J1___B_111X_11_C_1_1Y_1__Z__11Q__1_S111U11_R1_1W1__D_11K_1_N__1G__1O___I11A1_M__E1T_/
```
Next, in a loop, each sequence of `_`s and `1`s (and the subsequent `;`) is replaced by the corresponding character:
```
:
s/([1_]+);(.*([^1_])\1)/\3\2/
t
```
Finally, cleanup: `i`s are replaced with `1`s, remaining `;`s are spaces, and the lookup table is deleted:
```
y/i/1/
s/;/ /g
s/:.*//g
```
[Answer]
# [Java (JDK)](http://jdk.java.net/), 355 bytes
```
s->{var r="";for(var t:s.split("0000000")){for(var u:t.split("000"))for(int x[]={1,7,5,21,29,23,87,93,119,85,117,341,375,343,373,471,477,349,469,1877,1367,1909,1879,1501,1911,1885,7637,5495,7543,7639,6007,30581,22391,122333,96119,489335},i=36;i-->0;)if(u.equals(Long.toString(x[i],2)))r+="ETISNAURMHD5WVLKGFB64ZXPOC73YQJ82910".charAt(i);r+=" ";}return r;}
```
[Try it online!](https://tio.run/##bVJZj9owEH7nV1h5ilUT2XEukwaJtrs99uhBb8SDyxLWNCTUcdCuEL@dTgiwKcXReI5v5hvH47lcye787vdWLZaFNqg00qgJmkPYqYzKnIHW8rF0SqOnchF3ltWvDPBJJssS3UiVo3UHoX10X7wq1B1aAGYPjVb5bDRGUs9KvEtFLe60yidGFblzuTeeNwWkUX2UJtuy21@vpEY6saw4LbRdO6YHJ1pmytgWbZaF8fqAVj3TQgGpAZUb9DAaJ2tGQuITlxFXEJeTKCSCE8YEiXxQIeEeIzz0QXPQnHghA6njgniBICwCh/EANkF3Lmw@ZeAy2CKgCQMOPTwBlg8s4AoSUAoc1I@gscsFZILinIig7u1FgnN/Q1TCg1h1u30aY5XalTP9U8mstK@LfOaYorkX@2GkxsTFGOtniXXx@e3wdvDl082bV/63r9dXry9fBN7P7x/evwz5j4/vIlcwajmTe6kHxlY4rmuQFW/01FQ6RzrebOOTuTTDdoaNKlJ7hyNkMdp8dC@MPfktm7GjNKvt/4se6s4wUGaRduM2FT3b4Gi3SQ@Roz6hPTkPY/8JpWdj7OnEp5TnfhOSdjnYWcilnWIHXuWFnNzbw8fSTOGaK9PrLWG@JstxPZFNZ7P9Cw "Java (JDK) – Try It Online")
## Credits
* -3 bytes saved thanks to @Jeutnarg.
* -6 bytes thanks to @ceilingcat
[Answer]
# [Jelly](https://github.com/DennisMitchell/jelly), 67 bytes
```
ŒrḌṣ7ṣ€3ṣ€€1’H_4F€€ḅ3i@€€“ṗƙ⁶}zyȮẓŀȯ¦CFæ¢+ı(¥5ç1®¬ȷ4MÑÆ£Ç)×DGL‘ịØBK
```
[Try it online!](https://tio.run/##y0rNyan8///opKKHO3oe7lxsDsSPmtYYQyggMnzUMNMj3sQNwnu4o9U40wHCftQw5@HO6cdmPmrcVltVeWLdw12TjzacWH9ombPb4WWHFmkf2ahxaKnp4eWGh9YdWnNiu4nv4YmH2w4tPtyueXi6i7vPo4YZD3d3H57h5P3fBWja4XYgEfn/fzQXp6EBBBpAsaEhgo/ENjSEYwhA5qPKwvRhMcHAUAdiI7IZBlhNhrORTYOJwGmYeWguMDTEwAYGWMUMEW6Em4XNRwaGXLEA "Jelly – Try It Online")
[Answer]
# JavaScript (ES6), ~~104~~ ~~102~~ ~~101~~ 99 bytes
```
s=>s.split`000`.map(n=>" _T__9VEFO0K7MX_CGS__LU1RYIJ845__Z_B_D6QP_3__AHNW2"[n*1741%8360%51]).join``
```
### Test cases
```
let f =
s=>s.split`000`.map(n=>" _T__9VEFO0K7MX_CGS__LU1RYIJ845__Z_B_D6QP_3__AHNW2"[n*1741%8360%51]).join``
console.log(f("101010100010001011101010001011101010001110111011100000001011101110001110111011100010111010001011101010001110101"))
console.log(f("10100000001011100011101110000000101110000000101011101000101000101010001010101"))
console.log(f("1010111011101110001110111011101110111000101110111011101110001110111010101"))
console.log(f("101010001110111011100010101"))
```
### How?
Because converting from binary to decimal costs bytes, we use a hash function which works directly on binary blocks interpreted in base 10.
**Example**
```
dot dash dot dot = 101110101
101110101 * 1741 = 176032685841
176032685841 % 8360 = 3081
3081 % 51 = 21
--> The 21st character in the lookup table is 'L' (0-indexed).
```
[Answer]
# [Retina](https://github.com/m-ender/retina), ~~144~~ ~~138~~ ~~130~~ 103 bytes
```
T`d`@#
^|@@@
 @?#
E
{T`L#@`R6_BI_Z5S1C_GD8__\L\HNF3P__7_`\w@#
T`589B-INPRSZ#@`490XYKT2\OVAMJWUQ_`\w##
```
[Try it online!](https://tio.run/##K0otycxL/K@q4Z7wPyQhJcFBmSuuxsHBgUuBS8HBXpnLlas6JMFH2SEhyCzeyTM@yjTY0Dne3cUiPj7GJ8bDz804ID7ePD4hphyoMSTB1MLSSdfTLyAoOAqoxcTSICLSO8Qoxj/M0dcrPDQQpE5Z@f9/QwMINIBiQ0MEH4ltaAjHEIDMR5WF6cNigoEhF4SHMMEAq7lwNrJZMBE4DTENzXZDQwxsYIBVzBDhPqhJ2PxiYAgA "Retina – Try It Online") Link includes test cases. Explanation:
```
T`d`@#
```
Change the binary digits to other characters because 0 and 1 are valid outputs.
```
^|@@@
 
```
Insert a space before every character and two spaces between words.
```
 @?#
E
```
Assume that all characters are Es.
```
{T`L#@`R6_BI_Z5S1C_GD8__\L\HNF3P__7_`\w@#
```
Translate all letters assuming that they will be followed by a dot. For instance, if we have an E, and we see a second dot (we consumed the first when we inserted the E) then it translates to an I. For letters that can only be legally followed by a dash, they are translated with that assumption, and then the dash is consumed by the next stage. Other letters are deleted (keeping `L` costs a byte).
```
T`589B-INPRSZ#@`490XYKT2\OVAMJWUQ_`\w##
```
If it transpires that they were in fact followed by a dash, then fix up the mistranslations. This also consumes the dash when it was assumed by the previous stage. Both translations are repeated until all of the dots and dashes are consumed.
[Answer]
# [Perl 5](https://www.perl.org/), 241 + 1 (`-p`) = 242 bytes
```
%k=map{(23,469,1885,117,1,349,477,85,5,6007,471,373,119,29,1911,1501,7639,93,21,7,87,343,375,1879,7543,1909,489335,96119,22391,5495,1367,341,1877,7637,30581,122333)[$i++]=>$_}A..Z,0..9;map{$\.=$k{oct"0b$_"}for split/000/;$\.=$"}split/0{7}/}{
```
[Try it online!](https://tio.run/##bY7tSsQwEEVfRUoFZWfTmU6TybBU8AF8AT9YVBTKrrbs9l/Jqxsni6KChEDOmTuXTC@Hvc/5fNe/PU7LRcvQBQWK0QORAAF3Cp0ImPAQEMXIrLDNFVrLKhGQRwIJrKAMrT0hiq2yBa0oioJ4I1K0tqjMHjScClpWAt@pxTiUHSp5KWVG6KOxhZgv7@phtXror@ptunbuFtA53ZRf1/eur3fL@DxX@FRvq/Q6Hs6O036YG0RsNqd5lb7MIqlJS86Edujn4h/6Zf9z31TOxzjNw/h@zOsb70zk9fQJ "Perl 5 – Try It Online")
[Answer]
# PHP, 181+1 bytes
```
foreach(explode(_,strtr($argn. 0,[1110=>1,10=>0,"0000"=>_A,"00"=>_]))as$t)echo$t<A?~$t[-5]?(10+substr_count($t,0)*(1-2*$t[-5]))%10:__ETIANMSURWDKGOHVF_L_PJBXCYZQ[bindec("1$t")]:" ";
```
Run as pipe with `-nR` or [try it online](http://sandbox.onlinephpfunctions.com/code/f47aed535d352e741dfdeb01ea13e4ac6249dec4).
[Answer]
## [ES6](http://www.ecma-international.org/ecma-262/6.0/ "ES6"), 268 bytes
Uses ASCII encoding after mapping from a base36 representation of the morse to an index position. Not my best golf day, but it only took around 15 mins.
```
s=>s.split('00000').map(w=>String.fromCharCode.apply({},w.split('000').map(c=>"ahkn,225z,h9z,48n,11z,9h,1g5,5w5,nlh,2me5,,,,,,,,n,d1,1gd,39,1,9p,d9,2d,5,4mv,d3,ad,3b,t,1h3,15p,5w7,2l,l,7,2f,9j,af,1g7,1h1".split(',').indexOf(parseInt(c,2).toString(36))+48))).join(' ')
```
Easier to read (kinda):
```
s=>
s
.split('00000')
.map(w=>
	String.fromCharCode.apply({},
		w.split('000')
			.map(c=>
				"ahkn,225z,h9z,48n,11z,9h,1g5,5w5,nlh,2me5,,,,,,,,n,d1,1gd,39,1,9p,d9,2d,5,4mv,d3,ad,3b,t,1h3,15p,5w7,2l,l,7,2f,9j,af,1g7,1h1"
				.split(',')
				.indexOf(
					parseInt(c,2).toString(36)
				)+48)
			)
	).join(' ')
```
[Answer]
# [Wolfram Language (Mathematica)](https://www.wolfram.com/wolframscript/), 288 bytes
Thought about reading in the data as binary from a file but that gets hard to explain. Base 36 seemed like a good compromise way to store the data efficiently lexically.
Takes a string of 0's and 1's as input. Does a series of replacements, starting with the runs of 7 zeros, then the runs of 3, then the longest binary letters down to the shortest. Order of replacement is important.
```
StringReplace[#,Thread@Rule[Join[{"0000000","000"},#~FromDigits~36~IntegerString~2&/@StringSplit@"ahkn 2me5 225z nlh h9z 5w7 5w5 5tj 4mv 48n 1h3 1h1 1gd 1g7 1g5 15p 11z d9 d3 d1 af ad 9p 9j 9h 3b 39 2l 2f 2d t n l 7 5 1"],Insert[Characters@" 09182Q7YJ3OZCX6P4GKBWLFV5MDRUHNASTIE","",2]]]&
```
[Try it online!](https://tio.run/##bY9bS8NAFIT/yrCFPgXMbrpt8yBEW6utt9rWa8jD2myyqck2pKtCxfz1GImXCp7DBzMczsBkwiiZCZMsRRXtV3NTJDqeyTwVS@m3rIUqpAi92XMq/ck60f4bsZsh1qci71arHBXrbJjEidmUTrccayNjWTRJJWvveY2c52liPCLUkwbLJAdjfAudKih3C/7aq@HgZoVO9oJOX4Mqp4aCxmFNr4aD8hyUbhG6CB2EFCKCCOHmcFdwFZxHOC5YChaBhTDQSFFHg5LAGuuNLIw/UKIQSyOLjUdgu7TPrnr3E@fyYXDXnXaOTw9vz0Y3/Hw4uz65OJgvxkd1V2KxIAja1bSuYrzII9Ru1v6C0l@/oyn9oZld//f6/fdPgk1J9QE "Wolfram Language (Mathematica) – Try It Online")
[Answer]
## [Perl 5](https://www.perl.org/), 195 bytes
**194 bytes code + 1 for `-p`.**
```
%h=map{$_,(A..Z,0..9)[$i++]}unpack"S26I2S7I","\xd5]u]\xddUw\xd7uw
w\xdd\xd7
]WWwWw
uwwwwwWwWUU\xd5
uw\xdd\xdd";s/0{7}/ /g;s/(\d+?)(000|\b)/$h{oct"0b$1"}/ge
```
I couldn't get this working with just a standard packed binary string, I had to escape the higher-byte chars otherwise I'd be on 171, if anyone knows what I've missed, or why it's breaking that'd be great!
[Try it online!](https://tio.run/##bY9Ra4MwFIVvHkTYe@mTMIIDRac3BSejlLHHPhcRNmW0tbSyrcpauQPnX5/V2arbTLjknHOTL0m6@XhzSjWe4bS82c3el2muvpjao2U9mWhZ9/qzGhtGWGT7dLl@5YvJ3XyycOfc5GMIPiOHhXIGDEJWmYh5IAGNK@myjBEoQHKdS3WihDACGXzwGTFfJiWTiWQgYkA@jXzJY16921Eyqg/9AIFPDzbmbmFf29tKakFkPOgaIn4FK91Wd3myPnJcqYIX9nZTlgKbiecSovM9LURbzej7393LuQECiqvGdQQc5La6z7ok7drQ/twuxL9CHMxE974zaegvVe87SY9xsj@Ut@kJ "Perl 5 – Try It Online")
### Explanation
The binary string is a [`pack`ed](http://perldoc.perl.org/perlpacktut.html) list of the numbers that relate to the morse characters (`101011101` - `349` for `F` etc) and this is zipped with the ranges `A..Z,0..9` and used as a lookup. The `s///` expressions replace all runs of seven `0`s with space and then all runs of digits, separated with three `0`s or word boundaries `\b`, with their corresponding key from the `%h` hash.
]