LNK2019 - 在VS2017中使用Freeling

时间:2018-05-18 10:36:15

标签: c++ freeling

我正在尝试使用Freeling v4.1 - 这是一个自然语言处理库 - 在我的C ++程序中

此库取决于:

  • 提升
  • 的ZLib
  • ICU

所有已安装的

以下是Include目录:

C:\freeling\include
C:\freel\dependencies\boost
C:\freel\dependencies\zlib\include
C:\freel\dependencies\icu\include

这是图书馆目录:

C:\freeling\lib
C:\freel\dependencies\zlib\lib
C:\freel\dependencies\icu\lib
C:\freel\dependencies\boost\lib32-msvc-14.0

freeling4.cpp

// freeling4.cpp : Defines the entry point for the console application.

#include "stdafx.h"
#include "freeling.h"

#include <iostream>
#include <string>

int main(int argc, char **argv)
{
freeling::util::init_locale(L"default");

wstring lang = L"en";
if (argc > 1) lang = freeling::util::string2wstring(argv[1]);
// get installation path to use from arg2, or use /usr/local if not provided
wstring ipath = L"/usr/local";
if (argc > 2) ipath = freeling::util::string2wstring(argv[2]);

// path to language data
wstring lpath = ipath + L"/share/freeling/" + lang + L"/";

// create analyzers
freeling::tokenizer tk(lpath + L"tokenizer.dat");
freeling::splitter sp(lpath + L"splitter.dat");

// create the analyzer with the required set of maco_options
freeling::maco_options opt(lang);
// Provide files for morphological submodules. Note that it is not necessary
// to set files for modules that will not be used
opt.UserMapFile = L"";
opt.LocutionsFile = lpath + L"locucions.dat";
opt.AffixFile = lpath + L"afixos.dat";
opt.ProbabilityFile = lpath + L"probabilitats.dat";
opt.DictionaryFile = lpath + L"dicc.src";
opt.NPdataFile = lpath + L"np.dat";
opt.PunctuationFile = lpath + L"../common/punct.dat";

freeling::maco morfo(opt);

// then, (de)activate required modules
morfo.set_active_options(false,  // UserMap
    true,  // NumbersDetection,
    true,  // PunctuationDetection,
    true,  // DatesDetection,
    true,  // DictionarySearch,
    true,  // AffixAnalysis,
    false, // CompoundAnalysis,
    true,  // RetokContractions,
    true,  // MultiwordsDetection,
    true,  // NERecognition,
    false, // QuantitiesDetection,
    true); // ProbabilityAssignment

           // create a hmm tagger (with retokenization ability, and forced 
           // to choose only one tag per word)
freeling::hmm_tagger tagger(lpath + L"tagger.dat", true, FORCE_TAGGER);

// get all input text in a single string 
wstring text = L"";
wstring line;
while (getline(wcin, line))
    text = text + line + L"\n";


// tokenize input line into a list of words
list<freeling::word> lw = tk.tokenize(text);
// split list of words in sentences, return list of sentences
list<freeling::sentence> ls = sp.split(lw);

// perform morphosyntactic analysis and disambiguation
morfo.analyze(ls);
tagger.analyze(ls);

// do whatever is needed with processed sentences
// for each sentence in list
for (list<freeling::sentence>::const_iterator is = ls.begin(); is != ls.end(); ++is) {

    // for each word in sentence
    for (freeling::sentence::const_iterator w = is->begin(); w != is->end(); ++w) {

        // print word form
        wcout << L"word '" << w->get_form() << L"'" << endl;
        // print possible analysis in word, output lemma and tag
        wcout << L"  Possible analysis: {";
        for (freeling::word::const_iterator a = w->analysis_begin(); a != w->analysis_end(); ++a)
            wcout << L" (" << a->get_lemma() << L"," << a->get_tag() << L")";
        wcout << L" }" << endl;
        // print analysis selected by the tagger
        wcout << L"  Selected analysis: (" << w->get_lemma() << L", " << w->get_tag() << L")" << endl;

    }

    // sentence separator
    wcout << endl;
}

return 0;
}

我收到这些链接错误:

1>------ Build started: Project: freeling_4, Configuration: Debug Win32 ------
1>stdafx.cpp
1>freeling4.cpp
1>Unknown compiler version - please run the configure tests and report the results
1>c:\freeling\include\treeler\base\fidx.h(90): warning C4805: '|=': unsafe mix of type 'uint64_t' and type 'const bool' in operation
1>c:\freeling\include\treeler\srl\simple-parser.h(241): warning C4003: not enough actual parameters for macro 'max'
1>c:\freeling\include\treeler\srl\simple-parser.h(264): warning C4003: not enough actual parameters for macro 'max'
1>c:\freeling\include\treeler\srl\fidx-path.h(84): warning C4805: '|=': unsafe mix of type 'long' and type 'bool' in operation
1>freeling4.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: class freeling::analysis const * __thiscall std::_List_const_iterator<class std::_List_val<struct std::_List_simple_types<class freeling::analysis> > >::operator->(void)const " (__imp_??C?$_List_const_iterator@V?$_List_val@U?$_List_simple_types@Vanalysis@freeling@@@std@@@std@@@std@@QBEPBVanalysis@freeling@@XZ) referenced in function _main
1>freeling4.obj : error LNK2019: unresolved external symbol "__declspec(dllimport) public: __thiscall freeling::word::const_iterator::~const_iterator(void)" (__imp_??1const_iterator@word@freeling@@QAE@XZ) referenced in function _main
1>C:\FL\freeling_4\Debug\freeling_4.exe : fatal error LNK1120: 2 unresolved externals
1>Done building project "freeling_4.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========

1 个答案:

答案 0 :(得分:0)

某些FreeLing标头需要在Windows中使用特定的编译器选项。 请查看FreeLing手册: https://talp-upc.gitbooks.io/freeling-4-1-user-manual/content/installation/test-windows.html