Bangla text word cloud - jupyter-notebook

I wanted to take out the word cloud of Bengali text, But when it is being printed, the consonants of each word were being printed separately .
data = pd.read_csv('/content/gdrive/MyDrive/data.csv',encoding='UTF-8')
refined_sentence = " ".join(data)
regex = r"[\u0980-\u09FF]+"
wc = WordCloud(width=800, height=400, mode="RGBA",background_color=None, colormap="hsv",
stopwords = stopwords, font_path="kalpurush.ttf", regexp=regex).generate(refined_sentence)
plt.figure(figsize=(7, 7))
plt.imshow(wc, interpolation='none')
plt.axis("off")
plt.show()

I followed this comment and could solve the problem in Ubuntu eventually.
Step 1: !sudo apt-get install libfreetype6-dev libharfbuzz-dev libfribidi-dev gtk-doc-tools
Step 2: !wget -O raqm-0.7.0.tar.gz https://raw.githubusercontent.com/python-pillow/pillow-depends/master/raqm-0.7.0.tar.gz
Now the raqm-0.7.0.tar.gz file should be in your downloads section.
Step 3: !tar -xzvf raqm-0.7.0.tar.gz
Step 4: !cd raqm-0.7.0
Step 5: !./configure --prefix=/usr && make -j4 && sudo make -j4 install
Step 6: Now you just have to reinstall the Pillow library. Activate the correct environment. Then run the following commands:
python3 -m pip install --upgrade pip
python3 -m pip install --upgrade Pillow
That's it! Now you have a working Pillow library that can produce proper Bengali and other Indic fonts in the image.

Related

How to install R from tar gz file

I have R in 3.6.3 version and I want to download 4.0.0 version. I downloaded from https://cran.r-project.org/src/base/R-4/ tar gz file but I have no idea how can I install it. Could you please give me a command which can install this R version from tar gz file ?
Install R from Source on Linux
You can find a detailed description for a range of different Linux systems here.
In short, you will need to run the following chain of commands:
First to install dependencies. This will depend on your Linux distribution. For Linux Mint, you can do
sudo apt-get build-dep r-base
Then, specify your desired R version
export R_VERSION=4.2.1
In a folder of your choice, download the .tar.gz (For versions other than 4.X, you may need to adjust the link)
curl -O https://cran.rstudio.com/src/base/R-4/R-${R_VERSION}.tar.gz
tar -xzvf R-${R_VERSION}.tar.gz
cd R-${R_VERSION}
To build and install, run from the same shell
./configure \
--prefix=/opt/R/${R_VERSION} \
--enable-memory-profiling \
--enable-R-shlib \
--with-blas \
--with-lapack
make
sudo make install
In case the ./configure ... step does not work out, you may need to install the missing binaries individually by hand.
You can check the installation by running
/opt/R/${R_VERSION}/bin/R --version
and create a symlink
sudo ln -s /opt/R/${R_VERSION}/bin/R /usr/local/bin/R
sudo ln -s /opt/R/${R_VERSION}/bin/Rscript /usr/local/bin/Rscript
Done!
Your R installation will be in
/opt/R/${R_VERSION}

How to upgrade IRKernel in Ubuntu?

On Ubuntu 18.04 LTS, while working R in JupyterNotebook (without Anaconda), the IRKernel is reading the R version 3.4. For using some packages like cowplot it is necessary to have at least version 3.5.
Basically, two steps should be taken:
Update R. These and that answers were a guideline.
Update IRKernel. The offical IRKernel instructions for Linux were useful.
Next, is described the complete procedure
1. Add Key to server
sudo apt-key adv --keyserver keyserver.ubuntu.com --recv-keys E298A3A825C0D65DFD57CBB651716619E084DAB9
2. Add Entry to sources.list
echo 'deb https://cloud.r-project.org/bin/linux/ubuntu bionic-cran35/' | sudo tee -a /etc/apt/sources.list
Depending on the linux you're using you should change, for example, bionic by xenial or cosmic, check out https://cran.r-project.org/bin/linux/ubuntu/README.html
3. Update Programs
According to the instructions in the above link, we should do the following:
sudo apt-get update
sudo apt-get install r-base
sudo apt-get install r-base-dev
4. Update /.local/share/jupyter/kernels/ir
type R in the console and follow the next steps according to this link
# In the console
R
# Inside R
install.packages(c('repr', 'IRdisplay', 'IRkernel'), type = 'source')
getRversion() # to verify the new R version
IRKernel::installspec()
This should show the following message:
[InstallKernelSpec] Removing existing kernelspec in /home/user_name/.local/share/jupyter/kernels/ir
[InstallKernelSpec] Installed kernelspec ir in /home/user_name/.local/share/jupyter/kernels/ir
As a final remark, you should remove the older version of R, which you can find in ~/R/x86_64-pc-linux-gnu-library, where you will now have two directories with two different versions or R (remove the older one).

R studio not working on ubuntu 16.04

I converted to Ubuntu today, but have a problems launching R studio. I installed R through the command prompt like this:
gpg --keyserver keyserver.ubuntu.com --recv-key E084DAB9
sudo sh -c 'echo "deb http://cran.rstudio.com/bin/linux/ubuntu trusty/">> /etc/apt/sources.list'
gpg -a --export E084DAB9 | sudo apt-key add -
sudo apt-get update
sudo apt-get -y install r-base
I cheked if R was installed proper by typing R and then exiting by q(save="no").
I installed R studio through the command prompt by
sudo apt-get install gdebi-core
wget https://download2.rstudio.org/rstudio-server-0.99.902-amd64.deb
sudo gdebi rstudio-server-0.99.902-amd64.deb
But this doesn't work and i can't find the launch button or open R studio.
Afterwards i tried to remove it and install it through the website but doesn't work either. What should i do?
There is no lauch button -- you connect to port 8787 on the machine running RStudio Server.
In other words, type http://localhost:8787 in the address bar of your browser. You should see a login screen with the RStudio logo. This connects you to your RStudio Server.
If you want to run the Desktop version you need to install the other available .deb package.
For those on Ubuntu 16.10, or who prefer to use the desktop version of RStudio, you may wish to follow the solution posted by Mike Williamson reproduced below:
1) Get the latest R Studio Daily Build here, though note that it's not necessarily stable.
2) Install, chaning the name of the package to the one you downloaded - perhaps easiest if you go to your Downloads directory - and you'll probably find that there are missing packages:
$ sudo dpkg -i rstudio-1.0.124-amd64.deb
3) Download the missing packages (the lack of which causes the installation to fail):
$ wget http://ftp.ca.debian.org/debian/pool/main/g/gstreamer0.10/libgstreamer0.10-0_0.10.36-1.5_amd64.deb
$ wget http://ftp.ca.debian.org/debian/pool/main/g/gst-plugins-base0.10/libgstreamer-plugins-base0.10-0_0.10.36-2_amd64.deb
4) Install them:
$ sudo dpkg -i libgstreamer0.10-0_0.10.36-1.5_amd64.deb
$ sudo dpkg -i libgstreamer-plugins-base0.10-0_0.10.36-2_amd64.deb
5) Make sure they don't get over-written at the next software update:
$ sudo apt-mark hold libgstreamer-plugins-base0.10-0
$ sudo apt-mark hold libgstreamer0.10
6) Install RStudio (changing name to the version you downloaded):
sudo gdebi rstudio-1.1.5-amd64.deb
7) Launch RStudio:
rstudio

Docker - Rstudio - R old version running together

I'm working with docker since approximately a week and I don't understand some of the linking containers stuff.
I've downloaded from rocker, the latest images of Rstudio. It work nicely, everything is ok. I have one own made container with an old R version (let's say humm 3.1.0-1 for example). What I want to do is to use Rstudio from rocker with my own made R version. But this is where I don't understand. How it works ? Is it possible ? If I can do that that'll be awesome but I really don't understand how.
If someone have a solution, that'll be really great.
This is my dockerfile for my old R version :
#Get trusty version of ubuntu
FROM ubuntu:trusty
#We need to have https for cran
RUN apt-get -y update && apt-get -y install apt-transport-https
#We add the mirror directory to get older version packages
RUN echo "deb https://cloud.r-project.org/bin/linux/ubuntu trusty/" >> /etc/apt/sources.list
#We clean and get authentication key
RUN apt-get clean && gpg --keyserver hkp://keyserver.ubuntu.com:80 --recv-keys E084DAB9
#We add the key
RUN gpg -a --export E084DAB9 | apt-key add -
#We now update our lib
RUN apt-get -y update
# --> R PACKAGE INSTALLATION <--
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install r-base-core=3.1.0-1trusty0
RUN DEBIAN_FRONTEND=noninteractive apt-get -y --force-yes install r-doc-html=3.1.0-1trusty0
RUN DEBIAN_FRONTEND=noninteractive apt-get -y install r-base-dev=3.1.0-1trusty0
#Check version
RUN R --version
I used : docker build -t r-basev3-1-0-1 . to build it and that works fine. It's just the link between rstudio and my container that I can't figure it out how to do it.
Thank's in advance,
Regards
I don't think it's possible (or easy) to link RStudio in one container to R in another container, as containers are supposed to be isolated from each other. The easiest thing to do is probably to build your own r-base image by modifying this file https://github.com/rocker-org/rocker/blob/master/r-base/Dockerfile (just need to change the version part I think) and then build your own rstudio image based on this customized image by modifying files in this folder https://github.com/rocker-org/rocker/tree/master/rstudio (change the FROM part to your own customized image).

Unable to install R/rmr2 on AWS EMR

Having spent around a week trying to install R and rmr2 on AWS-EMR, I am turning to you all for a little help. My bootstrap script is successfully installing R 2.14.1-1~lennycran.0 (thanks to JD Long's blog). When I am trying to install rmr2 I am having the classic dependency problem. Seems I have to install packages like Rcpp, RJSONIO, bitops, digest and 5 more. Because only an older Rcpp works with R 2.14.1, I am downloading a named version and installing it. How old, I don't know - I randomly tried a few versions and 0.8.9 worked. I will make a few more hit-and-trials.
sudo curl -o Rcpp.tar.gz http://cran.us.r-project.org/src/contrib/Archive/Rcpp/Rcpp_0.8.9.tar.gz
sudo R CMD INSTALL Rcpp.tar.gz
Now I am supposed to install the rest of the dependencies (How?)
And eventually rmr2 would be installed. I am using the following script, which, of course fails -
sudo wget --no-check-certificate -o rmr2.tar.qz -S -T 10 -t 5 http://goo.gl/dvBric
sudo R CMD INSTALL rmr2.tar.gz
My question is -
What should be a simple bootstrap script for installing the rest of the dependencies ("RJSONIO", "bitops", "digest", "functional", "stringr", "plyr", "reshape2", "caTools")? Do I have to worry about compatibility of those packages as well?
Here is my complete bootstrap.sh code -
#!/bin/bash
#debian R upgrade
gpg --keyserver pgpkeys.mit.edu --recv-key 06F90DE5381BA480
gpg -a --export 06F90DE5381BA480 | sudo apt-key add -
echo "deb http://streaming.stat.iastate.edu/CRAN/bin/linux/debian lenny-cran/" | sudo tee -a /etc/apt/sources.list
sudo apt-get update
sudo apt-get -t lenny-cran install --yes --force-yes r-base r-base-dev
sudo curl -o rmr2.tar.gz http://goo.gl/dvBric
sudo R CMD INSTALL rmr2.tar.gz <<<< Does not go beyond this.
set -e
bucket=muxxx-bisxxx-bucket
path=input.tar.gz
wget -S -T 10 -t 5 http://$bucket.s3.amazonaws.com/$path
mkdir -p /home/hadoop/contents
tar -C /home/hadoop/contents -xzf input.tar.gz
export HADOOP_CMD=/home/hadoop/bin/hadoop
export HADOOP_STREAMING=/home/hadoop/contrib/streaming/hadoop_streaming.jar
/home/hadoop/bin/hadoop fs -mkdir /home/hadoop/contents
/home/hadoop/bin/hadoop fs -put /home/hadoop/contents/* /home/hadoop/contents/
I have not resolved my problem on hand but I got a direction. I added the following line of code in the bootstrap script after R 2.14.1 installation and before rmr2 installation -
sudo Rscript -e 'install.packages(c("rJava", "Rcpp", "RJSONIO", "bitops", "digest", "functional", "stringr", "plyr", "reshape2", "caTools"), repos="http://ftp.heanet.ie/mirrors/cran.r-project.org/")'
Currently the bootstrapping process breaks down at plyr, which I guess, is due to older version of Rcpp that I have.
I am closing this post.

Resources