forked from TALP-UPC/FreeLing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL.macosx
204 lines (133 loc) · 7.56 KB
/
INSTALL.macosx
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
COMPILING FREELING IN MacOS
===========================
This file describes how to build FreeLing from source in MacOS
Unless you have a special interest in compiling FreeLing, installing it from a binary package is recommended.
Following the procedure described here makes sense only in one of the following cases:
- You want to use a development FreeLing version for which there is no binary package yet.
- You want to modify or extend FreeLing.
PRELIMINARIES
=============
1.- Install development tools
xcode-select --install (and click "install command line tools")
2.- Install HomeBrew
Some needed tools and libraries can be easily installed using HomeBrew.
Go to https://brew.sh and follow the instructions there to install it.
3.- Install required HomeBrew packages
- Install CMake (3.8 or newer):
brew install cmake
- Install boost and icu libraries:
brew install boost --with-icu4c
4.- Decide where will you install FreeLing (e.g. /Users/myuser/freeling, /Users/myuser/programs/freeling)
and create this folder.
You can omit this, and FreeLing will be installed in the default location /usr/local
From this point on, we will refer to FreeLing installation folder as $FLINSTALL
BUILD FREELING
==============
4.- Compile FreeLing
a.- Download FreeLing source zipfile from GitHub (or clone git repository)
b.- Unzip the source file
c.- Change to the folder where you unzipped the source
d.- Execute
mkdir build
cd build
cmake ..
make install
This will install FreeLing in /usr/local. To change the destination directory,
add option -DCMAKE_INSTALL_PREFIX=$FLINSTALL to cmake command.
Note that cmake does not create an "uninstall" target. So, if you install in /usr/local,
you may need to selectively remove files if you want to uninstall FreeLing
If you installed in a custom folder and want a clean re-install, you can delete
folder $FLINSTALL, and run "make install" again from the "build" folder.
If you want a clean re-build, you can delete the "build" folder, and repeat the
whole procedure.
Available options that can be added to "cmake" command:
-DCMAKE_INSTALL_PREFIX=[path] Install FreeLing in given location (default: /usr/local)
-DTRACES=ON Build FreeLing with debugging traces (default: OFF)
-DWARNINGS=OFF Build FreeLing without warning messages (default: ON)
-DXPRESSIVE=ON Build FreeLing using boost::xpressive regexps instead of boost::regex (default: OFF)
-DJAVA_API=ON Build Java API (see "Observations" below before running cmake) (default: OFF)
-DPYTHON2_API=ON Build Python 2 API (see "Observations" below before running cmake) (default: OFF)
-DPYTHON3_API=ON Build Python 3 API (see "Observations" below before running cmake) (default: OFF)
5.- Execute FreeLing
a.- Execute "analyze" file:
$FLINSTALL/analyze -f en.cfg < myfile.txt
Check FreeLing manual (https://talp-upc.gitbooks.io/freeling-user-manual/),
section "Using the analyze script", to find out the parameters it accepts.
Note that the input text must be UTF8 encoded.
You can provide input from the terminal and end it with ctl-D
9.- Call FreeLing library from Python or Java (optional)
If you don't want to write Python or Java programs that call Freeling, you can
skip this section.
To be able to call FreeLing from Python or Java, you should ahve built it with
options -DPYTHON2_API, -DPYTHON3_API, or -DJAVA_API, depending on your target.
PYTHON
------
If you built the Python2 (or Python3) API, you'll find
in %FLINSTALL%/share/freeling/APIs/python2 (or %FLINSTALL%/share/freeling/APIs/python3)
the following files:
pyfreeling.py FreeLing python module, to be imported from your program.
Must be in the same folder than your program or in a folder
included in $PYTHONPATH
_pyfreeling.dylib The actual API DLL, bridging between Python and C++.
Must be in the same folder than your program or in a folder
included in $LD_LIBRARY_PATH
sample.py An example of a python program that calls FreeLing.
To run the example, do:
cd %FLINSTALL%/share/freeling/APIs/python
python sample.py < mytext.txt
* If you get "ImportError" about not found modules, you need to add to
$LD_LIBRARY_PATH the path where all the required libraries (freeling and
all its dependencies) are found, as well as the _pyfreeling.so API library
(you need to do this only once per session, or you can set it once
and forever in your system-wide configuration)
* If you get "FREELINGDIR not defined", you need to set the location where
FreeLing was installed:
set FREELINGDIR=$FLINSTALL
(this is because the example program "sample.py" checks that variable, it is
not a general requirement of the API)
JAVA
----
If you built the Java API, you'll find
in %FLINSTALL%/share/freeling/APIs/java the following files:
Jfreeling.jar FreeLing Java module, to be imported from your program.
Must be included in $CLASSPATH
Jfreeling.dylib The actual API DLL, bridging between Java and C++.
They both must be in the same folder than your program
or in a folder included in $LD_LIBRARY_PATH
Analyzer.java An example of a Java program that calls FreeLing.
To run the example, do:
cd %FLINSTALL%/share/freeling/APIs/java
javac Analyzer.java
java Analyzer < mytext.txt
* If you get "UnsatisfiedLinkError" about not found libraries, you need to
set $LD_LIBRARY_PATH so all the required libraries (freeling and all its dependencies)
are found (you need to do this only once per session, or you can set it once
and forever in your system-wide configuration):
* If you get "FREELINGDIR not defined", you need to set the location where
FreeLing was installed:
set FREELINGDIR=$FLINSTALL
(this is because the example program "Analyzer.java" checks that variable, it is
not a general requirement of the API)
* If you get memory-related errors (allocation error, array out of range, etc), it
may be that your JVM has to few memory for FreeLing. Try with -Xmx1G or more.
OBSERVATIONS
============
** APIs REQUIREMENTS
If you want to call FreeLing library from Python or Java, you need to install some
extra software before building FreeLing
A1.- Install SWIG:
brew install swig
A2.- Install target language, including interfaces, that is:
* For Python: Install Python2 or Python3.
Make sure you install also development headers
* For Java: Install Java Development Kit.
A3.- Add the following options to the "cmake" command
-DPYTHON2_API=ON (if you want to build Python 2 API. Not compatible with -DPYTHON3_API)
-DPYTHON3_API=ON (if you want to build Python 3 API. Not compatible with -DPYTHON2_API)
-DJAVA_API=ON (if you want to build Java API)
** Using Python2 instead of Python3
FreeLing uses UTF8 encoding to support multilinguality. Python3 is native
in UTF8, which provides a much smoother integration with FreeLing.
However, you can use FreeLing from Python2 too (though if you encounter
encoding problems, don't complain, we told you so...)
Just specify cmake option -DPYTHON2_API instead of -DPYTHON3_API.