diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..5f243a1 --- /dev/null +++ b/.gitignore @@ -0,0 +1,5 @@ +obj/ +build/ +build.*/ +.vscode/ +config.log \ No newline at end of file diff --git a/CMakeLists.txt b/CMakeLists.txt new file mode 100644 index 0000000..2987b4f --- /dev/null +++ b/CMakeLists.txt @@ -0,0 +1,210 @@ +cmake_minimum_required(VERSION 3.13) + +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/cmake") +list(APPEND CMAKE_MODULE_PATH "${CMAKE_CURRENT_LIST_DIR}/external/findwix/cmake/") + +project(crfpp VERSION 0.59 LANGUAGES C CXX) + +if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE) + if(CMAKE_SIZEOF_VOID_P MATCHES "8") + set(VCPKG_TARGET_TRIPLET "x64-windows-static" CACHE STRING "VCPKG_TARGET_TRIPLET" FORCE) + else() + set(VCPKG_TARGET_TRIPLET "x86-windows-static" CACHE STRING "VCPKG_TARGET_TRIPLET" FORCE) + endif() + set(CMAKE_TOOLCHAIN_FILE "$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake" CACHE STRING "CMAKE_TOOLCHAIN_FILE" FORCE) +endif() + +include(CheckIncludeFile) +include(CheckIncludeFiles) +include(CheckFunctionExists) +include(CheckSymbolExists) +include(CheckCSourceCompiles) +include(CheckCXXSourceCompiles) +include(FindLibM) + +set(CMAKE_LIBRARY_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_RUNTIME_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) +set(CMAKE_ARCHIVE_OUTPUT_DIRECTORY ${CMAKE_BINARY_DIR}/bin) + +# Generate 'compile_commands.json' for clang_complete +set(CMAKE_EXPORT_COMPILE_COMMANDS ON) + +set(CXX_STD 14 CACHE STRING "Set to 11, 14, 17 or 20 to enable C++11, C++14, C++17 or C++20 builds, respectively." FORCE) +set(C_STD 11 CACHE STRING "Set to 99 or 11 to enable C99 or C11 builds, respectively." FORCE) + +if("${CMAKE_CXX_COMPILER_ID}" STREQUAL "GNU" OR "${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + if("${CMAKE_CXX_COMPILER_ID}" MATCHES "Clang") + add_compile_options("-Wno-everything") + endif() +endif() + +add_compile_definitions(HAVE_CONFIG_H) + +if(WIN32) + add_compile_definitions(_CRT_SECURE_NO_DEPRECATE WIN32_LEAN_AND_MEAN _CRT_SECURE_NO_WARNINGS UNICODE _UNICODE HAVE_WINDOWS_H DLL_EXPORT) + add_compile_options("/utf-8" "/EHsc" "/GA" "/GL" "/Gy" "/Oi" "/Ob2" "/nologo" "/W3" "/wd4244") + add_link_options("/OPT:REF" "/OPT:ICF" "/LTCG" "/NXCOMPAT" "/DYNAMICBASE") + if(MSVC) + set(CMAKE_CXX_FLAGS_RELEASE "${CMAKE_CXX_FLAGS_RELEASE} /O2 /MT") + set(CMAKE_CXX_FLAGS_DEBUG "${CMAKE_CXX_FLAGS_DEBUG} /MTd") + endif() +else() + if(UNIX) + if(APPLE) + add_compile_options("-m64" "-fPIC" "-O3" "-march=native") + set(CMAKE_MACOSX_RPATH 1 CACHE STRING "CMAKE_MACOSX_RPATH" FORCE) + else() + add_compile_options("-fPIC" "-O3") + if(CMAKE_SYSTEM_PROCESSOR MATCHES "(x86)|(X86)|(amd64)|(AMD64)") + add_compile_options("-m64" "-march=westmere") + endif() + endif() + endif() +endif() + +foreach(keyword "__thread" "__declspec(thread)") + check_c_source_compiles( + "#if defined(__MINGW32__) && !(__GNUC__ > 4 || (__GNUC__ == 4 && __GNUC_MINOR__ >= 5)) + #error This MinGW version has broken __thread support + #endif + #ifdef __OpenBSD__ + #error OpenBSD has broken __thread support + #endif + + int ${keyword} test; + int main() { return 0; }" + HAVE_TLS_${keyword}) + if(HAVE_TLS_${keyword}) + set(HAVE_TLS_KEYWORD 1) + break() + endif() +endforeach() + +set(CHECK_SIZE_T_COMPATIBILITY 1 CACHE STRING "CHECK_SIZE_T_COMPATIBILITY" FORCE) +foreach(type "unsigned short int" "unsigned int" "unsigned long int") + string(REGEX REPLACE "[^0-9a-zA-Z_]" "_" TYPE_VAR ${type}) + string(REGEX REPLACE "^[^a-zA-Z_]+" "" TYPE_VAR ${TYPE_VAR}) + string(TOUPPER ${TYPE_VAR} TYPE_VAR) + check_cxx_source_compiles( + "#include + void foo(size_t x) {} + void foo(${type} x) {} + int main() { return 0; }" + ${TYPE_VAR}_COMPATIBLE_TO_SIZE_T) + message(STATUS "Checking if '${type}' is compatible with 'size_t': ${TYPE_VAR} [${${TYPE_VAR}_COMPATIBLE_TO_SIZE_T}]") +endforeach() + +CHECK_INCLUDE_FILES("stdint.h;stddef.h" STDC_HEADERS) +CHECK_INCLUDE_FILE("stdint.h" HAVE_STDINT_H) +CHECK_INCLUDE_FILE("stdlib.h" HAVE_STDLIB_H) +CHECK_INCLUDE_FILE("ctype.h" HAVE_CTYPE_H) +CHECK_INCLUDE_FILE("dlfcn.h" HAVE_DLFCN_H) +CHECK_INCLUDE_FILE("fcntl.h" HAVE_FCNTL_H) +CHECK_INCLUDE_FILE("inttypes.h" HAVE_INTTYPES_H) +CHECK_INCLUDE_FILE("math.h" HAVE_MATH_H) +CHECK_INCLUDE_FILE("memory.h" HAVE_MEMORY_H) +CHECK_INCLUDE_FILE("strings.h" HAVE_STRINGS_H) +CHECK_INCLUDE_FILE("string.h" HAVE_STRING_H) +CHECK_INCLUDE_FILE("sys/mman.h" HAVE_SYS_MMAN_H) +CHECK_INCLUDE_FILE("sys/param.h" HAVE_SYS_PARAM_H) +CHECK_INCLUDE_FILE("sys/stat.h" HAVE_SYS_STAT_H) +CHECK_INCLUDE_FILE("sys/times.h" HAVE_SYS_TIMES_H) +CHECK_INCLUDE_FILE("sys/types.h" HAVE_SYS_TYPES_H) +CHECK_INCLUDE_FILE("unistd.h" HAVE_UNISTD_H) +CHECK_INCLUDE_FILE("pthread.h" HAVE_PTHREAD_H) + +check_function_exists("getpagesize" HAVE_GETPAGESIZE) +check_function_exists("mmap" HAVE_MMAP) + +check_symbol_exists("_SC_NPROCESSORS_CONF" "unistd.h" HAVE_SYS_CONF_SC_NPROCESSORS_CONF) + +set(EXTRA_LINKING_LIBRARIES "") + +find_package(LibM QUIET) +if(LIBM_FOUND) + list(APPEND EXTRA_LINKING_LIBRARIES ${LIBM_LIBRARIES}) + include_directories(${LIBM_INCLUDE_DIRS}) + set(HAVE_LIBM 1 CACHE STRING "HAVE_LIBM" FORCE) +endif() + +find_package(Threads QUIET) +if(Threads_FOUND) + list(APPEND EXTRA_LINKING_LIBRARIES ${CMAKE_THREAD_LIBS_INIT}) + include_directories(${Threads_INCLUDE_DIRS}) + set(HAVE_LIBPTHREAD 1 CACHE STRING "HAVE_LIBPTHREAD" FORCE) +endif() + +message(STATUS "Project: ${PROJECT_NAME}") +message(STATUS "Version: ${PROJECT_VERSION}") + +set(CRF_PACKAGE_NAME ${PROJECT_NAME} CACHE STRING "CRF_PACKAGE_NAME" FORCE) +set(CRF_PACKAGE_VERSION ${PROJECT_VERSION} CACHE STRING "CRF_PACKAGE_VERSION" FORCE) + +configure_file(${CMAKE_CURRENT_LIST_DIR}/config.h.cmake.in config.h) + +include_directories( + ${CMAKE_CURRENT_LIST_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}) + +file(GLOB CRFPP_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/*.c + ${CMAKE_CURRENT_LIST_DIR}/*.cpp + ${CMAKE_CURRENT_BINARY_DIR}/*.c + ${CMAKE_CURRENT_BINARY_DIR}/*.cpp) + +set(CRF_LEARN_SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/crf_learn.cpp") + +set(CRF_TEST_SOURCE_FILES "${CMAKE_CURRENT_LIST_DIR}/crf_test.cpp") + +list(FILTER CRFPP_SOURCE_FILES EXCLUDE REGEX "crf_.+\.cpp") +list(REMOVE_DUPLICATES CRFPP_SOURCE_FILES) + +add_library(crfpp-static STATIC ${CRFPP_SOURCE_FILES}) +target_include_directories(crfpp-static PUBLIC ${CMAKE_CURRENT_LIST_DIR}) +target_link_libraries(crfpp-static ${EXTRA_LINKING_LIBRARIES}) +if(NOT WIN32) + set_target_properties(crfpp-static PROPERTIES OUTPUT_NAME "crfpp") +endif() +set_target_properties(crfpp-static PROPERTIES PUBLIC_HEADER "crfpp.h") + +add_library(crfpp SHARED ${CRFPP_SOURCE_FILES}) +target_include_directories(crfpp PUBLIC ${CMAKE_CURRENT_LIST_DIR}) +target_link_libraries(crfpp ${EXTRA_LINKING_LIBRARIES}) +set_target_properties(crfpp PROPERTIES PUBLIC_HEADER "crfpp.h") + +add_executable(crf_learn ${CRF_LEARN_SOURCE_FILES}) +target_link_libraries(crf_learn crfpp-static) + +add_executable(crf_test ${CRF_LEARN_SOURCE_FILES}) +target_link_libraries(crf_test crfpp-static) + +add_subdirectory(sdk) +add_subdirectory(example) + +# Installer + +install(TARGETS crfpp crfpp-static + RUNTIME + DESTINATION bin + LIBRARY + DESTINATION bin + RESOURCE + DESTINATION bin + LIBRARY + DESTINATION lib + ARCHIVE + DESTINATION lib + PUBLIC_HEADER + DESTINATION include) + +if(WIN32) + if(CMAKE_SIZEOF_VOID_P MATCHES "8") + set(CPACK_WIX_PLATFORM "x64" CACHE STRING "CPACK_WIX_PLATFORM" FORCE) + else() + set(CPACK_WIX_PLATFORM "x86" CACHE STRING "CPACK_WIX_PLATFORM" FORCE) + endif() + set(CPACK_WIX_EXTENSIONS "WixUtilExtension" "WixUIExtension" "WixNetFxExtension" CACHE STRING "CPACK_WIX_EXTENSIONS" FORCE) +else() + include(GNUInstallDirs) +endif() diff --git a/README b/README deleted file mode 100644 index de14f52..0000000 --- a/README +++ /dev/null @@ -1,2 +0,0 @@ -see doc/index.html - diff --git a/README.md b/README.md new file mode 100644 index 0000000..6cfab71 --- /dev/null +++ b/README.md @@ -0,0 +1,602 @@ +# CRF++: Yet Another CRF toolkit + +## Introduction + +**CRF++** is a simple, customizable, and open source implementation of [Conditional Random Fields (CRFs)](http://www.cis.upenn.edu/~pereira/papers/crf.pdf) for segmenting/labeling sequential data. CRF++ is designed for generic purpose and will be applied to a variety of NLP tasks, such as Named Entity Recognition, Information Extraction and Text Chunking. + +## Table of contents + +* [Features](#features) +* [News](#news) +* [Download](#download) + +* [Source](#source) +* [Binary package for MS-Windows](#windows) + +* [Installation](#install) +* [Usage](#usage) + * [Training and Test file formats](#format) + * [Preparing feature templates](#templ) + * [Training (encoding)](#training) + * [Testing (decoding)](#testing) +* [Case studies](#tips) +* [Useful Tips](#tips) +* [To do](#todo) +* [Links](#links) + +## Features + +* Can redefine feature sets +* Written in C++ with STL +* Fast training based on [LBFGS](http://www-fp.mcs.anl.gov/otc/Guide/SoftwareGuide/Blurbs/lbfgs.html), a quasi-newton algorithm for large scale numerical optimization problem +* Less memory usage both in training and testing +* encoding/decoding in practical time +* Can perform n-best outputs +* Can perform single-best MIRA training +* Can output marginal probabilities for all candidates +* Available as an open source software + +## News + +**2013-02-13** + +[CRF++ 0.58](#download) + +* Added createModelFromArray() method to load model file from fixed buffer. +* Added getTemplate() method to get template string. + +**2012-03-25** + +* Fixed build issue around libtool. +* Fixed C++11 compatible issue. + +**2012-02-24** + +* Added CRFPP:Tagger::set_model() method. +* Fixed minor bugs + +**2012-02-15** + +* Added new CRFPP:Model class so that multiple threads can share single CRF++ model. +* Added Tagger::set_penalty and Tagger::penalty() method for dual decompositon decoding +* Fixed crash bug on Windows +* Fixed minor bugs + +**2010-05-16** + +* fixed the bug in L1 regularization. Reported by Fujii Yasuhisa + +**2009-05-06** + +* fixed build failure on libtool + +**2009-04-19** + +* Code clean up +* replaced obsolete sstream with stringstream + +**2007-07-12** + +* Fixed a compilation error on gcc 4.3 + +**2007-12-09** + +* Bug fix in --convert mode (Could not generate model from text file) + +**2007-08-18** + +* Added setter/getter for nbest, cost_factor and vlevel to API + +**2007-07-07** + +* Support L1-CRF. use -a CRF-L1 option to enable L1 regularization. + +**2007-03-07** + +* Fixed a bug in MIRA training + +**2007-02-12** + +* Changed the licence from LGPL to LGPL/BSD dual license +* Perl/Ruby/Python/Java binding supports (see perl/ruby/python/java directory respectively) +* Code refactoring + +**2006-11-26** + +* Support 1-best MIRA training (use -a MIRA option) + +**2006-08-18** + +* Fixed a bug in feature extraction +* Allowed redundant spaces in training/test files +* Determined real column size by looking at template +* Added sample code of API (sdk/example.cpp) +* Described usage of each API function (crfpp.h) + +**2006-08-07** + +* implemented several API functions to get lattice information +* added -c option to control cost-factor + +**2006-03-31** + +* Fixed a bug in feature extraction + +**2006-03-30** + +* Support parallel training + +**2006-03-21** + +* Fixed a fatal memory leak bug +* make CRF++ API + +**2005-10-29** + +* added -t option that enables you to have not only binary model but also text model +* added -C option for converting a text model to a binary model + +**2005-07-04** + +* Fixed several bugs + +**2005-05-28** + +* Initial Release + +## Download + +* **CRF++** is free software; you can redistribute it and/or modify it under the terms of the [GNU Lesser General Public License](http://www.gnu.org/copyleft/lesser.html) or [new BSD License](http://www.opensource.org/licenses/bsd-license.php) +* Please let [me](mailto:taku@chasen.org) know if you use **CRF++** for research purpose or find any research publications where **CRF++** is applied. + + ### Source + + * CRF++-0.58.tar.gz: [HTTP](http://code.google.com/p/crfpp/downloads/list) + + ### Binary package for MS-Windows + + * [HTTP](http://code.google.com/p/crfpp/downloads/list) + +## Installation + +* Requirements + * C++ compiler (gcc 3.0 or higher) +* How to make + +
% ./configure 
+    % make
+    % su
+    # make install
+    
+ + You can change default install path by using --prefix option of configure script. + Try --help option for finding out other options. + +## Usage + +### Training and Test file formats + +Both the training file and the test file need to be in a particular format for **CRF++** to work properly. Generally speaking, training and test file must consist of multiple **tokens**. In addition, a **token** consists of multiple (but fixed-numbers) columns. The definition of tokens depends on tasks, however, in most of typical cases, they simply correspond to **words**. Each token must be represented in one line, with the columns separated by white space (spaces or tabular characters). A sequence of token becomes a **sentence**. To identify the boundary between sentences, an empty line is put. + +You can give as many columns as you like, however the number of columns must be fixed through all tokens. Furthermore, there are some kinds of "semantics" among the columns. For example, 1st column is 'word', second column is 'POS tag' third column is 'sub-category of POS' and so on. + +The last column represents a true answer tag which is going to be trained by CRF. + +Here's an example of such a file: (data for CoNLL shared task) + +
He        PRP  B-NP
+reckons   VBZ  B-VP
+the       DT   B-NP
+current   JJ   I-NP
+account   NN   I-NP
+deficit   NN   I-NP
+will      MD   B-VP
+narrow    VB   I-VP
+to        TO   B-PP
+only      RB   B-NP
+#         #    I-NP
+1.8       CD   I-NP
+billion   CD   I-NP
+in        IN   B-PP
+September NNP  B-NP
+.         .    O
+
+He        PRP  B-NP
+reckons   VBZ  B-VP
+..
+
+ +There are 3 columns for each token. + +* The word itself (e.g. reckons); +* part-of-speech associated with the word (e.g. VBZ); +* Chunk(answer) tag represented in IOB2 format; + +The following data is invalid, since the number of columns of second and third are 2\. (They have no POS column.) The number of columns should be fixed. + +
He        PRP  B-NP
+reckons   B-VP
+the       B-NP
+current   JJ   I-NP
+account   NN   I-NP
+..
+
+ +### Preparing feature templates + +As CRF++ is designed as a general purpose tool, you have to specify the feature templates in advance. This file describes which features are used in training and testing. + +* Template basic and macro + +Each line in the template file denotes one _template_. In each template, special macro _%x[row,col]_ will be used to specify a token in the input data. _row_ specfies the relative position from the current focusing token and _col_ specifies the absolute position of the column. + +Here you can find some examples for the replacements + +
Input: Data
+He        PRP  B-NP
+reckons   VBZ  B-VP
+the       DT   B-NP << CURRENT TOKEN
+current   JJ   I-NP 
+account   NN   I-NP
+
+ + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + + +
templateexpanded feature
**%x[0,0]**the
**%x[0,1]**DT
**%x[-1,0]**reckons
**%x[-2,1]**PRP
**%x[0,0]/%x[0,1]**the/DT
**ABC%x[0,1]123**ABCDT123
+ +* Template type + +Note also that there are two types of templates. The types are specified with the first character of templates. + +* Unigram template: first character, **'U'** + +This is a template to describe unigram features. When you give a template "U01:%x[0,1]", CRF++ automatically generates a set of feature functions (func1 ... funcN) like: + +
func1 = if (output = B-NP and feature="U01:DT") return 1 else return 0
+func2 = if (output = I-NP and feature="U01:DT") return 1 else return 0
+func3 = if (output = O and feature="U01:DT") return 1  else return 0
+....
+funcXX = if (output = B-NP and feature="U01:NN") return 1  else return 0
+funcXY = if (output = O and feature="U01:NN") return 1  else return 0
+...
+ +The number of feature functions generated by a template amounts to (L * N), where L is the number of output classes and N is the number of unique string expanded from the given template. + +* Bigram template: first character, **'B'** + +This is a template to describe bigram features. With this template, a combination of the current output token and previous output token (bigram) is automatically generated. Note that this type of template generates a total of (L * L * N) distinct features, where L is the number of output classes and N is the number of unique features generated by the templates. When the number of classes is large, this type of templates would produce a tons of distinct features that would cause inefficiency both in training/testing. + +* What is the diffrence between unigram and bigram features? + +The words unigram/bigram are confusing, since a macro for unigram-features does allow you to write word-level bigram like %x[-1,0]%x[0,0]. Here, unigram and bigram features mean uni/bigrams of output tags. + +* unigram: |output tag| x |all possible strings expanded with a macro| +* bigram: |output tag| x |output tag| x |all possible strings expanded with a macro| + +* Identifiers for distinguishing relative positions + +You also need to put an identifier in templates when relative positions of tokens must be distinguished. + +In the following case, the macro "%x[-2,1]" and "%x[1,1]" will be replaced into "DT". But they indicates different "DT". + +
The       DT  B-NP
+pen       NN  I-NP
+is        VB  B-VP << CURRENT TOKEN
+a         DT  B-NP
+
+ +To distinguish both two, put an unique identifier (U01: or U02:) in the template: + +
U01:%x[-2,1]
+U02:%x[1,1]
+
+ +In this case both two templates are regarded as different ones, as they are expanded into different features, "U01:DT" and "U02:DT". You can use any identifier whatever you like, but it is useful to use numerical numbers to manage them, because they simply correspond to feature IDs. + +If you want to use "bag-of-words" feature, in other words, not to care the relative position of features, You don't need to put such identifiers. + +* Example + +Here is the template example for [CoNLL 2000](http://www.cnts.ua.ac.be/conll2000/chunking/) shared task and Base-NP chunking task. Only one bigram template ('B') is used. This means that only combinations of previous output token and current token are used as bigram features. The lines starting from # or empty lines are discarded as comments + +
# Unigram
+U00:%x[-2,0]
+U01:%x[-1,0]
+U02:%x[0,0]
+U03:%x[1,0]
+U04:%x[2,0]
+U05:%x[-1,0]/%x[0,0]
+U06:%x[0,0]/%x[1,0]
+
+U10:%x[-2,1]
+U11:%x[-1,1]
+U12:%x[0,1]
+U13:%x[1,1]
+U14:%x[2,1]
+U15:%x[-2,1]/%x[-1,1]
+U16:%x[-1,1]/%x[0,1]
+U17:%x[0,1]/%x[1,1]
+U18:%x[1,1]/%x[2,1]
+
+U20:%x[-2,1]/%x[-1,1]/%x[0,1]
+U21:%x[-1,1]/%x[0,1]/%x[1,1]
+U22:%x[0,1]/%x[1,1]/%x[2,1]
+
+# Bigram
+B
+
+ +### Training (encoding) + +Use _crf_learn_ command: + +
% crf_learn template_file train_file model_file
+
+ +where _template_file_ and _train_file_ are the files you need to prepare in advance. _crf_learn_ generates the trained model file in _model_file_. + +crf_learn outputs the following information. + +
CRF++: Yet Another CRF Tool Kit
+Copyright(C) 2005 Taku Kudo, All rights reserved.
+
+reading training data: 100.. 200.. 300.. 400.. 500.. 600.. 700.. 800.. 
+Done! 1.94 s
+
+Number of sentences: 823
+Number of features:  1075862
+Number of thread(s): 1
+Freq:                1
+eta:                 0.00010
+C:                   1.00000
+shrinking size:      20
+Algorithm:           CRF
+
+iter=0 terr=0.99103 serr=1.00000 obj=54318.36623 diff=1.00000
+iter=1 terr=0.35260 serr=0.98177 obj=44996.53537 diff=0.17161
+iter=2 terr=0.35260 serr=0.98177 obj=21032.70195 diff=0.53257
+iter=3 terr=0.23879 serr=0.94532 obj=13642.32067 diff=0.35138
+iter=4 terr=0.15324 serr=0.88700 obj=8985.70071 diff=0.34134
+iter=5 terr=0.11605 serr=0.80680 obj=7118.89846 diff=0.20775
+iter=6 terr=0.09305 serr=0.72175 obj=5531.31015 diff=0.22301
+iter=7 terr=0.08132 serr=0.68408 obj=4618.24644 diff=0.16507
+iter=8 terr=0.06228 serr=0.59174 obj=3742.93171 diff=0.18953
+
+ +* iter: number of iterations processed +* terr: error rate with respect to tags. (# of error tags/# of all tag) +* serr: error rate with respect to sentences. (# of error sentences/# of all sentences) +* obj: current object value. When this value converges to a fixed point, CRF++ stops the iteration. +* diff: relative difference from the previous object value. + +There are 4 major parameters to control the training condition + +* -a CRF-L2 or CRF-L1: + Changing the regularization algorithm. Default setting is L2. Generally speaking, L2 performs slightly better than L1, while the number of non-zero features in L1 is drastically smaller than that in L2. +* -c float: + With this option, you can change the hyper-parameter for the CRFs. With larger C value, CRF tends to overfit to the give training corpus. This parameter trades the balance between overfitting and underfitting. The results will significantly be influenced by this parameter. You can find an optimal value by using held-out data or more general model selection method such as cross validation. +* -f NUM: + This parameter sets the cut-off threshold for the features. CRF++ uses the features that occurs no less than NUM times in the given training data. The default value is 1. When you apply CRF++ to large data, the number of unique features would amount to several millions. This option is useful in such cases. +* -p NUM: + If the PC has multiple CPUs, you can make the training faster by using multi-threading. NUM is the number of threads. + +Here is the example where these two parameters are used. + +
% crf_learn -f 3 -c 1.5 template_file train_file model_file
+
+ +Since version 0.45, CRF++ supports single-best MIRA training. MIRA training is used when -a MIRA option is set. + +
% crf_learn -a MIRA template train.data model
+CRF++: Yet Another CRF Tool Kit
+Copyright(C) 2005 Taku Kudo, All rights reserved.
+
+reading training data: 100.. 200.. 300.. 400.. 500.. 600.. 700.. 800.. 
+Done! 1.92 s
+
+Number of sentences: 823
+Number of features:  1075862
+Number of thread(s): 1
+Freq:                1
+eta:                 0.00010
+C:                   1.00000
+shrinking size:      20
+Algorithm:           MIRA
+
+iter=0 terr=0.11381 serr=0.74605 act=823 uact=0 obj=24.13498 kkt=28.00000
+iter=1 terr=0.04710 serr=0.49818 act=823 uact=0 obj=35.42289 kkt=7.60929
+iter=2 terr=0.02352 serr=0.30741 act=823 uact=0 obj=41.86775 kkt=5.74464
+iter=3 terr=0.01836 serr=0.25881 act=823 uact=0 obj=47.29565 kkt=6.64895
+iter=4 terr=0.01106 serr=0.17011 act=823 uact=0 obj=50.68792 kkt=3.81902
+iter=5 terr=0.00610 serr=0.10085 act=823 uact=0 obj=52.58096 kkt=3.98915
+iter=0 terr=0.11381 serr=0.74605 act=823 uact=0 obj=24.13498 kkt=28.00000
+...
+
+ +* iter, terr, serror: same as CRF training +* act: number of active examples in working set +* uact: number of examples whose dual parameters reach soft margin upper-bound C. 0 uact suggests that given training data was linear separable +* obj: current object value, ||w||^2 +* kkt: max kkt violation value. When it gets 0.0, MIRA training finishes + +There are some parameters to control the MIRA training condition + +* -c float: + Changes soft margin parameter, which is an analogue to the soft margin parameter C in Support Vector Machines. The definition is basically the same as -c option in CRF training. With larger C value, MIRA tends to overfit to the give training corpus. +* -f NUM: + Same as CRF +* -H NUM: + Changes shrinking size. When a training sentence is not used in updating parameter vector NUM times, we can consider that the instance doesn't contribute training any more. MIRA tries to remove such instances. The process is called "shrinking". When setting smaller NUM, shrinking occurs in early stage, which drastically reduces training time. However, too small NUM is not recommended. When training finishes, MIRA tries to go through all training examples again to know whether or not all KKT conditions are really satisfied. Too small NUM would increase the chances of recheck. + +### Testing (decoding) + +Use _crf_test_ command: + +
% crf_test -m model_file test_files ...
+
+ +where _model_file_ is the file _crf_learn_creates. In the testing, you don't need to specify the template file, because the model file has the same information for the template. _test_file_ is the test data you want to assign sequential tags. This file has to be written in the same format as training file. + +Here is an output of _crf_test_: + +
% crf_test -m model test.data
+Rockwell        NNP     B       B
+International   NNP     I       I
+Corp.   NNP     I       I
+'s      POS     B       B
+Tulsa   NNP     I       I
+unit    NN      I       I
+..
+
+ +The last column is given (estimated) tag. If the 3rd column is true answer tag , you can evaluate the accuracy by simply seeing the difference between the 3rd and 4th columns. + +* verbose level + +The **-v** option sets verbose level. default value is 0\. By increasing the level, you can have an extra information from CRF++ + +* level 1 + You can also have marginal probabilities for each tag (a kind of confidece measure for each output tag) and a conditional probably for the output (confidence measure for the entire output). + +
% crf_test -v1 -m model test.data| head
+    # 0.478113
+    Rockwell        NNP     B       B/0.992465
+    International   NNP     I       I/0.979089
+    Corp.   NNP     I       I/0.954883
+    's      POS     B       B/0.986396
+    Tulsa   NNP     I       I/0.991966
+    ...
+    
+ + The first line "# 0.478113" shows the conditional probably for the output. Also, each output tag has a probability represented like "B/0.992465". + +* level 2 + + You can also have marginal probabilities for all other candidates. + +
% crf_test -v2 -m model test.data
+    # 0.478113
+    Rockwell        NNP     B       B/0.992465      B/0.992465      I/0.00144946    O/0.00608594
+    International   NNP     I       I/0.979089      B/0.0105273     I/0.979089      O/0.0103833
+    Corp.   NNP     I       I/0.954883      B/0.00477976    I/0.954883      O/0.040337
+    's      POS     B       B/0.986396      B/0.986396      I/0.00655976    O/0.00704426
+    Tulsa   NNP     I       I/0.991966      B/0.00787494    I/0.991966      O/0.00015949
+    unit    NN      I       I/0.996169      B/0.00283111    I/0.996169      O/0.000999975
+    ..
+    
+ +* N-best outputs + +With the **-n** option, you can obtain N-best results sorted by the conditional probability of CRF. With n-best output mode, CRF++ first gives one additional line like "# N prob", where N means that rank of the output starting from 0 and prob denotes the conditional probability for the output. + +Note that CRF++ sometimes discards enumerating N-best results if it cannot find candidates any more. This is the case when you give CRF++ a short sentence. + +CRF++ uses a combination of forward Viterbi and backward A* search. This combination yields the exact list of n-best results. + +Here is the example of the N-best results. + +
% crf_test -n 20 -m model test.data
+# 0 0.478113
+Rockwell        NNP     B       B
+International   NNP     I       I
+Corp.   NNP     I       I
+'s      POS     B       B
+...
+
+# 1 0.194335
+Rockwell        NNP     B       B
+International   NNP     I       I
+
+ +## Tips + +* CRF++ uses the exactly same data format as [YamCha](http://chasen.org/~taku/software/yamcha/) uses. You may use both two toolkits for an input data and compare the performance between CRF and SVM +* The output of CRF++ is also compatible to [CoNLL 2000](http://www.cnts.ua.ac.be/conll2000/chunking/) shared task. This allows us to use the perl script [conlleval.pl](http://www.cnts.ua.ac.be/conll2000/chunking/output.html) to evaluate system outputs. This script is very useful and give us a list of F-measures for all chunk types + +## Case studies + +In the example directories, you can find three case studies, baseNP chunking, Text Chunking, and Japanese named entity recognition, to use CRF++. + +In each directory, please try the following commands + +
 % crf_learn template train model
+ % crf_test  -m model test 
+ +## To Do + +* Support [semi-Markov CRF](http://www-2.cs.cmu.edu/~wcohen/postscript/semiCRF.pdf) +* Support [piece-wise CRF](http://www.cs.umass.edu/~mccallum/papers/lcrf-nips2004.pdf) +* Provide useful C++/C API (Currently no APIs are available) + +## References + +* J. Lafferty, A. McCallum, and F. Pereira. [Conditional random fields: Probabilistic models for segmenting and labeling sequence data](http://www.cis.upenn.edu/~pereira/papers/crf.pdf), In Proc. of ICML, pp.282-289, 2001 +* F. Sha and F. Pereira. [Shallow parsing with conditional random fields](http://www.cis.upenn.edu/~feisha/pubs/shallow03.pdf), In Proc. of HLT/NAACL 2003 +* [NP chunking](http://staff.science.uva.nl/~erikt/research/np-chunking.html) +* [CoNLL 2000 shared task: Chunking](http://www.cnts.ua.ac.be/conll2000/chunking/) + +* * * + +$Id: index.html,v 1.23 2003/01/06 13:11:21 taku-ku Exp $; + +
taku@chasen.org
diff --git a/cmake/FindLibM.cmake b/cmake/FindLibM.cmake new file mode 100644 index 0000000..9660f9d --- /dev/null +++ b/cmake/FindLibM.cmake @@ -0,0 +1,47 @@ +#.rst: +# FindLibM +# -------- +# +# Find the native realtime includes and library. +# +# IMPORTED Targets +# ^^^^^^^^^^^^^^^^ +# +# This module defines :prop_tgt:`IMPORTED` target ``LIBM::LIBM``, if +# LIBM has been found. +# +# Result Variables +# ^^^^^^^^^^^^^^^^ +# +# This module defines the following variables: +# +# :: +# +# LIBM_INCLUDE_DIRS - where to find math.h, etc. +# LIBM_LIBRARIES - List of libraries when using libm. +# LIBM_FOUND - True if math library found. +# +# Hints +# ^^^^^ +# +# A user may set ``LIBM_ROOT`` to a math library installation root to tell this +# module where to look. + +find_path(LIBM_INCLUDE_DIRS + NAMES math.h + PATHS /usr/include /usr/local/include /usr/local/bic/include + NO_DEFAULT_PATH +) +find_library(LIBM_LIBRARIES m) +include(FindPackageHandleStandardArgs) +find_package_handle_standard_args(LibM DEFAULT_MSG LIBM_LIBRARIES LIBM_INCLUDE_DIRS) +mark_as_advanced(LIBM_INCLUDE_DIRS LIBM_LIBRARIES) + +if(LIBM_FOUND) + if(NOT TARGET LIBM::LIBM) + add_library(LIBM::LIBM UNKNOWN IMPORTED) + set_target_properties(LIBM::LIBM PROPERTIES + IMPORTED_LOCATION "${LIBM_LIBRARIES}" + INTERFACE_INCLUDE_DIRECTORIES "${LIBM_INCLUDE_DIRS}") + endif() +endif() \ No newline at end of file diff --git a/common.h b/common.h index 4269227..a58f3b2 100644 --- a/common.h +++ b/common.h @@ -210,9 +210,15 @@ class string_buffer: public std::string { string_buffer& operator<<(short int _n) { _ITOA(_n); } string_buffer& operator<<(int _n) { _ITOA(_n); } string_buffer& operator<<(long int _n) { _ITOA(_n); } +#if defined(CHECK_SIZE_T_COMPATIBILITY) && defined(UNSIGNED_SHORT_INT_COMPATIBLE_TO_SIZE_T) string_buffer& operator<<(unsigned short int _n) { _UITOA(_n); } +#endif +#if defined(CHECK_SIZE_T_COMPATIBILITY) && defined(UNSIGNED_INT_COMPATIBLE_TO_SIZE_T) string_buffer& operator<<(unsigned int _n) { _UITOA(_n); } - // string_buffer& operator<<(unsigned long int _n) { _UITOA(_n); } +#endif +#if defined(CHECK_SIZE_T_COMPATIBILITY) && defined(UNSIGNED_LONG_INT_COMPATIBLE_TO_SIZE_T) + string_buffer& operator<<(unsigned long int _n) { _UITOA(_n); } +#endif string_buffer& operator<<(size_t _n) { _UITOA(_n); } string_buffer& operator<<(char _n) { push_back(_n); diff --git a/config.h b/config.h.cmake.in similarity index 57% rename from config.h rename to config.h.cmake.in index ddb6701..0e55017 100644 --- a/config.h +++ b/config.h.cmake.in @@ -1,105 +1,120 @@ /* config.h. Generated from config.h.in by configure. */ /* config.h.in. Generated from configure.in by autoheader. */ +#ifndef CONFIG_H_ +#define CONFIG_H_ /* Define to 1 if you have the header file. */ -#define HAVE_CTYPE_H 1 +#cmakedefine HAVE_CTYPE_H /* Define to 1 if you have the header file. */ -#define HAVE_DLFCN_H 1 +#cmakedefine HAVE_DLFCN_H /* Define to 1 if you have the header file. */ -#define HAVE_FCNTL_H 1 +#cmakedefine HAVE_FCNTL_H /* Define to 1 if you have the `getpagesize' function. */ -#define HAVE_GETPAGESIZE 1 +#cmakedefine HAVE_GETPAGESIZE /* Define to 1 if you have the header file. */ -#define HAVE_INTTYPES_H 1 +#cmakedefine HAVE_INTTYPES_H /* Define to 1 if you have the `m' library (-lm). */ -#define HAVE_LIBM 1 +#cmakedefine HAVE_LIBM /* Define to 1 if you have the `pthread' library (-lpthread). */ -#define HAVE_LIBPTHREAD 1 +#cmakedefine HAVE_LIBPTHREAD /* Define to 1 if you have the header file. */ -#define HAVE_MATH_H 1 +#cmakedefine HAVE_MATH_H /* Define to 1 if you have the header file. */ -#define HAVE_MEMORY_H 1 +#cmakedefine HAVE_MEMORY_H /* Define to 1 if you have a working `mmap' system call. */ -#define HAVE_MMAP 1 +#cmakedefine HAVE_MMAP /* Define to 1 if you have the header file. */ -#define HAVE_PTHREAD_H 1 +#cmakedefine HAVE_PTHREAD_H /* Define to 1 if you have the header file. */ -#define HAVE_STDINT_H 1 +#cmakedefine HAVE_STDINT_H /* Define to 1 if you have the header file. */ -#define HAVE_STDLIB_H 1 +#cmakedefine HAVE_STDLIB_H /* Define to 1 if you have the header file. */ -#define HAVE_STRINGS_H 1 +#cmakedefine HAVE_STRINGS_H /* Define to 1 if you have the header file. */ -#define HAVE_STRING_H 1 - -/* */ -#define HAVE_SYS_CONF_SC_NPROCESSORS_CONF 1 +#cmakedefine HAVE_STRING_H /* Define to 1 if you have the header file. */ -#define HAVE_SYS_MMAN_H 1 +#cmakedefine HAVE_SYS_MMAN_H /* Define to 1 if you have the header file. */ -#define HAVE_SYS_PARAM_H 1 +#cmakedefine HAVE_SYS_PARAM_H /* Define to 1 if you have the header file. */ -#define HAVE_SYS_STAT_H 1 +#cmakedefine HAVE_SYS_STAT_H /* Define to 1 if you have the header file. */ -#define HAVE_SYS_TIMES_H 1 +#cmakedefine HAVE_SYS_TIMES_H /* Define to 1 if you have the header file. */ -#define HAVE_SYS_TYPES_H 1 - -/* */ -#define HAVE_TLS_KEYWORD 1 +#cmakedefine HAVE_SYS_TYPES_H /* Define to 1 if you have the header file. */ -#define HAVE_UNISTD_H 1 +#cmakedefine HAVE_UNISTD_H + +/* Define to 1 if you have the ANSI C header files. */ +#ifndef STDC_HEADERS +#cmakedefine STDC_HEADERS +#endif + +/* Define to 1 if __thread or __declspec(thread) compiles */ +#cmakedefine HAVE_TLS_KEYWORD + +/* Define to 1 if should check compatibility to size_t */ +#cmakedefine CHECK_SIZE_T_COMPATIBILITY + +/* Define to 1 if sizeof(size_t) == sizeof(unsigned short int) */ +#cmakedefine UNSIGNED_SHORT_INT_COMPATIBLE_TO_SIZE_T + +/* Define to 1 if sizeof(size_t) == sizeof(unsigned int) */ +#cmakedefine UNSIGNED_INT_COMPATIBLE_TO_SIZE_T + +/* Define to 1 if sizeof(size_t) == sizeof(unsigned long int) */ +#cmakedefine UNSIGNED_LONG_INT_COMPATIBLE_TO_SIZE_T + +/* */ +#cmakedefine HAVE_SYS_CONF_SC_NPROCESSORS_CONF /* Define to the sub-directory in which libtool stores uninstalled libraries. */ #define LT_OBJDIR ".libs/" /* Name of package */ -#define PACKAGE "CRF++" +#define PACKAGE "@CRF_PACKAGE_NAME@" /* Define to the address where bug reports for this package should be sent. */ #define PACKAGE_BUGREPORT "" /* Define to the full name of this package. */ -#define PACKAGE_NAME "" +#define PACKAGE_NAME "@CRF_PACKAGE_NAME@" /* Define to the full name and version of this package. */ -#define PACKAGE_STRING "" +#define PACKAGE_STRING "@CRF_PACKAGE_NAME@" /* Define to the one symbol short name of this package. */ -#define PACKAGE_TARNAME "" +#define PACKAGE_TARNAME "@CRF_PACKAGE_NAME@" /* Define to the home page for this package. */ #define PACKAGE_URL "" /* Define to the version of this package. */ -#define PACKAGE_VERSION "" - -/* Define to 1 if you have the ANSI C header files. */ -/* #undef STDC_HEADERS */ +#define PACKAGE_VERSION "@CRF_PACKAGE_NAME@" /* Version number of package */ -#define VERSION "0.59" +#define VERSION "@CRF_PACKAGE_VERSION@" -/* Define to `unsigned int' if does not define. */ -/* #undef size_t */ +#endif diff --git a/config.log b/config.log deleted file mode 100644 index 9ae9ea4..0000000 --- a/config.log +++ /dev/null @@ -1,1126 +0,0 @@ -This file contains any messages produced by compilers while -running configure, to aid debugging if configure makes a mistake. - -It was created by configure, which was -generated by GNU Autoconf 2.69. Invocation command line was - - $ ./configure --enable-maintainer-mode --no-create --no-recursion - -## --------- ## -## Platform. ## -## --------- ## - -hostname = woodstock -uname -m = x86_64 -uname -r = 13.1.0 -uname -s = Darwin -uname -v = Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 - -/usr/bin/uname -p = i386 -/bin/uname -X = unknown - -/bin/arch = unknown -/usr/bin/arch -k = unknown -/usr/convex/getsysinfo = unknown -/usr/bin/hostinfo = Mach kernel version: - Darwin Kernel Version 13.1.0: Thu Jan 16 19:40:37 PST 2014; root:xnu-2422.90.20~2/RELEASE_X86_64 -Kernel configured for up to 4 processors. -2 processors are physically available. -4 processors are logically available. -Processor type: i486 (Intel 80486) -Processors active: 0 1 2 3 -Primary memory available: 8.00 gigabytes -Default processor set: 210 tasks, 1031 threads, 4 processors -Load average: 3.62, Mach factor: 0.65 -/bin/machine = unknown -/usr/bin/oslevel = unknown -/bin/universe = unknown - -PATH: /usr/bin -PATH: /bin -PATH: /usr/sbin -PATH: /sbin -PATH: /usr/local/bin -PATH: /opt/X11/bin -PATH: /Users/taku/.root/bin -PATH: /usr/X11R6/bin - - -## ----------- ## -## Core tests. ## -## ----------- ## - -configure:2567: checking for a BSD-compatible install -configure:2635: result: /usr/bin/install -c -configure:2646: checking whether build environment is sane -configure:2696: result: yes -configure:2837: checking for a thread-safe mkdir -p -configure:2876: result: /usr/local/bin/gmkdir -p -configure:2889: checking for gawk -configure:2919: result: no -configure:2889: checking for mawk -configure:2919: result: no -configure:2889: checking for nawk -configure:2919: result: no -configure:2889: checking for awk -configure:2905: found /usr/bin/awk -configure:2916: result: awk -configure:2927: checking whether make sets $(MAKE) -configure:2949: result: yes -configure:3078: checking for gcc -configure:3094: found /usr/bin/gcc -configure:3105: result: gcc -configure:3334: checking for C compiler version -configure:3343: gcc --version >&5 -Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn) -Target: x86_64-apple-darwin13.1.0 -Thread model: posix -Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -configure:3354: $? = 0 -configure:3343: gcc -v >&5 -Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn) -Target: x86_64-apple-darwin13.1.0 -Thread model: posix -configure:3354: $? = 0 -configure:3343: gcc -V >&5 -clang: error: argument to '-V' is missing (expected 1 value) -clang: error: no input files -configure:3354: $? = 1 -configure:3343: gcc -qversion >&5 -clang: error: unknown argument: '-qversion' [-Wunused-command-line-argument-hard-error-in-future] -clang: note: this will be a hard error (cannot be downgraded to a warning) in the future -clang: error: no input files -configure:3354: $? = 1 -configure:3374: checking whether the C compiler works -configure:3396: gcc conftest.c >&5 -configure:3400: $? = 0 -configure:3448: result: yes -configure:3451: checking for C compiler default output file name -configure:3453: result: a.out -configure:3459: checking for suffix of executables -configure:3466: gcc -o conftest conftest.c >&5 -configure:3470: $? = 0 -configure:3492: result: -configure:3514: checking whether we are cross compiling -configure:3522: gcc -o conftest conftest.c >&5 -configure:3526: $? = 0 -configure:3533: ./conftest -configure:3537: $? = 0 -configure:3552: result: no -configure:3557: checking for suffix of object files -configure:3579: gcc -c conftest.c >&5 -configure:3583: $? = 0 -configure:3604: result: o -configure:3608: checking whether we are using the GNU C compiler -configure:3627: gcc -c conftest.c >&5 -configure:3627: $? = 0 -configure:3636: result: yes -configure:3645: checking whether gcc accepts -g -configure:3665: gcc -c -g conftest.c >&5 -configure:3665: $? = 0 -configure:3706: result: yes -configure:3723: checking for gcc option to accept ISO C89 -configure:3786: gcc -c -g -O2 conftest.c >&5 -configure:3786: $? = 0 -configure:3799: result: none needed -configure:3830: checking for style of include used by make -configure:3858: result: GNU -configure:3884: checking dependency style of gcc -configure:3995: result: gcc3 -configure:4068: checking for g++ -configure:4084: found /usr/bin/g++ -configure:4095: result: g++ -configure:4122: checking for C++ compiler version -configure:4131: g++ --version >&5 -Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn) -Target: x86_64-apple-darwin13.1.0 -Thread model: posix -Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -configure:4142: $? = 0 -configure:4131: g++ -v >&5 -Configured with: --prefix=/Applications/Xcode.app/Contents/Developer/usr --with-gxx-include-dir=/Applications/Xcode.app/Contents/Developer/Platforms/MacOSX.platform/Developer/SDKs/MacOSX10.9.sdk/usr/include/c++/4.2.1 -Apple LLVM version 5.1 (clang-503.0.38) (based on LLVM 3.4svn) -Target: x86_64-apple-darwin13.1.0 -Thread model: posix -configure:4142: $? = 0 -configure:4131: g++ -V >&5 -clang: error: argument to '-V' is missing (expected 1 value) -clang: error: no input files -configure:4142: $? = 1 -configure:4131: g++ -qversion >&5 -clang: error: unknown argument: '-qversion' [-Wunused-command-line-argument-hard-error-in-future] -clang: note: this will be a hard error (cannot be downgraded to a warning) in the future -clang: error: no input files -configure:4142: $? = 1 -configure:4146: checking whether we are using the GNU C++ compiler -configure:4165: g++ -c conftest.cpp >&5 -configure:4165: $? = 0 -configure:4174: result: yes -configure:4183: checking whether g++ accepts -g -configure:4203: g++ -c -g conftest.cpp >&5 -configure:4203: $? = 0 -configure:4244: result: yes -configure:4269: checking dependency style of g++ -configure:4380: result: gcc3 -configure:4401: checking how to run the C preprocessor -configure:4432: gcc -E conftest.c -configure:4432: $? = 0 -configure:4446: gcc -E conftest.c -conftest.c:11:10: fatal error: 'ac_nonexistent.h' file not found -#include - ^ -1 error generated. -configure:4446: $? = 1 -configure: failed program was: -| /* confdefs.h */ -| #define PACKAGE_NAME "" -| #define PACKAGE_TARNAME "" -| #define PACKAGE_VERSION "" -| #define PACKAGE_STRING "" -| #define PACKAGE_BUGREPORT "" -| #define PACKAGE_URL "" -| #define PACKAGE "CRF++" -| #define VERSION "0.59" -| /* end confdefs.h. */ -| #include -configure:4471: result: gcc -E -configure:4491: gcc -E conftest.c -configure:4491: $? = 0 -configure:4505: gcc -E conftest.c -conftest.c:11:10: fatal error: 'ac_nonexistent.h' file not found -#include - ^ -1 error generated. -configure:4505: $? = 1 -configure: failed program was: -| /* confdefs.h */ -| #define PACKAGE_NAME "" -| #define PACKAGE_TARNAME "" -| #define PACKAGE_VERSION "" -| #define PACKAGE_STRING "" -| #define PACKAGE_BUGREPORT "" -| #define PACKAGE_URL "" -| #define PACKAGE "CRF++" -| #define VERSION "0.59" -| /* end confdefs.h. */ -| #include -configure:4534: checking for grep that handles long lines and -e -configure:4592: result: /usr/bin/grep -configure:4597: checking for egrep -configure:4659: result: /usr/bin/grep -E -configure:4665: checking whether gcc needs -traditional -conftest.c:11:10: fatal error: 'termio.h' file not found -#include - ^ -1 error generated. -configure:4699: result: no -configure:4706: checking whether make sets $(MAKE) -configure:4728: result: yes -configure:4737: checking for library containing strerror -configure:4768: gcc -o conftest -g -O2 conftest.c >&5 -conftest.c:18:6: warning: incompatible redeclaration of library function 'strerror' [-Wincompatible-library-redeclaration] -char strerror (); - ^ -conftest.c:18:6: note: 'strerror' is a builtin with type 'char *(int)' -1 warning generated. -configure:4768: $? = 0 -configure:4785: result: none required -configure:4797: checking build system type -configure:4811: result: x86_64-apple-darwin13.1.0 -configure:4831: checking host system type -configure:4844: result: x86_64-apple-darwin13.1.0 -configure:4922: checking how to print strings -configure:4949: result: printf -configure:4970: checking for a sed that does not truncate output -configure:5034: result: /usr/bin/sed -configure:5052: checking for fgrep -configure:5114: result: /usr/bin/grep -F -configure:5149: checking for ld used by gcc -configure:5216: result: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -configure:5223: checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld -configure:5238: result: no -configure:5250: checking for BSD- or MS-compatible name lister (nm) -configure:5299: result: /usr/bin/nm -configure:5429: checking the name lister (/usr/bin/nm) interface -configure:5436: g++ -c -g -O2 conftest.cpp >&5 -configure:5439: /usr/bin/nm "conftest.o" -configure:5442: output -0000000000000218 S _some_variable -configure:5449: result: BSD nm -configure:5452: checking whether ln -s works -configure:5456: result: yes -configure:5464: checking the maximum length of command line arguments -configure:5594: result: 196608 -configure:5611: checking whether the shell understands some XSI constructs -configure:5621: result: yes -configure:5625: checking whether the shell understands "+=" -configure:5631: result: yes -configure:5666: checking how to convert x86_64-apple-darwin13.1.0 file names to x86_64-apple-darwin13.1.0 format -configure:5706: result: func_convert_file_noop -configure:5713: checking how to convert x86_64-apple-darwin13.1.0 file names to toolchain format -configure:5733: result: func_convert_file_noop -configure:5740: checking for /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld option to reload object files -configure:5747: result: -r -configure:5821: checking for objdump -configure:5851: result: no -configure:5880: checking how to recognize dependent libraries -configure:6082: result: pass_all -configure:6167: checking for dlltool -configure:6197: result: no -configure:6227: checking how to associate runtime and link libraries -configure:6254: result: printf %s\n -configure:6315: checking for ar -configure:6331: found /usr/bin/ar -configure:6342: result: ar -configure:6379: checking for archiver @FILE support -configure:6396: g++ -c -g -O2 conftest.cpp >&5 -configure:6396: $? = 0 -configure:6399: ar cru libconftest.a @conftest.lst >&5 -ar: @conftest.lst: No such file or directory -configure:6402: $? = 1 -configure:6422: result: no -configure:6480: checking for strip -configure:6496: found /usr/bin/strip -configure:6507: result: strip -configure:6579: checking for ranlib -configure:6595: found /usr/bin/ranlib -configure:6606: result: ranlib -configure:6708: checking command to parse /usr/bin/nm output from gcc object -configure:6828: g++ -c -g -O2 conftest.cpp >&5 -configure:6831: $? = 0 -configure:6835: /usr/bin/nm conftest.o \| sed -n -e 's/^.*[ ]\([BCDEGRST][BCDEGRST]*\)[ ][ ]*\([_A-Za-z][_A-Za-z0-9]*\)$/\1 \2 \2/p' | sed '/ __gnu_lto/d' \> conftest.nm -configure:6838: $? = 0 -cannot find nm_test_var in conftest.nm -configure:6828: g++ -c -g -O2 conftest.cpp >&5 -configure:6831: $? = 0 -configure:6835: /usr/bin/nm conftest.o \| sed -n -e 's/^.*[ ]\([BCDEGRST][BCDEGRST]*\)[ ][ ]*_\([_A-Za-z][_A-Za-z0-9]*\)$/\1 _\2 \2/p' | sed '/ __gnu_lto/d' \> conftest.nm -configure:6838: $? = 0 -configure:6904: g++ -o conftest -g -O2 conftest.cpp conftstm.o >&5 -configure:6907: $? = 0 -configure:6945: result: ok -configure:6982: checking for sysroot -configure:7012: result: no -configure:7268: checking for mt -configure:7298: result: no -configure:7318: checking if : is a manifest tool -configure:7324: : '-?' -configure:7332: result: no -configure:7388: checking for dsymutil -configure:7404: found /usr/bin/dsymutil -configure:7415: result: dsymutil -configure:7480: checking for nmedit -configure:7496: found /usr/bin/nmedit -configure:7507: result: nmedit -configure:7572: checking for lipo -configure:7588: found /usr/bin/lipo -configure:7599: result: lipo -configure:7664: checking for otool -configure:7680: found /usr/bin/otool -configure:7691: result: otool -configure:7756: checking for otool64 -configure:7786: result: no -configure:7831: checking for -single_module linker flag -gcc -g -O2 -o libconftest.dylib -dynamiclib -Wl,-single_module conftest.c -configure:7864: result: yes -configure:7867: checking for -exported_symbols_list linker flag -configure:7887: g++ -o conftest -g -O2 -Wl,-exported_symbols_list,conftest.sym conftest.cpp >&5 -configure:7887: $? = 0 -configure:7897: result: yes -configure:7900: checking for -force_load linker flag -gcc -g -O2 -c -o conftest.o conftest.c -ar cru libconftest.a conftest.o -ranlib libconftest.a -gcc -g -O2 -o conftest conftest.c -Wl,-force_load,./libconftest.a -configure:7932: result: yes -configure:7969: checking for ANSI C header files -configure:7989: g++ -c -g -O2 conftest.cpp >&5 -configure:7989: $? = 0 -./configure: line 8003: conftest.cpp: command not found -configure:8073: result: no -configure:8086: checking for sys/types.h -configure:8086: g++ -c -g -O2 conftest.cpp >&5 -configure:8086: $? = 0 -configure:8086: result: yes -configure:8086: checking for sys/stat.h -configure:8086: g++ -c -g -O2 conftest.cpp >&5 -configure:8086: $? = 0 -configure:8086: result: yes -configure:8086: checking for stdlib.h -configure:8086: g++ -c -g -O2 conftest.cpp >&5 -configure:8086: $? = 0 -configure:8086: result: yes -configure:8086: checking for string.h -configure:8086: g++ -c -g -O2 conftest.cpp >&5 -configure:8086: $? = 0 -configure:8086: result: yes -configure:8086: checking for memory.h -configure:8086: g++ -c -g -O2 conftest.cpp >&5 -configure:8086: $? = 0 -configure:8086: result: yes -configure:8086: checking for strings.h -configure:8086: g++ -c -g -O2 conftest.cpp >&5 -configure:8086: $? = 0 -configure:8086: result: yes -configure:8086: checking for inttypes.h -configure:8086: g++ -c -g -O2 conftest.cpp >&5 -configure:8086: $? = 0 -configure:8086: result: yes -configure:8086: checking for stdint.h -configure:8086: g++ -c -g -O2 conftest.cpp >&5 -configure:8086: $? = 0 -configure:8086: result: yes -configure:8086: checking for unistd.h -configure:8086: g++ -c -g -O2 conftest.cpp >&5 -configure:8086: $? = 0 -configure:8086: result: yes -configure:8100: checking for dlfcn.h -configure:8100: g++ -c -g -O2 conftest.cpp >&5 -configure:8100: $? = 0 -configure:8100: result: yes -configure:8316: checking for objdir -configure:8331: result: .libs -configure:8598: checking if gcc supports -fno-rtti -fno-exceptions -configure:8616: gcc -c -g -O2 -fno-rtti -fno-exceptions conftest.c >&5 -configure:8620: $? = 0 -configure:8633: result: yes -configure:8960: checking for gcc option to produce PIC -configure:8967: result: -fno-common -DPIC -configure:8975: checking if gcc PIC flag -fno-common -DPIC works -configure:8993: gcc -c -g -O2 -fno-common -DPIC -DPIC conftest.c >&5 -configure:8997: $? = 0 -configure:9010: result: yes -configure:9039: checking if gcc static flag -static works -configure:9067: result: no -configure:9082: checking if gcc supports -c -o file.o -configure:9103: gcc -c -g -O2 -o out/conftest2.o conftest.c >&5 -configure:9107: $? = 0 -configure:9129: result: yes -configure:9137: checking if gcc supports -c -o file.o -configure:9184: result: yes -configure:9217: checking whether the gcc linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries -configure:10374: result: yes -configure:10614: checking dynamic linker characteristics -configure:11359: result: darwin13.1.0 dyld -configure:11466: checking how to hardcode library paths into programs -configure:11491: result: immediate -configure:12031: checking whether stripping libraries is possible -configure:12045: result: yes -configure:12071: checking if libtool supports shared libraries -configure:12073: result: yes -configure:12076: checking whether to build shared libraries -configure:12097: result: yes -configure:12100: checking whether to build static libraries -configure:12104: result: yes -configure:12127: checking how to run the C++ preprocessor -configure:12154: g++ -E conftest.cpp -configure:12154: $? = 0 -configure:12168: g++ -E conftest.cpp -conftest.cpp:22:10: fatal error: 'ac_nonexistent.h' file not found -#include - ^ -1 error generated. -configure:12168: $? = 1 -configure: failed program was: -| /* confdefs.h */ -| #define PACKAGE_NAME "" -| #define PACKAGE_TARNAME "" -| #define PACKAGE_VERSION "" -| #define PACKAGE_STRING "" -| #define PACKAGE_BUGREPORT "" -| #define PACKAGE_URL "" -| #define PACKAGE "CRF++" -| #define VERSION "0.59" -| #define HAVE_SYS_TYPES_H 1 -| #define HAVE_SYS_STAT_H 1 -| #define HAVE_STDLIB_H 1 -| #define HAVE_STRING_H 1 -| #define HAVE_MEMORY_H 1 -| #define HAVE_STRINGS_H 1 -| #define HAVE_INTTYPES_H 1 -| #define HAVE_STDINT_H 1 -| #define HAVE_UNISTD_H 1 -| #define HAVE_DLFCN_H 1 -| #define LT_OBJDIR ".libs/" -| /* end confdefs.h. */ -| #include -configure:12193: result: g++ -E -configure:12213: g++ -E conftest.cpp -configure:12213: $? = 0 -configure:12227: g++ -E conftest.cpp -conftest.cpp:22:10: fatal error: 'ac_nonexistent.h' file not found -#include - ^ -1 error generated. -configure:12227: $? = 1 -configure: failed program was: -| /* confdefs.h */ -| #define PACKAGE_NAME "" -| #define PACKAGE_TARNAME "" -| #define PACKAGE_VERSION "" -| #define PACKAGE_STRING "" -| #define PACKAGE_BUGREPORT "" -| #define PACKAGE_URL "" -| #define PACKAGE "CRF++" -| #define VERSION "0.59" -| #define HAVE_SYS_TYPES_H 1 -| #define HAVE_SYS_STAT_H 1 -| #define HAVE_STDLIB_H 1 -| #define HAVE_STRING_H 1 -| #define HAVE_MEMORY_H 1 -| #define HAVE_STRINGS_H 1 -| #define HAVE_INTTYPES_H 1 -| #define HAVE_STDINT_H 1 -| #define HAVE_UNISTD_H 1 -| #define HAVE_DLFCN_H 1 -| #define LT_OBJDIR ".libs/" -| /* end confdefs.h. */ -| #include -configure:12396: checking for ld used by g++ -configure:12463: result: /Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -configure:12470: checking if the linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) is GNU ld -configure:12485: result: no -configure:12540: checking whether the g++ linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries -configure:13545: result: yes -configure:13581: g++ -c -g -O2 conftest.cpp >&5 -configure:13584: $? = 0 -configure:14104: checking for g++ option to produce PIC -configure:14111: result: -fno-common -DPIC -configure:14119: checking if g++ PIC flag -fno-common -DPIC works -configure:14137: g++ -c -g -O2 -fno-common -DPIC -DPIC conftest.cpp >&5 -configure:14141: $? = 0 -configure:14154: result: yes -configure:14177: checking if g++ static flag -static works -configure:14205: result: no -configure:14217: checking if g++ supports -c -o file.o -configure:14238: g++ -c -g -O2 -o out/conftest2.o conftest.cpp >&5 -configure:14242: $? = 0 -configure:14264: result: yes -configure:14269: checking if g++ supports -c -o file.o -configure:14316: result: yes -configure:14346: checking whether the g++ linker (/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld) supports shared libraries -configure:14385: result: yes -configure:14526: checking dynamic linker characteristics -configure:15205: result: darwin13.1.0 dyld -configure:15258: checking how to hardcode library paths into programs -configure:15283: result: immediate -configure:15348: checking for ANSI C header files -configure:15452: result: no -configure:15465: checking for string.h -configure:15465: result: yes -configure:15465: checking for stdlib.h -configure:15465: result: yes -configure:15465: checking for unistd.h -configure:15465: result: yes -configure:15465: checking fcntl.h usability -configure:15465: g++ -c -g -O2 conftest.cpp >&5 -configure:15465: $? = 0 -configure:15465: result: yes -configure:15465: checking fcntl.h presence -configure:15465: g++ -E conftest.cpp -configure:15465: $? = 0 -configure:15465: result: yes -configure:15465: checking for fcntl.h -configure:15465: result: yes -configure:15465: checking for sys/stat.h -configure:15465: result: yes -configure:15465: checking sys/mman.h usability -configure:15465: g++ -c -g -O2 conftest.cpp >&5 -configure:15465: $? = 0 -configure:15465: result: yes -configure:15465: checking sys/mman.h presence -configure:15465: g++ -E conftest.cpp -configure:15465: $? = 0 -configure:15465: result: yes -configure:15465: checking for sys/mman.h -configure:15465: result: yes -configure:15465: checking sys/times.h usability -configure:15465: g++ -c -g -O2 conftest.cpp >&5 -configure:15465: $? = 0 -configure:15465: result: yes -configure:15465: checking sys/times.h presence -configure:15465: g++ -E conftest.cpp -configure:15465: $? = 0 -configure:15465: result: yes -configure:15465: checking for sys/times.h -configure:15465: result: yes -configure:15465: checking ctype.h usability -configure:15465: g++ -c -g -O2 conftest.cpp >&5 -configure:15465: $? = 0 -configure:15465: result: yes -configure:15465: checking ctype.h presence -configure:15465: g++ -E conftest.cpp -configure:15465: $? = 0 -configure:15465: result: yes -configure:15465: checking for ctype.h -configure:15465: result: yes -configure:15465: checking for sys/types.h -configure:15465: result: yes -configure:15465: checking math.h usability -configure:15465: g++ -c -g -O2 conftest.cpp >&5 -configure:15465: $? = 0 -configure:15465: result: yes -configure:15465: checking math.h presence -configure:15465: g++ -E conftest.cpp -configure:15465: $? = 0 -configure:15465: result: yes -configure:15465: checking for math.h -configure:15465: result: yes -configure:15465: checking pthread.h usability -configure:15465: g++ -c -g -O2 conftest.cpp >&5 -configure:15465: $? = 0 -configure:15465: result: yes -configure:15465: checking pthread.h presence -configure:15465: g++ -E conftest.cpp -configure:15465: $? = 0 -configure:15465: result: yes -configure:15465: checking for pthread.h -configure:15465: result: yes -configure:15476: checking for size_t -configure:15476: g++ -c -g -O2 conftest.cpp >&5 -configure:15476: $? = 0 -configure:15476: g++ -c -g -O2 conftest.cpp >&5 -conftest.cpp:69:21: error: expected expression -if (sizeof ((size_t))) - ^ -1 error generated. -configure:15476: $? = 1 -configure: failed program was: -| /* confdefs.h */ -| #define PACKAGE_NAME "" -| #define PACKAGE_TARNAME "" -| #define PACKAGE_VERSION "" -| #define PACKAGE_STRING "" -| #define PACKAGE_BUGREPORT "" -| #define PACKAGE_URL "" -| #define PACKAGE "CRF++" -| #define VERSION "0.59" -| #define HAVE_SYS_TYPES_H 1 -| #define HAVE_SYS_STAT_H 1 -| #define HAVE_STDLIB_H 1 -| #define HAVE_STRING_H 1 -| #define HAVE_MEMORY_H 1 -| #define HAVE_STRINGS_H 1 -| #define HAVE_INTTYPES_H 1 -| #define HAVE_STDINT_H 1 -| #define HAVE_UNISTD_H 1 -| #define HAVE_DLFCN_H 1 -| #define LT_OBJDIR ".libs/" -| #define HAVE_STRING_H 1 -| #define HAVE_STDLIB_H 1 -| #define HAVE_UNISTD_H 1 -| #define HAVE_FCNTL_H 1 -| #define HAVE_SYS_STAT_H 1 -| #define HAVE_SYS_MMAN_H 1 -| #define HAVE_SYS_TIMES_H 1 -| #define HAVE_CTYPE_H 1 -| #define HAVE_SYS_TYPES_H 1 -| #define HAVE_MATH_H 1 -| #define HAVE_PTHREAD_H 1 -| /* end confdefs.h. */ -| #include -| #ifdef HAVE_SYS_TYPES_H -| # include -| #endif -| #ifdef HAVE_SYS_STAT_H -| # include -| #endif -| #ifdef STDC_HEADERS -| # include -| # include -| #else -| # ifdef HAVE_STDLIB_H -| # include -| # endif -| #endif -| #ifdef HAVE_STRING_H -| # if !defined STDC_HEADERS && defined HAVE_MEMORY_H -| # include -| # endif -| # include -| #endif -| #ifdef HAVE_STRINGS_H -| # include -| #endif -| #ifdef HAVE_INTTYPES_H -| # include -| #endif -| #ifdef HAVE_STDINT_H -| # include -| #endif -| #ifdef HAVE_UNISTD_H -| # include -| #endif -| int -| main () -| { -| if (sizeof ((size_t))) -| return 0; -| ; -| return 0; -| } -configure:15476: result: yes -configure:15488: checking for pow in -lm -configure:15513: g++ -o conftest -g -O2 conftest.cpp -lm >&5 -configure:15513: $? = 0 -configure:15522: result: yes -configure:15533: checking for exp in -lm -configure:15558: g++ -o conftest -g -O2 conftest.cpp -lm -lm >&5 -configure:15558: $? = 0 -configure:15567: result: yes -configure:15578: checking for log in -lm -configure:15603: g++ -o conftest -g -O2 conftest.cpp -lm -lm -lm >&5 -configure:15603: $? = 0 -configure:15612: result: yes -configure:15623: checking for pthread_create in -lpthread -configure:15648: g++ -o conftest -g -O2 conftest.cpp -lpthread -lm -lm -lm >&5 -configure:15648: $? = 0 -configure:15657: result: yes -configure:15668: checking for pthread_join in -lpthread -configure:15693: g++ -o conftest -g -O2 conftest.cpp -lpthread -lpthread -lm -lm -lm >&5 -configure:15693: $? = 0 -configure:15702: result: yes -configure:15719: checking for stdlib.h -configure:15719: result: yes -configure:15719: checking for unistd.h -configure:15719: result: yes -configure:15719: checking for sys/param.h -configure:15719: g++ -c -g -O2 conftest.cpp >&5 -configure:15719: $? = 0 -configure:15719: result: yes -configure:15739: checking for getpagesize -configure:15739: g++ -o conftest -g -O2 conftest.cpp -lpthread -lpthread -lm -lm -lm >&5 -configure:15739: $? = 0 -configure:15739: result: yes -configure:15748: checking for working mmap -configure:15895: g++ -o conftest -g -O2 conftest.cpp -lpthread -lpthread -lm -lm -lm >&5 -configure:15895: $? = 0 -configure:15895: ./conftest -configure:15895: $? = 0 -configure:15905: result: yes -configure:15915: checking whether make is GNU Make -configure:15918: result: yes -configure:16184: checking if g++ supports stl (required) -configure:16201: g++ -c -O3 -Wall conftest.cpp >&5 -configure:16201: $? = 0 -configure:16213: result: yes -configure:16217: checking if g++ supports stl (required) -configure:16234: g++ -c -O3 -Wall conftest.cpp >&5 -configure:16234: $? = 0 -configure:16246: result: yes -configure:16250: checking if g++ supports stl (required) -configure:16267: g++ -c -O3 -Wall conftest.cpp >&5 -configure:16267: $? = 0 -configure:16279: result: yes -configure:16283: checking if g++ supports stl (required) -configure:16300: g++ -c -O3 -Wall conftest.cpp >&5 -configure:16300: $? = 0 -configure:16312: result: yes -configure:16316: checking if g++ supports stl (required) -configure:16333: g++ -c -O3 -Wall conftest.cpp >&5 -configure:16333: $? = 0 -configure:16345: result: yes -configure:16349: checking if g++ supports stl (required) -configure:16366: g++ -c -O3 -Wall conftest.cpp >&5 -configure:16366: $? = 0 -configure:16378: result: yes -configure:16382: checking if g++ supports stl (required) -configure:16399: g++ -c -O3 -Wall conftest.cpp >&5 -configure:16399: $? = 0 -configure:16411: result: yes -configure:16415: checking if g++ supports stl (required) -configure:16432: g++ -c -O3 -Wall conftest.cpp >&5 -configure:16432: $? = 0 -configure:16444: result: yes -configure:16449: checking if g++ supports template (required) -configure:16468: g++ -c -O3 -Wall conftest.cpp >&5 -configure:16468: $? = 0 -configure:16480: result: yes -configure:16484: checking if g++ supports const_cast<> (required) -configure:16502: g++ -c -O3 -Wall conftest.cpp >&5 -conftest.cpp:51:9: warning: unused variable 'c1' [-Wunused-variable] - foo *c1=const_cast(c); - ^ -1 warning generated. -configure:16502: $? = 0 -configure:16514: result: yes -configure:16518: checking if g++ supports static_cast<> (required) -configure:16536: g++ -c -O3 -Wall conftest.cpp >&5 -conftest.cpp:51:10: warning: unused variable 'c1' [-Wunused-variable] - void *c1 = static_cast(c); - ^ -1 warning generated. -configure:16536: $? = 0 -configure:16548: result: yes -configure:16552: checking if g++ supports dynamic_cast<> (required) -configure:16571: g++ -c -O3 -Wall conftest.cpp >&5 -conftest.cpp:52:9: warning: unused variable 'c1' [-Wunused-variable] - foo *c1 = dynamic_cast(c); - ^ -1 warning generated. -configure:16571: $? = 0 -configure:16583: result: yes -configure:16587: checking if g++ supports exception handler (required) -configure:16610: g++ -c -O3 -Wall conftest.cpp >&5 -conftest.cpp:51:11: warning: unused variable 'i' [-Wunused-variable] - int i = 0; - ^ -1 warning generated. -configure:16610: $? = 0 -configure:16622: result: yes -configure:16626: checking if g++ supports namespaces (required) -configure:16644: g++ -c -O3 -Wall conftest.cpp >&5 -conftest.cpp:51:3: warning: unused variable 'a' [-Wunused-variable] -A a; - ^ -1 warning generated. -configure:16644: $? = 0 -configure:16655: result: yes -configure:16659: checking if g++ supports __thread (optional) -configure:16676: g++ -c -O3 -Wall conftest.cpp >&5 -configure:16676: $? = 0 -configure:16686: result: yes -configure:16699: checking if g++ supports _SC_NPROCESSORS_CONF (optional) -configure:16717: g++ -c -O3 -Wall conftest.cpp >&5 -configure:16717: $? = 0 -configure:16727: result: yes -configure:16738: checking if g++ environment provides all required features -configure:16746: result: yes -configure:16888: creating ./config.status -configure:19377: WARNING: unrecognized options: --enable-maintainer-mode - -## ---------------- ## -## Cache variables. ## -## ---------------- ## - -ac_cv_build=x86_64-apple-darwin13.1.0 -ac_cv_c_compiler_gnu=yes -ac_cv_cxx_compiler_gnu=yes -ac_cv_env_CCC_set= -ac_cv_env_CCC_value= -ac_cv_env_CC_set= -ac_cv_env_CC_value= -ac_cv_env_CFLAGS_set= -ac_cv_env_CFLAGS_value= -ac_cv_env_CPPFLAGS_set= -ac_cv_env_CPPFLAGS_value= -ac_cv_env_CPP_set= -ac_cv_env_CPP_value= -ac_cv_env_CXXCPP_set= -ac_cv_env_CXXCPP_value= -ac_cv_env_CXXFLAGS_set= -ac_cv_env_CXXFLAGS_value= -ac_cv_env_CXX_set= -ac_cv_env_CXX_value= -ac_cv_env_LDFLAGS_set= -ac_cv_env_LDFLAGS_value= -ac_cv_env_LIBS_set= -ac_cv_env_LIBS_value= -ac_cv_env_build_alias_set= -ac_cv_env_build_alias_value= -ac_cv_env_host_alias_set= -ac_cv_env_host_alias_value= -ac_cv_env_target_alias_set= -ac_cv_env_target_alias_value= -ac_cv_func_getpagesize=yes -ac_cv_func_mmap_fixed_mapped=yes -ac_cv_header_ctype_h=yes -ac_cv_header_dlfcn_h=yes -ac_cv_header_fcntl_h=yes -ac_cv_header_inttypes_h=yes -ac_cv_header_math_h=yes -ac_cv_header_memory_h=yes -ac_cv_header_pthread_h=yes -ac_cv_header_stdc=no -ac_cv_header_stdint_h=yes -ac_cv_header_stdlib_h=yes -ac_cv_header_string_h=yes -ac_cv_header_strings_h=yes -ac_cv_header_sys_mman_h=yes -ac_cv_header_sys_param_h=yes -ac_cv_header_sys_stat_h=yes -ac_cv_header_sys_times_h=yes -ac_cv_header_sys_types_h=yes -ac_cv_header_unistd_h=yes -ac_cv_host=x86_64-apple-darwin13.1.0 -ac_cv_lib_m_exp=yes -ac_cv_lib_m_log=yes -ac_cv_lib_m_pow=yes -ac_cv_lib_pthread_pthread_create=yes -ac_cv_lib_pthread_pthread_join=yes -ac_cv_objext=o -ac_cv_path_EGREP='/usr/bin/grep -E' -ac_cv_path_FGREP='/usr/bin/grep -F' -ac_cv_path_GREP=/usr/bin/grep -ac_cv_path_SED=/usr/bin/sed -ac_cv_path_install='/usr/bin/install -c' -ac_cv_path_mkdir=/usr/local/bin/gmkdir -ac_cv_prog_AWK=awk -ac_cv_prog_CPP='gcc -E' -ac_cv_prog_CXXCPP='g++ -E' -ac_cv_prog_ac_ct_AR=ar -ac_cv_prog_ac_ct_CC=gcc -ac_cv_prog_ac_ct_CXX=g++ -ac_cv_prog_ac_ct_DSYMUTIL=dsymutil -ac_cv_prog_ac_ct_LIPO=lipo -ac_cv_prog_ac_ct_NMEDIT=nmedit -ac_cv_prog_ac_ct_OTOOL=otool -ac_cv_prog_ac_ct_RANLIB=ranlib -ac_cv_prog_ac_ct_STRIP=strip -ac_cv_prog_cc_c89= -ac_cv_prog_cc_g=yes -ac_cv_prog_cxx_g=yes -ac_cv_prog_gcc_traditional=no -ac_cv_prog_make_make_set=yes -ac_cv_search_strerror='none required' -ac_cv_type_size_t=yes -am_cv_CC_dependencies_compiler_type=gcc3 -am_cv_CXX_dependencies_compiler_type=gcc3 -lt_cv_apple_cc_single_mod=yes -lt_cv_ar_at_file=no -lt_cv_deplibs_check_method=pass_all -lt_cv_file_magic_cmd='$MAGIC_CMD' -lt_cv_file_magic_test_file= -lt_cv_ld_exported_symbols_list=yes -lt_cv_ld_force_load=yes -lt_cv_ld_reload_flag=-r -lt_cv_nm_interface='BSD nm' -lt_cv_objdir=.libs -lt_cv_path_LD=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -lt_cv_path_LDCXX=/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld -lt_cv_path_NM=/usr/bin/nm -lt_cv_path_mainfest_tool=no -lt_cv_prog_compiler_c_o=yes -lt_cv_prog_compiler_c_o_CXX=yes -lt_cv_prog_compiler_pic='-fno-common -DPIC' -lt_cv_prog_compiler_pic_CXX='-fno-common -DPIC' -lt_cv_prog_compiler_pic_works=yes -lt_cv_prog_compiler_pic_works_CXX=yes -lt_cv_prog_compiler_rtti_exceptions=yes -lt_cv_prog_compiler_static_works=no -lt_cv_prog_compiler_static_works_CXX=no -lt_cv_prog_gnu_ld=no -lt_cv_prog_gnu_ldcxx=no -lt_cv_sharedlib_from_linklib_cmd='printf %s\n' -lt_cv_sys_global_symbol_pipe='sed -n -e '\''s/^.*[ ]\([BCDEGRST][BCDEGRST]*\)[ ][ ]*_\([_A-Za-z][_A-Za-z0-9]*\)$/\1 _\2 \2/p'\'' | sed '\''/ __gnu_lto/d'\''' -lt_cv_sys_global_symbol_to_c_name_address='sed -n -e '\''s/^: \([^ ]*\)[ ]*$/ {\"\1\", (void *) 0},/p'\'' -e '\''s/^[BCDEGRST]* \([^ ]*\) \([^ ]*\)$/ {"\2", (void *) \&\2},/p'\''' -lt_cv_sys_global_symbol_to_c_name_address_lib_prefix='sed -n -e '\''s/^: \([^ ]*\)[ ]*$/ {\"\1\", (void *) 0},/p'\'' -e '\''s/^[BCDEGRST]* \([^ ]*\) \(lib[^ ]*\)$/ {"\2", (void *) \&\2},/p'\'' -e '\''s/^[BCDEGRST]* \([^ ]*\) \([^ ]*\)$/ {"lib\2", (void *) \&\2},/p'\''' -lt_cv_sys_global_symbol_to_cdecl='sed -n -e '\''s/^T .* \(.*\)$/extern int \1();/p'\'' -e '\''s/^[BCDEGRST]* .* \(.*\)$/extern char \1;/p'\''' -lt_cv_sys_max_cmd_len=196608 -lt_cv_to_host_file_cmd=func_convert_file_noop -lt_cv_to_tool_file_cmd=func_convert_file_noop - -## ----------------- ## -## Output variables. ## -## ----------------- ## - -ACLOCAL='${SHELL} /Users/taku/proj/crfpp/missing --run aclocal-1.11' -AMDEPBACKSLASH='\' -AMDEP_FALSE='#' -AMDEP_TRUE='' -AMTAR='$${TAR-tar}' -AR='ar' -AUTOCONF='${SHELL} /Users/taku/proj/crfpp/missing --run autoconf' -AUTOHEADER='${SHELL} /Users/taku/proj/crfpp/missing --run autoheader' -AUTOMAKE='${SHELL} /Users/taku/proj/crfpp/missing --run automake-1.11' -AWK='awk' -CC='gcc' -CCDEPMODE='depmode=gcc3' -CFLAGS='-O3 -Wall' -CPP='gcc -E' -CPPFLAGS='' -CXX='g++' -CXXCPP='g++ -E' -CXXDEPMODE='depmode=gcc3' -CXXFLAGS='-O3 -Wall' -CYGPATH_W='echo' -DEFS='-DHAVE_CONFIG_H' -DEPDIR='.deps' -DLLTOOL='false' -DSYMUTIL='dsymutil' -DUMPBIN='' -ECHO_C='\c' -ECHO_N='' -ECHO_T='' -EGREP='/usr/bin/grep -E' -EXEEXT='' -FGREP='/usr/bin/grep -F' -GREP='/usr/bin/grep' -INSTALL_DATA='${INSTALL} -m 644' -INSTALL_PROGRAM='${INSTALL}' -INSTALL_SCRIPT='${INSTALL}' -INSTALL_STRIP_PROGRAM='$(install_sh) -c -s' -LD='/Applications/Xcode.app/Contents/Developer/Toolchains/XcodeDefault.xctoolchain/usr/bin/ld' -LDFLAGS='' -LIBOBJS='' -LIBS='-lpthread -lpthread -lm -lm -lm ' -LIBTOOL='$(SHELL) $(top_builddir)/libtool' -LIPO='lipo' -LN_S='ln -s' -LTLIBOBJS='' -MAKEINFO='${SHELL} /Users/taku/proj/crfpp/missing --run makeinfo' -MANIFEST_TOOL=':' -MKDIR_P='/usr/local/bin/gmkdir -p' -NM='/usr/bin/nm' -NMEDIT='nmedit' -OBJDUMP='false' -OBJEXT='o' -OTOOL64=':' -OTOOL='otool' -PACKAGE='CRF++' -PACKAGE_BUGREPORT='' -PACKAGE_NAME='' -PACKAGE_STRING='' -PACKAGE_TARNAME='' -PACKAGE_URL='' -PACKAGE_VERSION='' -PATH_SEPARATOR=':' -RANLIB='ranlib' -SED='/usr/bin/sed' -SET_MAKE='' -SHELL='/bin/sh' -STRIP='strip' -VERSION='0.59' -ac_ct_AR='ar' -ac_ct_CC='gcc' -ac_ct_CXX='g++' -ac_ct_DUMPBIN='' -am__EXEEXT_FALSE='' -am__EXEEXT_TRUE='#' -am__fastdepCC_FALSE='#' -am__fastdepCC_TRUE='' -am__fastdepCXX_FALSE='#' -am__fastdepCXX_TRUE='' -am__include='include' -am__isrc='' -am__leading_dot='.' -am__nodep='_no' -am__quote='' -am__tar='$${TAR-tar} chof - "$$tardir"' -am__untar='$${TAR-tar} xf -' -bindir='${exec_prefix}/bin' -build='x86_64-apple-darwin13.1.0' -build_alias='' -build_cpu='x86_64' -build_os='darwin13.1.0' -build_vendor='apple' -datadir='${datarootdir}' -datarootdir='${prefix}/share' -docdir='${datarootdir}/doc/${PACKAGE}' -dvidir='${docdir}' -exec_prefix='${prefix}' -host='x86_64-apple-darwin13.1.0' -host_alias='' -host_cpu='x86_64' -host_os='darwin13.1.0' -host_vendor='apple' -htmldir='${docdir}' -includedir='${prefix}/include' -infodir='${datarootdir}/info' -install_sh='${SHELL} /Users/taku/proj/crfpp/install-sh' -libdir='${exec_prefix}/lib' -libexecdir='${exec_prefix}/libexec' -localedir='${datarootdir}/locale' -localstatedir='${prefix}/var' -mandir='${datarootdir}/man' -mkdir_p='/usr/local/bin/gmkdir -p' -oldincludedir='/usr/include' -pdfdir='${docdir}' -prefix='/usr/local' -program_transform_name='s,x,x,' -psdir='${docdir}' -sbindir='${exec_prefix}/sbin' -sharedstatedir='${prefix}/com' -sysconfdir='${prefix}/etc' -target_alias='' - -## ----------- ## -## confdefs.h. ## -## ----------- ## - -/* confdefs.h */ -#define PACKAGE_NAME "" -#define PACKAGE_TARNAME "" -#define PACKAGE_VERSION "" -#define PACKAGE_STRING "" -#define PACKAGE_BUGREPORT "" -#define PACKAGE_URL "" -#define PACKAGE "CRF++" -#define VERSION "0.59" -#define HAVE_SYS_TYPES_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_STRING_H 1 -#define HAVE_MEMORY_H 1 -#define HAVE_STRINGS_H 1 -#define HAVE_INTTYPES_H 1 -#define HAVE_STDINT_H 1 -#define HAVE_UNISTD_H 1 -#define HAVE_DLFCN_H 1 -#define LT_OBJDIR ".libs/" -#define HAVE_STRING_H 1 -#define HAVE_STDLIB_H 1 -#define HAVE_UNISTD_H 1 -#define HAVE_FCNTL_H 1 -#define HAVE_SYS_STAT_H 1 -#define HAVE_SYS_MMAN_H 1 -#define HAVE_SYS_TIMES_H 1 -#define HAVE_CTYPE_H 1 -#define HAVE_SYS_TYPES_H 1 -#define HAVE_MATH_H 1 -#define HAVE_PTHREAD_H 1 -#define HAVE_LIBM 1 -#define HAVE_LIBM 1 -#define HAVE_LIBM 1 -#define HAVE_LIBPTHREAD 1 -#define HAVE_LIBPTHREAD 1 -#define HAVE_STDLIB_H 1 -#define HAVE_UNISTD_H 1 -#define HAVE_SYS_PARAM_H 1 -#define HAVE_GETPAGESIZE 1 -#define HAVE_MMAP 1 -#define HAVE_TLS_KEYWORD 1 -#define HAVE_SYS_CONF_SC_NPROCESSORS_CONF 1 - -configure: exit 0 - -## ---------------------- ## -## Running config.status. ## -## ---------------------- ## - -This file was extended by config.status, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = - CONFIG_HEADERS = - CONFIG_LINKS = - CONFIG_COMMANDS = - $ ./config.status - -on woodstock - -config.status:1160: creating Makefile -config.status:1160: creating Makefile.msvc -config.status:1160: creating swig/version.h -config.status:1160: creating config.h -config.status:1341: config.h is unchanged -config.status:1389: executing depfiles commands -config.status:1389: executing libtool commands - -## ---------------------- ## -## Running config.status. ## -## ---------------------- ## - -This file was extended by config.status, which was -generated by GNU Autoconf 2.69. Invocation command line was - - CONFIG_FILES = - CONFIG_HEADERS = - CONFIG_LINKS = - CONFIG_COMMANDS = - $ ./config.status config.h - -on woodstock - -config.status:1160: creating config.h -config.status:1341: config.h is unchanged diff --git a/encoder.cpp b/encoder.cpp index 2c6f758..993db35 100644 --- a/encoder.cpp +++ b/encoder.cpp @@ -5,6 +5,10 @@ // // Copyright(C) 2005-2007 Taku Kudo // +#ifdef HAVE_CONFIG_H +#include "config.h" +#endif + #ifdef HAVE_UNISTD_H #include #endif diff --git a/example/CMakeLists.txt b/example/CMakeLists.txt new file mode 100644 index 0000000..93e512e --- /dev/null +++ b/example/CMakeLists.txt @@ -0,0 +1,7 @@ +cmake_minimum_required(VERSION 3.13) +project(crfpp_examples VERSION 0.59 LANGUAGES C CXX) + +set(BIN_PATH ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}) +set(EXAMPLE_DIR ${CMAKE_CURRENT_LIST_DIR}) + +configure_file(${CMAKE_CURRENT_LIST_DIR}/run_examples.sh.in ${CMAKE_RUNTIME_OUTPUT_DIRECTORY}/run_examples.sh) diff --git a/example/JapaneseNE/exec.sh b/example/JapaneseNE/exec.sh index b4e9f5c..1010187 100755 --- a/example/JapaneseNE/exec.sh +++ b/example/JapaneseNE/exec.sh @@ -1,7 +1,10 @@ #!/bin/sh -../../crf_learn -p2 -f 3 -c 4.0 template train.data model -../../crf_test -m model test.data -../../crf_learn -a MIRA -f 3 template train.data model -../../crf_test -m model test.data +BIN_PATH="${1:-../..}" + +$BIN_PATH/crf_learn -p2 -f 3 -c 4.0 template train.data model +$BIN_PATH/crf_test -m model test.data + +$BIN_PATH/crf_learn -a MIRA -f 3 template train.data model +$BIN_PATH/crf_test -m model test.data rm -f model diff --git a/example/basenp/exec.sh b/example/basenp/exec.sh index 7005d08..8632ddb 100755 --- a/example/basenp/exec.sh +++ b/example/basenp/exec.sh @@ -1,7 +1,10 @@ #!/bin/sh -../../crf_learn -c 10.0 template train.data model -../../crf_test -m model test.data -../../crf_learn -a MIRA template train.data model -../../crf_test -m model test.data +BIN_PATH="${1:-../..}" + +$BIN_PATH/crf_learn -c 10.0 template train.data model +$BIN_PATH/crf_test -m model test.data + +$BIN_PATH/crf_learn -a MIRA template train.data model +$BIN_PATH/crf_test -m model test.data rm -f model diff --git a/example/chunking/exec.sh b/example/chunking/exec.sh index 153e34e..c32dd7a 100755 --- a/example/chunking/exec.sh +++ b/example/chunking/exec.sh @@ -1,11 +1,14 @@ #!/bin/sh -../../crf_learn -c 4.0 template train.data model -../../crf_test -m model test.data -../../crf_learn -a MIRA template train.data model -../../crf_test -m model test.data +BIN_PATH="${1:-../..}" -#../../crf_learn -a CRF-L1 template train.data model -#../../crf_test -m model test.data +$BIN_PATH/crf_learn -c 4.0 template train.data model +$BIN_PATH/crf_test -m model test.data + +$BIN_PATH/crf_learn -a MIRA template train.data model +$BIN_PATH/crf_test -m model test.data + +# $BIN_PATH/crf_learn -a CRF-L1 template train.data model +# $BIN_PATH/crf_test -m model test.data rm -f model diff --git a/example/run_examples.sh.in b/example/run_examples.sh.in new file mode 100644 index 0000000..e89dcfc --- /dev/null +++ b/example/run_examples.sh.in @@ -0,0 +1,19 @@ +#!/bin/bash + +function run_example { + dir_name="$1" + pushd $dir_name + ./exec.sh $BIN_PATH + popd +} + +export BIN_PATH="@BIN_PATH@" + +pushd "@EXAMPLE_DIR@" + +EXAMPLE_DIRS=$(ls -d */) +for example in $EXAMPLE_DIRS +do + echo "Starting example $example..." + run_example $example +done diff --git a/example/seg/exec.sh b/example/seg/exec.sh index 65251fd..4100d28 100755 --- a/example/seg/exec.sh +++ b/example/seg/exec.sh @@ -1,7 +1,10 @@ #!/bin/sh -../../crf_learn -f 3 -c 4.0 template train.data model -../../crf_test -m model test.data -../../crf_learn -a MIRA -f 3 template train.data model -../../crf_test -m model test.data +BIN_PATH="${1:-../..}" + +$BIN_PATH/crf_learn -f 3 -c 4.0 template train.data model +$BIN_PATH/crf_test -m model test.data + +$BIN_PATH/crf_learn -a MIRA -f 3 template train.data model +$BIN_PATH/crf_test -m model test.data rm -f model diff --git a/sdk/CMakeLists.txt b/sdk/CMakeLists.txt new file mode 100644 index 0000000..61360dd --- /dev/null +++ b/sdk/CMakeLists.txt @@ -0,0 +1,14 @@ +cmake_minimum_required(VERSION 3.13) +project(crfpp_sdk_example VERSION 0.59 LANGUAGES C CXX) + +include_directories( + ${CMAKE_CURRENT_LIST_DIR} + ${CMAKE_BINARY_DIR} + ${CMAKE_CURRENT_BINARY_DIR}) + +file(GLOB CRFPP_SDK_EXAMPLE_SOURCE_FILES + ${CMAKE_CURRENT_LIST_DIR}/*.c + ${CMAKE_CURRENT_LIST_DIR}/*.cpp) + +add_executable(crf_sdk_example ${CRFPP_SDK_EXAMPLE_SOURCE_FILES}) +target_link_libraries(crf_sdk_example crfpp) \ No newline at end of file diff --git a/thread.h b/thread.h index b5c3c37..1c5e71e 100644 --- a/thread.h +++ b/thread.h @@ -9,6 +9,7 @@ #define CRFPP_THREAD_H_ #ifdef HAVE_PTHREAD_H +#define CRFPP_USE_THREAD 1 #include #else #ifdef _WIN32 @@ -17,10 +18,6 @@ #endif #endif -#if defined HAVE_PTHREAD_H -#define CRFPP_USE_THREAD 1 -#endif - #if(defined(_WIN32) && !defined (__CYGWIN__)) #define CRFPP_USE_THREAD 1 #define BEGINTHREAD(src, stack, func, arg, flag, id) \ diff --git a/winmain.h b/winmain.h new file mode 100644 index 0000000..ce44b31 --- /dev/null +++ b/winmain.h @@ -0,0 +1,8 @@ +#if _WIN32 +#ifndef WINMAIN_H +#define WINMAIN_H + + + +#endif +#endif \ No newline at end of file