Download FreeLing User Manual
Transcript
46
CHAPTER 4. USING THE LIBRARY FROM YOUR OWN APPLICATION
// for each word in sentence
for (w=s->begin(); w!=s->end(); w++) {
// print word form, with PoS and lemma chosen by the tagger
cout<<" <WORD form=\""<<w->get_form();
cout<<"\" lemma=\""<<w->get_lemma();
cout<<"\" pos=\""<<w->get_parole();
cout<<"\">"<<endl;
// for each possible analysis in word, output lemma, parole and probability
for (a=w->analysis_begin(); a!=w->analysis_end(); ++a) {
// print analysis info
cout<<"
<ANALYSIS lemma=\""<<a->get_lemma();
cout<<"\" pos=\""<<a->get_parole();
cout<<"\" prob=\""<<a->get_prob();
cout<<"\"/>"<<endl;
}
// close word XML tag after list of analysis
cout<<"</WORD>"<<endl;
}
// close sentence XML tag
cout<<"</SENT>"<<endl;
}
}
The above sample program may be found in /src/main/simple examples/sample.cc in
FreeLing tarball.
Once you have compiled and installed FreeLing, you can build this sample program (or any
other you may want to write) with the command:
g++ -o sample sample.cc -lmorfo -ldb cxx -lpcre -lomlet -fries
Check the README file in the directory to learn more about compiling and using the sample
programs.
Option -lmorfo links with libmorfo library, which is the final result of the FreeLing compilation
process. The oher options refer to other libraries required by FreeLing.
You may have to add some -I and/or -L options to the compilation command depending on
where the headers and code of required libraries are located. For instance, if you installed some
of the libraries in /usr/local/mylib instead of the default place /usr/local, you’ll have to add
the options -I/usr/local/mylib/include -L/usr/local/mylib/lib to the command above.