Morphological Analysis

Among the features of CAMeL Tools, is the availability of a token analyzer. In the following example, we will analyze the first word of the basmalah from avrs1 above. Load the data as follows:

julia> using QuranTree

julia> crps, tnzl = load(QuranData());

julia> crpsdata = table(crps);

julia> tnzldata = table(tnzl);

julia> avrs1 = verses(tnzldata[1][1])[1]
"بِسْمِ ٱللَّهِ ٱلرَّحْمَٰنِ ٱلرَّحِيمِ"

julia> dediac(avrs1)
"بسم ٱلله ٱلرحمٰن ٱلرحيم"

To analyze the Morphological feature of the basmalah, run the following:

julia> using Pkg

julia> Pkg.add("PyCall")
  Resolving package versions...
No Changes to `~/.julia/packages/QuranTree/JFGph/docs/Project.toml`
No Changes to `~/.julia/packages/QuranTree/JFGph/docs/Manifest.toml`

julia> using PyCall

julia> using JuliaDB

julia> using PrettyTables

julia> @ptconf vcrop_mode=:middle tf=tf_compact

julia> @pyimport camel_tools.morphology.database as camel_database
ERROR: PyError (PyImport_ImportModule

The Python package camel_tools.morphology.database could not be imported by pyimport. Usually this means
that you did not install camel_tools.morphology.database in the Python version being used by PyCall.

PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package.  To install the camel_tools.morphology.database module, you can
use `pyimport_conda("camel_tools.morphology.database", PKG)`, where PKG is the Anaconda
package the contains the module camel_tools.morphology.database, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).

Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python.   As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.

) <class 'ModuleNotFoundError'>
ModuleNotFoundError("No module named 'camel_tools'")

julia> @pyimport camel_tools.morphology.analyzer as camel_analyzer
ERROR: PyError (PyImport_ImportModule

The Python package camel_tools.morphology.analyzer could not be imported by pyimport. Usually this means
that you did not install camel_tools.morphology.analyzer in the Python version being used by PyCall.

PyCall is currently configured to use the Julia-specific Python distribution
installed by the Conda.jl package.  To install the camel_tools.morphology.analyzer module, you can
use `pyimport_conda("camel_tools.morphology.analyzer", PKG)`, where PKG is the Anaconda
package the contains the module camel_tools.morphology.analyzer, or alternatively you can use the
Conda package directly (via `using Conda` followed by `Conda.add` etcetera).

Alternatively, if you want to use a different Python distribution on your
system, such as a system-wide Python (as opposed to the Julia-specific Python),
you can re-configure PyCall with that Python.   As explained in the PyCall
documentation, set ENV["PYTHON"] to the path/name of the python executable
you want to use, run Pkg.build("PyCall"), and re-launch Julia.

) <class 'ModuleNotFoundError'>
ModuleNotFoundError("No module named 'camel_tools'")

julia> db = camel_database.MorphologyDB.builtin_db()
ERROR: UndefVarError: camel_database not defined

julia> analyzer = camel_analyzer.Analyzer(db)
ERROR: UndefVarError: camel_analyzer not defined

julia> analyses = analyzer.analyze(split(avrs1)[1])
ERROR: UndefVarError: analyzer not defined

julia> tbl = table([(;Dict(Symbol.(keys(d)) .=> collect(values(d)))...) for d in analyses])
ERROR: UndefVarError: analyses not defined

julia> @pt tbl
ERROR: UndefVarError: tbl not defined
Note

You need to install JuliaDB.jl and PrettyTables.jl to successfully run the code.

using Pkg
Pkg.add("JuliaDB")
Pkg.add("PrettyTables")

The following is the table of the above output properly formatted in HTML.

Pkg.add("DataFrames")
Pkg.add("IterableTables")
Pkg.add("Latexify")
using DataFrames: DataFrame
using IterableTables
using Latexify

mdtable(DataFrame(tbl), latex=false)