It would seem that I have far too much time on my hands. After the post about a Star Trek “test”, I started wondering if there could be any data to back it up and… well here we go:
Those Old Scientists
Name |
Total Lines |
Percentage of Lines |
KIRK |
8257 |
32.89 |
SPOCK |
3985 |
15.87 |
MCCOY |
2334 |
9.3 |
SCOTT |
912 |
3.63 |
SULU |
634 |
2.53 |
UHURA |
575 |
2.29 |
CHEKOV |
417 |
1.66 |
The Next Generation
Name |
Total Lines |
Percentage of Lines |
PICARD |
11175 |
20.16 |
RIKER |
6453 |
11.64 |
DATA |
5599 |
10.1 |
LAFORGE |
3843 |
6.93 |
WORF |
3402 |
6.14 |
TROI |
2992 |
5.4 |
CRUSHER |
2833 |
5.11 |
WESLEY |
1285 |
2.32 |
Deep Space Nine
Name |
Total Lines |
Percentage of Lines |
SISKO |
8073 |
13.0 |
KIRA |
5112 |
8.23 |
BASHIR |
4836 |
7.79 |
O’BRIEN |
4540 |
7.31 |
ODO |
4509 |
7.26 |
QUARK |
4331 |
6.98 |
DAX |
3559 |
5.73 |
WORF |
1976 |
3.18 |
JAKE |
1434 |
2.31 |
GARAK |
1420 |
2.29 |
NOG |
1247 |
2.01 |
ROM |
1172 |
1.89 |
DUKAT |
1091 |
1.76 |
EZRI |
953 |
1.53 |
Voyager
Name |
Total Lines |
Percentage of Lines |
JANEWAY |
10238 |
17.7 |
CHAKOTAY |
5066 |
8.76 |
EMH |
4823 |
8.34 |
PARIS |
4416 |
7.63 |
TUVOK |
3993 |
6.9 |
KIM |
3801 |
6.57 |
TORRES |
3733 |
6.45 |
SEVEN |
3527 |
6.1 |
NEELIX |
2887 |
4.99 |
KES |
1189 |
2.06 |
Enterprise
Name |
Total Lines |
Percentage of Lines |
ARCHER |
6959 |
24.52 |
T’POL |
3715 |
13.09 |
TUCKER |
3610 |
12.72 |
REED |
2083 |
7.34 |
PHLOX |
1621 |
5.71 |
HOSHI |
1313 |
4.63 |
TRAVIS |
1087 |
3.83 |
SHRAN |
358 |
1.26 |
Discovery
Important Note: As the source material is incomplete for Discovery, the following table only includes line counts from seasons 1 and 4 along with a single episode of season 2.
Name |
Total Lines |
Percentage of Lines |
BURNHAM |
2162 |
22.92 |
SARU |
773 |
8.2 |
BOOK |
586 |
6.21 |
STAMETS |
513 |
5.44 |
TILLY |
488 |
5.17 |
LORCA |
471 |
4.99 |
TARKA |
313 |
3.32 |
TYLER |
300 |
3.18 |
GEORGIOU |
279 |
2.96 |
CULBER |
267 |
2.83 |
RILLAK |
205 |
2.17 |
DETMER |
186 |
1.97 |
OWOSEKUN |
169 |
1.79 |
ADIRA |
154 |
1.63 |
COMPUTER |
152 |
1.61 |
ZORA |
151 |
1.6 |
VANCE |
101 |
1.07 |
CORNWELL |
101 |
1.07 |
SAREK |
100 |
1.06 |
T’RINA |
96 |
1.02 |
If anyone is interested, here’s the (rather hurried, don’t judge me) Python used:
<span style="font-style:italic;color:#969896;">#!/usr/bin/env python
</span><span style="color:#323232;">
</span><span style="font-style:italic;color:#969896;">#
</span><span style="font-style:italic;color:#969896;"># This script assumes that you've already downloaded all the episode lines from
</span><span style="font-style:italic;color:#969896;"># the fantastic chakoteya.net:
</span><span style="font-style:italic;color:#969896;">#
</span><span style="font-style:italic;color:#969896;"># wget --accept=html,htm --relative --wait=2 --include-directories=/STDisco17/ http://www.chakoteya.net/STDisco17/episodes.html -m
</span><span style="font-style:italic;color:#969896;"># wget --accept=html,htm --relative --wait=2 --include-directories=/Enterprise/ http://www.chakoteya.net/Enterprise/episodes.htm -m
</span><span style="font-style:italic;color:#969896;"># wget --accept=html,htm --relative --wait=2 --include-directories=/Voyager/ http://www.chakoteya.net/Voyager/episode_listing.htm -m
</span><span style="font-style:italic;color:#969896;"># wget --accept=html,htm --relative --wait=2 --include-directories=/DS9/ http://www.chakoteya.net/DS9/episodes.htm -m
</span><span style="font-style:italic;color:#969896;"># wget --accept=html,htm --relative --wait=2 --include-directories=/NextGen/ http://www.chakoteya.net/NextGen/episodes.htm -m
</span><span style="font-style:italic;color:#969896;"># wget --accept=html,htm --relative --wait=2 --include-directories=/StarTrek/ http://www.chakoteya.net/StarTrek/episodes.htm -m
</span><span style="font-style:italic;color:#969896;">#
</span><span style="font-style:italic;color:#969896;"># Then you'll probably have to convert the following files to UTF-8 as they
</span><span style="font-style:italic;color:#969896;"># differ from the rest:
</span><span style="font-style:italic;color:#969896;">#
</span><span style="font-style:italic;color:#969896;"># * Voyager/709.htm
</span><span style="font-style:italic;color:#969896;"># * Voyager/515.htm
</span><span style="font-style:italic;color:#969896;"># * Voyager/416.htm
</span><span style="font-style:italic;color:#969896;"># * Enterprise/41.htm
</span><span style="font-style:italic;color:#969896;">#
</span><span style="color:#323232;">
</span><span style="font-weight:bold;color:#a71d5d;">import </span><span style="color:#323232;">re
</span><span style="font-weight:bold;color:#a71d5d;">from </span><span style="color:#323232;">collections </span><span style="font-weight:bold;color:#a71d5d;">import </span><span style="color:#323232;">defaultdict
</span><span style="font-weight:bold;color:#a71d5d;">from </span><span style="color:#323232;">pathlib </span><span style="font-weight:bold;color:#a71d5d;">import </span><span style="color:#323232;">Path
</span><span style="color:#323232;">
</span><span style="color:#0086b3;">EPISODE_REGEX </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">re.compile(</span><span style="font-weight:bold;color:#a71d5d;">r</span><span style="color:#183691;">"</span><span style="font-weight:bold;color:#a71d5d;">^</span><span style="color:#0086b3;">d</span><span style="font-weight:bold;color:#a71d5d;">+</span><span style="color:#0086b3;">.</span><span style="color:#183691;">html</span><span style="font-weight:bold;color:#a71d5d;">?$</span><span style="color:#183691;">"</span><span style="color:#323232;">)
</span><span style="color:#0086b3;">LINE_REGEX </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">re.compile(</span><span style="font-weight:bold;color:#a71d5d;">r</span><span style="color:#183691;">"</span><span style="font-weight:bold;color:#a71d5d;">^</span><span style="color:#183691;">(?P<name></span><span style="color:#0086b3;">[A-Z']</span><span style="font-weight:bold;color:#a71d5d;">+</span><span style="color:#183691;">): "</span><span style="color:#323232;">)
</span><span style="color:#323232;">
</span><span style="color:#0086b3;">EPISODES </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">Path(</span><span style="color:#183691;">"www.chakoteya.net"</span><span style="color:#323232;">)
</span><span style="color:#0086b3;">DISCO </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#0086b3;">EPISODES </span><span style="font-weight:bold;color:#a71d5d;">/ </span><span style="color:#183691;">"STDisco17"
</span><span style="color:#0086b3;">ENT </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#0086b3;">EPISODES </span><span style="font-weight:bold;color:#a71d5d;">/ </span><span style="color:#183691;">"Enterprise"
</span><span style="color:#0086b3;">TNG </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#0086b3;">EPISODES </span><span style="font-weight:bold;color:#a71d5d;">/ </span><span style="color:#183691;">"NextGen"
</span><span style="color:#0086b3;">TOS </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#0086b3;">EPISODES </span><span style="font-weight:bold;color:#a71d5d;">/ </span><span style="color:#183691;">"StarTrek"
</span><span style="color:#323232;">DS9 </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#0086b3;">EPISODES </span><span style="font-weight:bold;color:#a71d5d;">/ </span><span style="color:#183691;">"DS9"
</span><span style="color:#0086b3;">VOY </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#0086b3;">EPISODES </span><span style="font-weight:bold;color:#a71d5d;">/ </span><span style="color:#183691;">"Voyager"
</span><span style="color:#323232;">
</span><span style="color:#0086b3;">NAMES </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">{
</span><span style="color:#323232;"> </span><span style="color:#0086b3;">TOS</span><span style="color:#323232;">.name: </span><span style="color:#183691;">"Those Old Scientists"</span><span style="color:#323232;">,
</span><span style="color:#323232;"> </span><span style="color:#0086b3;">TNG</span><span style="color:#323232;">.name: </span><span style="color:#183691;">"The Next Generation"</span><span style="color:#323232;">,
</span><span style="color:#323232;"> DS9.name: </span><span style="color:#183691;">"Deep Space Nine"</span><span style="color:#323232;">,
</span><span style="color:#323232;"> </span><span style="color:#0086b3;">VOY</span><span style="color:#323232;">.name: </span><span style="color:#183691;">"Voyager"</span><span style="color:#323232;">,
</span><span style="color:#323232;"> </span><span style="color:#0086b3;">ENT</span><span style="color:#323232;">.name: </span><span style="color:#183691;">"Enterprise"</span><span style="color:#323232;">,
</span><span style="color:#323232;"> </span><span style="color:#0086b3;">DISCO</span><span style="color:#323232;">.name: </span><span style="color:#183691;">"Discovery"</span><span style="color:#323232;">,
</span><span style="color:#323232;">}
</span><span style="color:#323232;">
</span><span style="color:#323232;">
</span><span style="font-weight:bold;color:#a71d5d;">class </span><span style="color:#0086b3;">CharacterLines</span><span style="color:#323232;">:
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#62a35c;">__init__</span><span style="color:#323232;">(self, path: Path) -> </span><span style="color:#0086b3;">None</span><span style="color:#323232;">:
</span><span style="color:#323232;"> self.path </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">path
</span><span style="color:#323232;"> self.line_count </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">defaultdict(</span><span style="color:#0086b3;">int</span><span style="color:#323232;">)
</span><span style="color:#323232;">
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#323232;">collect</span><span style="color:#323232;">(self) -> </span><span style="color:#0086b3;">None</span><span style="color:#323232;">:
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">for </span><span style="color:#323232;">episode </span><span style="font-weight:bold;color:#a71d5d;">in </span><span style="color:#323232;">self.path.glob(</span><span style="color:#183691;">"*.htm*"</span><span style="color:#323232;">):
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">if </span><span style="color:#323232;">EPISODE_REGEX.match(episode.name):
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">for </span><span style="color:#323232;">line </span><span style="font-weight:bold;color:#a71d5d;">in </span><span style="color:#323232;">episode.read_text().split(</span><span style="color:#183691;">"</span><span style="color:#0086b3;">n</span><span style="color:#183691;">"</span><span style="color:#323232;">):
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">if </span><span style="color:#323232;">m :</span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">LINE_REGEX.match(line):
</span><span style="color:#323232;"> self.line_count[m.group(</span><span style="color:#183691;">"name"</span><span style="color:#323232;">)] </span><span style="font-weight:bold;color:#a71d5d;">+= </span><span style="color:#0086b3;">1
</span><span style="color:#323232;">
</span><span style="color:#323232;"> @</span><span style="color:#62a35c;">property
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#323232;">as_tablular_data</span><span style="color:#323232;">(self) -> </span><span style="color:#0086b3;">tuple</span><span style="color:#323232;">[</span><span style="color:#0086b3;">tuple</span><span style="color:#323232;">[</span><span style="color:#0086b3;">str</span><span style="color:#323232;">, </span><span style="color:#0086b3;">int</span><span style="color:#323232;">, </span><span style="color:#0086b3;">float</span><span style="color:#323232;">], </span><span style="color:#0086b3;">...</span><span style="color:#323232;">]:
</span><span style="color:#323232;"> total </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#62a35c;">sum</span><span style="color:#323232;">(self.line_count.values())
</span><span style="color:#323232;"> r </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">[]
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">for </span><span style="color:#323232;">k, v </span><span style="font-weight:bold;color:#a71d5d;">in </span><span style="color:#323232;">self.line_count.items():
</span><span style="color:#323232;"> percentage </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#62a35c;">round</span><span style="color:#323232;">(v </span><span style="font-weight:bold;color:#a71d5d;">* </span><span style="color:#0086b3;">100 </span><span style="font-weight:bold;color:#a71d5d;">/ </span><span style="color:#323232;">total, </span><span style="color:#0086b3;">2</span><span style="color:#323232;">)
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">if </span><span style="color:#323232;">percentage </span><span style="font-weight:bold;color:#a71d5d;">> </span><span style="color:#0086b3;">1</span><span style="color:#323232;">:
</span><span style="color:#323232;"> r.append((</span><span style="color:#0086b3;">str</span><span style="color:#323232;">(k), v, percentage))
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">return </span><span style="color:#0086b3;">tuple</span><span style="color:#323232;">(</span><span style="color:#62a35c;">reversed</span><span style="color:#323232;">(</span><span style="color:#62a35c;">sorted</span><span style="color:#323232;">(r, key</span><span style="font-weight:bold;color:#a71d5d;">=lambda </span><span style="color:#323232;">_: _[</span><span style="color:#0086b3;">2</span><span style="color:#323232;">])))
</span><span style="color:#323232;">
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">def </span><span style="font-weight:bold;color:#323232;">render</span><span style="color:#323232;">(self) -> </span><span style="color:#0086b3;">None</span><span style="color:#323232;">:
</span><span style="color:#323232;"> </span><span style="color:#62a35c;">print</span><span style="color:#323232;">(</span><span style="font-weight:bold;color:#a71d5d;">f</span><span style="color:#183691;">"</span><span style="color:#0086b3;">nn</span><span style="color:#183691;"># </span><span style="color:#323232;">{</span><span style="color:#0086b3;">NAMES</span><span style="color:#323232;">[self.path.name]}</span><span style="color:#0086b3;">n</span><span style="color:#183691;">"</span><span style="color:#323232;">)
</span><span style="color:#323232;"> </span><span style="color:#62a35c;">print</span><span style="color:#323232;">(</span><span style="color:#183691;">"| Name | Total Lines | Percentage of Lines |"</span><span style="color:#323232;">)
</span><span style="color:#323232;"> </span><span style="color:#62a35c;">print</span><span style="color:#323232;">(</span><span style="color:#183691;">"| ---------------- | :---------: | ------------------: |"</span><span style="color:#323232;">)
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">for </span><span style="color:#323232;">character, total, pct </span><span style="font-weight:bold;color:#a71d5d;">in </span><span style="color:#323232;">self.as_tablular_data:
</span><span style="color:#323232;"> </span><span style="color:#62a35c;">print</span><span style="color:#323232;">(</span><span style="font-weight:bold;color:#a71d5d;">f</span><span style="color:#183691;">"| </span><span style="color:#323232;">{character</span><span style="color:#0086b3;">:16</span><span style="color:#323232;">}</span><span style="color:#183691;"> | </span><span style="color:#323232;">{total</span><span style="color:#0086b3;">:11</span><span style="color:#323232;">}</span><span style="color:#183691;"> | </span><span style="color:#323232;">{pct</span><span style="color:#0086b3;">:19</span><span style="color:#323232;">}</span><span style="color:#183691;"> |"</span><span style="color:#323232;">)
</span><span style="color:#323232;">
</span><span style="color:#323232;">
</span><span style="font-weight:bold;color:#a71d5d;">if </span><span style="color:#323232;">__name__ </span><span style="font-weight:bold;color:#a71d5d;">== </span><span style="color:#183691;">"__main__"</span><span style="color:#323232;">:
</span><span style="color:#323232;"> </span><span style="font-weight:bold;color:#a71d5d;">for </span><span style="color:#323232;">series </span><span style="font-weight:bold;color:#a71d5d;">in </span><span style="color:#323232;">(</span><span style="color:#0086b3;">TOS</span><span style="color:#323232;">, </span><span style="color:#0086b3;">TNG</span><span style="color:#323232;">, DS9, </span><span style="color:#0086b3;">VOY</span><span style="color:#323232;">, </span><span style="color:#0086b3;">ENT</span><span style="color:#323232;">, </span><span style="color:#0086b3;">DISCO</span><span style="color:#323232;">):
</span><span style="color:#323232;"> counter </span><span style="font-weight:bold;color:#a71d5d;">= </span><span style="color:#323232;">CharacterLines(series)
</span><span style="color:#323232;"> counter.collect()
</span><span style="color:#323232;"> counter.render()
</span>