-
Notifications
You must be signed in to change notification settings - Fork 0
/
write_preinstalled_cmudict.R
34 lines (28 loc) · 861 Bytes
/
write_preinstalled_cmudict.R
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
31
32
33
34
## This script saves the pre-packaged version of cmudict.
## It is not called in master.R
## Before running this, run cmudict_downloader.R and cmudict_formatter.R
require(magrittr)
require(readr)
# Import misc. functions
source(file = "misc_functions.R")
# Import dictionary downloader
source(file = "cmudict_downloader.R")
# If user.replacements exists, remove it
if (exists("user.replacements")) {
rm(user.replacements)
}
# Set user.replacements to "preinstalled" and formatter will avoid
# asking about replacements.
user.replacements <- "preinstalled"
# Import CMU formatter
if (.Platform$OS.type == "windows") {
source.utf8(f = "cmudict_formatter.R")
} else{
source(file = "cmudict_formatter.R")
}
# Write the downloaded and formatted dictionary to a csv file
write_csv(
cmudict_dld,
path = "cmudict_preinstalled.csv",
col_names = TRUE
)