-
Notifications
You must be signed in to change notification settings - Fork 72
/
1_getNames.fsx
31 lines (23 loc) · 897 Bytes
/
1_getNames.fsx
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
#load "packages/FsLab/FsLab.fsx"
#load "parseScripts.fs"
open FSharp.Data
open System
open System.IO
open StarWars.ParseScripts
// ===========================================================================
// Extract character names from the scripts
let allNames =
scriptUrls
|> List.mapi (fun episodeIdx (episode, url) ->
getCharactersByScene url
|> Array.concat)
|> Array.concat
|> filterClutterTerms
|> Array.countBy id
|> Seq.filter (snd >> (<) 1) // filter out characters that speak in only one scene
for (name, count) in allNames do printfn "%s - %d" name count
// Now follows a manual step - filter out names that are not actual names of characters
// such as "PILOT" or "GUARD"
// Print the selected character names
let characters = File.ReadAllLines(__SOURCE_DIRECTORY__ + "/data/characters.csv")
characters |> Array.sort |> Array.iter (printfn "%s")