forked from TALP-UPC/FreeLing
-
Notifications
You must be signed in to change notification settings - Fork 0
/
INSTALL.windows
265 lines (183 loc) · 10.9 KB
/
INSTALL.windows
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
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
COMPILING FREELING IN Ms-Windows
================================
This file describes how to build FreeLing from source using MS Visual Studio.
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 MSVC (MS Visual Studio, with C++ compiler)
2.- Install CMake (3.7 or newer) using installer available at https://cmake.org/download/
3.- Decide where will you install FreeLing (e.g. C:\FreeLing, C:\Program Files\FreeLing, etc)
and create this folder.
Anything we install in this README will go under this folder.
From now on, we will refer to this folder as %FLINSTALL%
4.- Find out which version of MSVC you are using, and which is the identifier that
CMake uses for it. For example, MSVC 2015 is "Visual Studio 14 2015", and
MSVC 2017 is "Visual Studio 15 2017".
Also, find out whether your system is 32 or 64 bits. Most modern windows are 64bits,
but you can check that in "Control Panel" -> "System & Security" -> "System" and look
for "System type".
INSTALL DEPENDENCIES
====================
5.- Install ZLIB
a.- Download zlib source from http://www.zlib.net/
b.- Unzip the source file
c.- From the start menu, open a "Visual Studio x64 Native Tools Command Prompt"
(or "x86" if your system is 32 bits)
d.- change to the folder where you unzipped the source:
e.- Execute:
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=%FLINSTALL%\dependencies\zlib -G "NMake Makefiles"
nmake install
6.- Install Boost and ICU
The easiest way to install these dependencies is to get precompiled binary packages.
a) Get boost binaries from: https://www.npcglib.org/~stathis/blog/precompiled-boost/
Select a package that matches your MSVC version (2014, 2015, ...) and architecture (32/64 bits)
b) Uncompress boost package in %FLINSTALL%\dependencies
c) Each boost binary package has associated an ICU version, which is mentioned in the
rightmost column of the table ("Notes").
Follow the link to the associated ICU version, and download the package.
Make sure you are getting the right version (you may need to go
to "past builds" page https://www.npcglib.org/~stathis/blog/precompiled-icu-past/)
Also, make sure the package matches your MSVC version and architecture.
d) Uncompress icu package in %FLINSTALL%\dependencies.
The content of your %FLINSTALL% folder should look like (version numbers may differ):
%FLINSTALL%\dependencies\zlib
\boost64-1.61.0-vs2015
\icu-57.1-vs2015
You can keep these names or change them to "boost" and "icu".
(From now on we will assume you changed them, so if you keep the full names, you'll need
to change some paths in the commands described in step 7 below).
Now your installation folder looks like:
%FLINSTALL%\dependencies\zlib
\boost
\icu
BUILD FREELING
==============
7.- Compile FreeLing
a.- Download FreeLing source zipfile from GitHub (or clone git repository)
b.- Unzip the source file
c.- Open a "Visual Studio x64 Native Tools Command Prompt" from the start menu
d.- Change to the folder where you unzipped the source
e.- Execute
mkdir build
cd build
cmake .. -DCMAKE_INSTALL_PREFIX=%FLINSTALL%\freeling -DZLIB_INCLUDE_DIR=%FLINSTALL%\dependencies\zlib\include -DZLIB_LIBRARY=%FLINSTALL%\dependencies\zlib\lib\zlibd.lib -DBOOST_ROOT=%FLINSTALL%\dependencies\boost -DICU_ROOT=%FLINSTALL%\dependencies\icu -G "NMake Makefiles"
nmake install
With this, you are done. Your %FLINSTALL% folder should look like:
%FLINSTALL%\dependencies\zlib
| \boost
| \icu
\freeling\bin
\include
\lib
\share
If you want a clean re-install, you can delete folder %FLINSTALL%\freeling,
and run again "nmake install" 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)
8.- Execute FreeLing
a.- Execute "analyze.bat" file:
%FLINSTALL%\freeling\bin\analyze.bat -f en.cfg < myfile.txt
"analyze.bat" behaves just the Linux "analyze" script. 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-Z. Take into account
windows command prompt is not UTF8, so you will find problems if you use non-ascii
characters.
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
PYTHON
------
If you built the Python API (steps A1, A2, A3), you'll find
in %FLINSTALL%/share/freeling/APIs/python 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.lib The actual API DLL, bridging between Python and C++.
_pyfreeling.pyd They both must be in the same folder than your program
or in a folder included in %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 DLLs, you need to set the 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):
set PATH=%PATH%;%FLINSTALL%\freeling\bin;%FLINSTALL%\dependencies\boost\lib;%FLINSTALL%\dependencies\zlib\bin;%FLINSTALL%\dependencies\icu\bin64;
* If you get "FREELINGDIR not defined", you need to set the location where
FreeLing was installed:
set FREELINGDIR=%FLINSTALL%\freeling
(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 Python API (steps A1, A2, A3), 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.lib The actual API DLL, bridging between Java and C++.
Jfreeling.dll They both must be in the same folder than your program
or in a folder included in %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 the 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):
set PATH=%PATH%;%FLINSTALL%\freeling\bin;%FLINSTALL%\dependencies\boost\lib;%FLINSTALL%\dependencies\zlib\bin;%FLINSTALL%\dependencies\icu\bin64;
* If you get "FREELINGDIR not defined", you need to set the location where
FreeLing was installed:
set FREELINGDIR=%FLINSTALL%\freeling
(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
============
** Installing dependencies in different folders
You can install zlib, boost, and icu anywhere (that is, they don't HAVE to
be in %FLINSTALL%\dependencies).
If you install them somewhere else, you just need to set the right paths for
variables ZLIB_INCLUDE_DIR, ZLIB_LIBRARY, BOOST_ROOT, and ICU_ROOT in the "cmake"
command in step 7, and paths in step 9 if you are using an API.
If you plan to use the "analyzer.bat" script, you'll need to edit it and adjust
the paths to those libraries too.
** APIs REQUIREMENTS
If you want to call FreeLing library from one of these languages, you need to:
A1.- Install SWIG.
Download swigwin.zip package from http://swig.org and uncompress it anywhere
you want (e.g. C:\Program Files\swigwin).
We will refer to this folder as %SWIGDIR% from now on
A2.- Install target language, including interfaces, that is:
* For Python: Install Python2 or Python3.
* For Java: Install Java Development Kit.
A3.- Add the following options to the "cmake" command
-DSWIG_DIR=%SWIGDIR%
-DSWIG_EXECUTABLE=%SWIGDIR%/swig.exe
-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.