R Aspell homebrew
working on a Macbook pro with OS 10.6. I've recently installed the package Aspell with the R package manager and it appears the install went just fine (no install errors). but when I try to use aspell I get the following error,
> aspell("love")
Error in getSpeller() :
No word lists can b开发者_如何学Pythone found for the language "en_US".
I also tried
> aspell("love", program = "/usr/local/bin/aspell")
I also installed aspell and hunspell seperately using GitHubs homebrew. When I did install aspell with homebrew I used
brew install aspell --lang=en_US
Is there somewhere I search on my mac to double check that the en_US language was installed? And if I do find that en_US is there, are there any suggestions as to why R is not finding it?
I'm a bit of a newbie when it comes to installation subtleties from sources files. Any help would be much appreciated.
As shown at the bottom of the aspell formula, you can use a --with-lang-#{name}
option. In my case, I wanted to install multiple dictionaries: de, en & pl. I did that with this command:
brew install aspell --with-lang-de --with-lang-en --with-lang-pl
To view all available install options use brew info aspell
(Thanks Andrew)
The --lang
option mentioned in this thread with --lang=de,en,pl
didn't work for me.
A lot of time has gone by, but I recently had the same problem and the fix was:
brew remove aspell
brew install aspell --lang=en
I should have paid more careful attention when this flew by in the original brew install:
Dictionaries are not automatically installed, please specify the languages for which you want dictionaries to be installed with the --lang option, e.g: % brew install aspell --lang=en,es
For the following languages aspell dictionaries are available: af, am, ar, ast, az, be, bg, bn, br, ca, cs, csb, cy, da, de, de_alt, el, en, eo, es, et, fa, fi, fo, fr, fy, ga, gd, gl, grc, gu, gv, he, hi, hil, hr, hsb, hu, hy, ia, id, is, it, kn, ku, ky, la, lt, lv, mg, mi, mk, ml, mn, mr, ms, mt, nb, nds, nl, nn, ny, or, pa, pl, pt_BR, pt_PT, qu, ro, ru, rw, sc, sk, sl, sr, sv, sw, ta, te, tet, tk, tl, tn, tr, uk, uz, vi, wa, yi, zu
I don't understand what you are doing. aspell
is a function in the utils package and is, therefore, loaded by default when R is started up. The first argument to aspell is a file name, not a text vector. You may need to install a dictionary that the aspell function can access. But on my Mac I already have several versions installed (and may need to do some cleaning.) The Omegahat repository also has one that is tested with R. The interface with Aspell will probably be attempting to select the correct language. You can see what R thinks is the correct language with sessionInfo() and look at your LOCALE settings. You can find the location of your Aspell installation with Terminal.app by entering locate aspell
at the command prompt.
This is a modification of the example in help(aspell) that spell-checks t*.dat files:
files <- Sys.glob("~/t*.dat")
res <- aspell(files)
str(res)
length(res$File)
#[1] 309 # so I probably should have been more narrow than asking for .dat files beginning with "t".
As a note, aspell()
works with factors but not character vectors. This won't help til after you have Aspell (or another spell checker) installed, but afterwards if you want to use aspell()
on data in R (instead of just working on files), make sure it's properly formatted.
Here's an example:
> str1 <- "This is a string with a mispeled word"
> str1 <- as.character(str1)
> aspell(str1)
Error in file(con, "r") : cannot open the connection
In addition: Warning message:
In file(con, "r") :
cannot open file 'This is a string with a mispeled word': No such file or directory
> str1 <- "This is a string with a mispelled word"
> str1 <- as.factor(str1)
> results1 <- aspell(str1)
> results1
mispelled
<unknown>:1:25
精彩评论