opener-opinion-detector-base 2.0.0

Sign up to get free protection for your applications and to get access to all the features.
Files changed (261) hide show
  1. checksums.yaml +7 -0
  2. data/README.md +101 -0
  3. data/bin/opinion-detector-base +19 -0
  4. data/core/annotation.cfg.erb +9 -0
  5. data/core/packages/KafNafParser-1.4.tar.gz +0 -0
  6. data/core/packages/VUA_pylib-1.5.tar.gz +0 -0
  7. data/core/python-scripts/LICENSE +339 -0
  8. data/core/python-scripts/README.md +226 -0
  9. data/core/python-scripts/classify_kaf_naf_file.py +499 -0
  10. data/core/python-scripts/cross_validation.py +634 -0
  11. data/core/python-scripts/generate_folds.py +134 -0
  12. data/core/python-scripts/models.cfg +10 -0
  13. data/core/python-scripts/my_templates/README +33 -0
  14. data/core/python-scripts/my_templates/templates_exp.only0.txt +6 -0
  15. data/core/python-scripts/my_templates/templates_exp.pol0.txt +10 -0
  16. data/core/python-scripts/my_templates/templates_exp.red.txt +7 -0
  17. data/core/python-scripts/my_templates/templates_exp.txt +10 -0
  18. data/core/python-scripts/my_templates/templates_holder.only0.txt +11 -0
  19. data/core/python-scripts/my_templates/templates_holder.red.txt +9 -0
  20. data/core/python-scripts/my_templates/templates_holder.txt +10 -0
  21. data/core/python-scripts/my_templates/templates_target.only0.txt +11 -0
  22. data/core/python-scripts/my_templates/templates_target.red.txt +9 -0
  23. data/core/python-scripts/my_templates/templates_target.txt +10 -0
  24. data/core/python-scripts/run_all_experiments.sh +49 -0
  25. data/core/python-scripts/run_basic.py +20 -0
  26. data/core/python-scripts/run_experiment.sh +42 -0
  27. data/core/python-scripts/scripts/__init__.py +1 -0
  28. data/core/python-scripts/scripts/config_manager.py +314 -0
  29. data/core/python-scripts/scripts/crfutils.py +215 -0
  30. data/core/python-scripts/scripts/extract_feats_relations.py +295 -0
  31. data/core/python-scripts/scripts/extract_features.py +376 -0
  32. data/core/python-scripts/scripts/feats_to_crf.exp.py +105 -0
  33. data/core/python-scripts/scripts/lexicons.py +44 -0
  34. data/core/python-scripts/scripts/link_entities_distance.py +77 -0
  35. data/core/python-scripts/scripts/relation_classifier.py +250 -0
  36. data/core/python-scripts/train.py +566 -0
  37. data/core/site-packages/pre_build/KafNafParser-1.4-py2.7.egg-info/PKG-INFO +10 -0
  38. data/core/site-packages/pre_build/KafNafParser-1.4-py2.7.egg-info/SOURCES.txt +22 -0
  39. data/core/site-packages/pre_build/KafNafParser-1.4-py2.7.egg-info/dependency_links.txt +1 -0
  40. data/core/site-packages/pre_build/KafNafParser-1.4-py2.7.egg-info/installed-files.txt +47 -0
  41. data/core/site-packages/pre_build/KafNafParser-1.4-py2.7.egg-info/top_level.txt +1 -0
  42. data/core/site-packages/pre_build/KafNafParser/KafNafParserMod.py +390 -0
  43. data/core/site-packages/pre_build/KafNafParser/KafNafParserMod.pyc +0 -0
  44. data/core/site-packages/pre_build/KafNafParser/__init__.py +14 -0
  45. data/core/site-packages/pre_build/KafNafParser/__init__.pyc +0 -0
  46. data/core/site-packages/pre_build/KafNafParser/constituency_data.py +125 -0
  47. data/core/site-packages/pre_build/KafNafParser/constituency_data.pyc +0 -0
  48. data/core/site-packages/pre_build/KafNafParser/coreference_data.py +52 -0
  49. data/core/site-packages/pre_build/KafNafParser/coreference_data.pyc +0 -0
  50. data/core/site-packages/pre_build/KafNafParser/dependency_data.py +78 -0
  51. data/core/site-packages/pre_build/KafNafParser/dependency_data.pyc +0 -0
  52. data/core/site-packages/pre_build/KafNafParser/entity_data.py +59 -0
  53. data/core/site-packages/pre_build/KafNafParser/entity_data.pyc +0 -0
  54. data/core/site-packages/pre_build/KafNafParser/external_references_data.py +41 -0
  55. data/core/site-packages/pre_build/KafNafParser/external_references_data.pyc +0 -0
  56. data/core/site-packages/pre_build/KafNafParser/feature_extractor/__init__.py +2 -0
  57. data/core/site-packages/pre_build/KafNafParser/feature_extractor/__init__.pyc +0 -0
  58. data/core/site-packages/pre_build/KafNafParser/feature_extractor/constituency.py +205 -0
  59. data/core/site-packages/pre_build/KafNafParser/feature_extractor/constituency.pyc +0 -0
  60. data/core/site-packages/pre_build/KafNafParser/feature_extractor/dependency.py +309 -0
  61. data/core/site-packages/pre_build/KafNafParser/feature_extractor/dependency.pyc +0 -0
  62. data/core/site-packages/pre_build/KafNafParser/features_data.py +131 -0
  63. data/core/site-packages/pre_build/KafNafParser/features_data.pyc +0 -0
  64. data/core/site-packages/pre_build/KafNafParser/header_data.py +127 -0
  65. data/core/site-packages/pre_build/KafNafParser/header_data.pyc +0 -0
  66. data/core/site-packages/pre_build/KafNafParser/opinion_data.py +211 -0
  67. data/core/site-packages/pre_build/KafNafParser/opinion_data.pyc +0 -0
  68. data/core/site-packages/pre_build/KafNafParser/references_data.py +23 -0
  69. data/core/site-packages/pre_build/KafNafParser/references_data.pyc +0 -0
  70. data/core/site-packages/pre_build/KafNafParser/span_data.py +63 -0
  71. data/core/site-packages/pre_build/KafNafParser/span_data.pyc +0 -0
  72. data/core/site-packages/pre_build/KafNafParser/term_data.py +111 -0
  73. data/core/site-packages/pre_build/KafNafParser/term_data.pyc +0 -0
  74. data/core/site-packages/pre_build/KafNafParser/term_sentiment_data.py +42 -0
  75. data/core/site-packages/pre_build/KafNafParser/term_sentiment_data.pyc +0 -0
  76. data/core/site-packages/pre_build/KafNafParser/text_data.py +99 -0
  77. data/core/site-packages/pre_build/KafNafParser/text_data.pyc +0 -0
  78. data/core/site-packages/pre_build/VUA_pylib-1.5-py2.7.egg-info/PKG-INFO +10 -0
  79. data/core/site-packages/pre_build/VUA_pylib-1.5-py2.7.egg-info/SOURCES.txt +14 -0
  80. data/core/site-packages/pre_build/VUA_pylib-1.5-py2.7.egg-info/dependency_links.txt +1 -0
  81. data/core/site-packages/pre_build/VUA_pylib-1.5-py2.7.egg-info/installed-files.txt +23 -0
  82. data/core/site-packages/pre_build/VUA_pylib-1.5-py2.7.egg-info/top_level.txt +1 -0
  83. data/core/site-packages/pre_build/VUA_pylib/__init__.py +1 -0
  84. data/core/site-packages/pre_build/VUA_pylib/__init__.pyc +0 -0
  85. data/core/site-packages/pre_build/VUA_pylib/common/__init__.py +1 -0
  86. data/core/site-packages/pre_build/VUA_pylib/common/__init__.pyc +0 -0
  87. data/core/site-packages/pre_build/VUA_pylib/common/common.py +28 -0
  88. data/core/site-packages/pre_build/VUA_pylib/common/common.pyc +0 -0
  89. data/core/site-packages/pre_build/VUA_pylib/corpus_reader/__init__.py +1 -0
  90. data/core/site-packages/pre_build/VUA_pylib/corpus_reader/__init__.pyc +0 -0
  91. data/core/site-packages/pre_build/VUA_pylib/corpus_reader/google_web_nl.py +156 -0
  92. data/core/site-packages/pre_build/VUA_pylib/corpus_reader/google_web_nl.pyc +0 -0
  93. data/core/site-packages/pre_build/VUA_pylib/io_utils/__init__.py +1 -0
  94. data/core/site-packages/pre_build/VUA_pylib/io_utils/__init__.pyc +0 -0
  95. data/core/site-packages/pre_build/VUA_pylib/io_utils/feature_file.py +121 -0
  96. data/core/site-packages/pre_build/VUA_pylib/io_utils/feature_file.pyc +0 -0
  97. data/core/site-packages/pre_build/VUA_pylib/lexicon/__init__.py +1 -0
  98. data/core/site-packages/pre_build/VUA_pylib/lexicon/__init__.pyc +0 -0
  99. data/core/site-packages/pre_build/VUA_pylib/lexicon/lexicon.py +72 -0
  100. data/core/site-packages/pre_build/VUA_pylib/lexicon/lexicon.pyc +0 -0
  101. data/core/site-packages/pre_build/VUKafParserPy-1.0-py2.7.egg-info/PKG-INFO +10 -0
  102. data/core/site-packages/pre_build/VUKafParserPy-1.0-py2.7.egg-info/SOURCES.txt +7 -0
  103. data/core/site-packages/pre_build/VUKafParserPy-1.0-py2.7.egg-info/dependency_links.txt +1 -0
  104. data/core/site-packages/pre_build/VUKafParserPy-1.0-py2.7.egg-info/installed-files.txt +11 -0
  105. data/core/site-packages/pre_build/VUKafParserPy-1.0-py2.7.egg-info/top_level.txt +1 -0
  106. data/core/site-packages/pre_build/VUKafParserPy/KafDataObjectsMod.py +165 -0
  107. data/core/site-packages/pre_build/VUKafParserPy/KafDataObjectsMod.pyc +0 -0
  108. data/core/site-packages/pre_build/VUKafParserPy/KafParserMod.py +439 -0
  109. data/core/site-packages/pre_build/VUKafParserPy/KafParserMod.pyc +0 -0
  110. data/core/site-packages/pre_build/VUKafParserPy/__init__.py +7 -0
  111. data/core/site-packages/pre_build/VUKafParserPy/__init__.pyc +0 -0
  112. data/core/vendor/src/crfsuite/AUTHORS +1 -0
  113. data/core/vendor/src/crfsuite/COPYING +27 -0
  114. data/core/vendor/src/crfsuite/ChangeLog +103 -0
  115. data/core/vendor/src/crfsuite/INSTALL +236 -0
  116. data/core/vendor/src/crfsuite/Makefile.am +19 -0
  117. data/core/vendor/src/crfsuite/Makefile.in +783 -0
  118. data/core/vendor/src/crfsuite/README +183 -0
  119. data/core/vendor/src/crfsuite/aclocal.m4 +9018 -0
  120. data/core/vendor/src/crfsuite/autogen.sh +38 -0
  121. data/core/vendor/src/crfsuite/compile +143 -0
  122. data/core/vendor/src/crfsuite/config.guess +1502 -0
  123. data/core/vendor/src/crfsuite/config.h.in +198 -0
  124. data/core/vendor/src/crfsuite/config.sub +1714 -0
  125. data/core/vendor/src/crfsuite/configure +14273 -0
  126. data/core/vendor/src/crfsuite/configure.in +149 -0
  127. data/core/vendor/src/crfsuite/crfsuite.sln +42 -0
  128. data/core/vendor/src/crfsuite/depcomp +630 -0
  129. data/core/vendor/src/crfsuite/example/chunking.py +49 -0
  130. data/core/vendor/src/crfsuite/example/crfutils.py +179 -0
  131. data/core/vendor/src/crfsuite/example/ner.py +270 -0
  132. data/core/vendor/src/crfsuite/example/pos.py +78 -0
  133. data/core/vendor/src/crfsuite/example/template.py +88 -0
  134. data/core/vendor/src/crfsuite/frontend/Makefile.am +29 -0
  135. data/core/vendor/src/crfsuite/frontend/Makefile.in +640 -0
  136. data/core/vendor/src/crfsuite/frontend/dump.c +116 -0
  137. data/core/vendor/src/crfsuite/frontend/frontend.vcxproj +129 -0
  138. data/core/vendor/src/crfsuite/frontend/iwa.c +273 -0
  139. data/core/vendor/src/crfsuite/frontend/iwa.h +65 -0
  140. data/core/vendor/src/crfsuite/frontend/learn.c +439 -0
  141. data/core/vendor/src/crfsuite/frontend/main.c +137 -0
  142. data/core/vendor/src/crfsuite/frontend/option.c +93 -0
  143. data/core/vendor/src/crfsuite/frontend/option.h +86 -0
  144. data/core/vendor/src/crfsuite/frontend/readdata.h +38 -0
  145. data/core/vendor/src/crfsuite/frontend/reader.c +136 -0
  146. data/core/vendor/src/crfsuite/frontend/tag.c +427 -0
  147. data/core/vendor/src/crfsuite/genbinary.sh.in +15 -0
  148. data/core/vendor/src/crfsuite/include/Makefile.am +11 -0
  149. data/core/vendor/src/crfsuite/include/Makefile.in +461 -0
  150. data/core/vendor/src/crfsuite/include/crfsuite.h +1063 -0
  151. data/core/vendor/src/crfsuite/include/crfsuite.hpp +555 -0
  152. data/core/vendor/src/crfsuite/include/crfsuite_api.hpp +400 -0
  153. data/core/vendor/src/crfsuite/include/os.h +61 -0
  154. data/core/vendor/src/crfsuite/install-sh +520 -0
  155. data/core/vendor/src/crfsuite/lib/cqdb/COPYING +28 -0
  156. data/core/vendor/src/crfsuite/lib/cqdb/Makefile.am +21 -0
  157. data/core/vendor/src/crfsuite/lib/cqdb/Makefile.in +549 -0
  158. data/core/vendor/src/crfsuite/lib/cqdb/cqdb.vcxproj +86 -0
  159. data/core/vendor/src/crfsuite/lib/cqdb/include/cqdb.h +524 -0
  160. data/core/vendor/src/crfsuite/lib/cqdb/src/cqdb.c +587 -0
  161. data/core/vendor/src/crfsuite/lib/cqdb/src/lookup3.c +976 -0
  162. data/core/vendor/src/crfsuite/lib/crf/Makefile.am +46 -0
  163. data/core/vendor/src/crfsuite/lib/crf/Makefile.in +721 -0
  164. data/core/vendor/src/crfsuite/lib/crf/crf.vcxproj +216 -0
  165. data/core/vendor/src/crfsuite/lib/crf/src/crf1d.h +353 -0
  166. data/core/vendor/src/crfsuite/lib/crf/src/crf1d_context.c +705 -0
  167. data/core/vendor/src/crfsuite/lib/crf/src/crf1d_encode.c +943 -0
  168. data/core/vendor/src/crfsuite/lib/crf/src/crf1d_feature.c +352 -0
  169. data/core/vendor/src/crfsuite/lib/crf/src/crf1d_model.c +994 -0
  170. data/core/vendor/src/crfsuite/lib/crf/src/crf1d_tag.c +550 -0
  171. data/core/vendor/src/crfsuite/lib/crf/src/crfsuite.c +492 -0
  172. data/core/vendor/src/crfsuite/lib/crf/src/crfsuite_internal.h +236 -0
  173. data/core/vendor/src/crfsuite/lib/crf/src/crfsuite_train.c +272 -0
  174. data/core/vendor/src/crfsuite/lib/crf/src/dataset.c +106 -0
  175. data/core/vendor/src/crfsuite/lib/crf/src/dictionary.c +118 -0
  176. data/core/vendor/src/crfsuite/lib/crf/src/holdout.c +80 -0
  177. data/core/vendor/src/crfsuite/lib/crf/src/logging.c +91 -0
  178. data/core/vendor/src/crfsuite/lib/crf/src/logging.h +48 -0
  179. data/core/vendor/src/crfsuite/lib/crf/src/params.c +335 -0
  180. data/core/vendor/src/crfsuite/lib/crf/src/params.h +80 -0
  181. data/core/vendor/src/crfsuite/lib/crf/src/quark.c +172 -0
  182. data/core/vendor/src/crfsuite/lib/crf/src/quark.h +46 -0
  183. data/core/vendor/src/crfsuite/lib/crf/src/rumavl.c +1107 -0
  184. data/core/vendor/src/crfsuite/lib/crf/src/rumavl.h +160 -0
  185. data/core/vendor/src/crfsuite/lib/crf/src/train_arow.c +408 -0
  186. data/core/vendor/src/crfsuite/lib/crf/src/train_averaged_perceptron.c +242 -0
  187. data/core/vendor/src/crfsuite/lib/crf/src/train_l2sgd.c +507 -0
  188. data/core/vendor/src/crfsuite/lib/crf/src/train_lbfgs.c +338 -0
  189. data/core/vendor/src/crfsuite/lib/crf/src/train_passive_aggressive.c +435 -0
  190. data/core/vendor/src/crfsuite/lib/crf/src/vecmath.h +341 -0
  191. data/core/vendor/src/crfsuite/ltmain.sh +8413 -0
  192. data/core/vendor/src/crfsuite/missing +376 -0
  193. data/core/vendor/src/crfsuite/swig/Makefile.am +13 -0
  194. data/core/vendor/src/crfsuite/swig/Makefile.in +365 -0
  195. data/core/vendor/src/crfsuite/swig/crfsuite.cpp +2 -0
  196. data/core/vendor/src/crfsuite/swig/export.i +32 -0
  197. data/core/vendor/src/crfsuite/swig/python/README +92 -0
  198. data/core/vendor/src/crfsuite/swig/python/crfsuite.py +329 -0
  199. data/core/vendor/src/crfsuite/swig/python/export_wrap.cpp +14355 -0
  200. data/core/vendor/src/crfsuite/swig/python/export_wrap.h +63 -0
  201. data/core/vendor/src/crfsuite/swig/python/prepare.sh +9 -0
  202. data/core/vendor/src/crfsuite/swig/python/sample_tag.py +52 -0
  203. data/core/vendor/src/crfsuite/swig/python/sample_train.py +68 -0
  204. data/core/vendor/src/crfsuite/swig/python/setup.py +44 -0
  205. data/core/vendor/src/crfsuite/win32/stdint.h +679 -0
  206. data/core/vendor/src/liblbfgs/AUTHORS +1 -0
  207. data/core/vendor/src/liblbfgs/COPYING +22 -0
  208. data/core/vendor/src/liblbfgs/ChangeLog +120 -0
  209. data/core/vendor/src/liblbfgs/INSTALL +231 -0
  210. data/core/vendor/src/liblbfgs/Makefile.am +10 -0
  211. data/core/vendor/src/liblbfgs/Makefile.in +638 -0
  212. data/core/vendor/src/liblbfgs/NEWS +0 -0
  213. data/core/vendor/src/liblbfgs/README +71 -0
  214. data/core/vendor/src/liblbfgs/aclocal.m4 +6985 -0
  215. data/core/vendor/src/liblbfgs/autogen.sh +38 -0
  216. data/core/vendor/src/liblbfgs/config.guess +1411 -0
  217. data/core/vendor/src/liblbfgs/config.h.in +64 -0
  218. data/core/vendor/src/liblbfgs/config.sub +1500 -0
  219. data/core/vendor/src/liblbfgs/configure +21146 -0
  220. data/core/vendor/src/liblbfgs/configure.in +107 -0
  221. data/core/vendor/src/liblbfgs/depcomp +522 -0
  222. data/core/vendor/src/liblbfgs/include/lbfgs.h +745 -0
  223. data/core/vendor/src/liblbfgs/install-sh +322 -0
  224. data/core/vendor/src/liblbfgs/lbfgs.sln +26 -0
  225. data/core/vendor/src/liblbfgs/lib/Makefile.am +24 -0
  226. data/core/vendor/src/liblbfgs/lib/Makefile.in +499 -0
  227. data/core/vendor/src/liblbfgs/lib/arithmetic_ansi.h +133 -0
  228. data/core/vendor/src/liblbfgs/lib/arithmetic_sse_double.h +294 -0
  229. data/core/vendor/src/liblbfgs/lib/arithmetic_sse_float.h +298 -0
  230. data/core/vendor/src/liblbfgs/lib/lbfgs.c +1371 -0
  231. data/core/vendor/src/liblbfgs/lib/lib.vcxproj +95 -0
  232. data/core/vendor/src/liblbfgs/ltmain.sh +6426 -0
  233. data/core/vendor/src/liblbfgs/missing +353 -0
  234. data/core/vendor/src/liblbfgs/sample/Makefile.am +15 -0
  235. data/core/vendor/src/liblbfgs/sample/Makefile.in +433 -0
  236. data/core/vendor/src/liblbfgs/sample/sample.c +81 -0
  237. data/core/vendor/src/liblbfgs/sample/sample.cpp +126 -0
  238. data/core/vendor/src/liblbfgs/sample/sample.vcxproj +105 -0
  239. data/core/vendor/src/svm_light/LICENSE.txt +59 -0
  240. data/core/vendor/src/svm_light/Makefile +105 -0
  241. data/core/vendor/src/svm_light/kernel.h +40 -0
  242. data/core/vendor/src/svm_light/svm_classify.c +197 -0
  243. data/core/vendor/src/svm_light/svm_common.c +985 -0
  244. data/core/vendor/src/svm_light/svm_common.h +301 -0
  245. data/core/vendor/src/svm_light/svm_hideo.c +1062 -0
  246. data/core/vendor/src/svm_light/svm_learn.c +4147 -0
  247. data/core/vendor/src/svm_light/svm_learn.h +169 -0
  248. data/core/vendor/src/svm_light/svm_learn_main.c +397 -0
  249. data/core/vendor/src/svm_light/svm_loqo.c +211 -0
  250. data/ext/hack/Rakefile +17 -0
  251. data/ext/hack/support.rb +88 -0
  252. data/lib/opener/opinion_detectors/base.rb +112 -0
  253. data/lib/opener/opinion_detectors/base/version.rb +7 -0
  254. data/lib/opener/opinion_detectors/configuration_creator.rb +86 -0
  255. data/lib/opener/opinion_detectors/de.rb +7 -0
  256. data/lib/opener/opinion_detectors/en.rb +7 -0
  257. data/lib/opener/opinion_detectors/it.rb +7 -0
  258. data/lib/opener/opinion_detectors/nl.rb +6 -0
  259. data/opener-opinion-detector-base.gemspec +35 -0
  260. data/pre_build_requirements.txt +3 -0
  261. metadata +374 -0
@@ -0,0 +1,216 @@
1
+ <?xml version="1.0" encoding="utf-8"?>
2
+ <Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
3
+ <ItemGroup Label="ProjectConfigurations">
4
+ <ProjectConfiguration Include="Debug|Win32">
5
+ <Configuration>Debug</Configuration>
6
+ <Platform>Win32</Platform>
7
+ </ProjectConfiguration>
8
+ <ProjectConfiguration Include="Debug|x64">
9
+ <Configuration>Debug</Configuration>
10
+ <Platform>x64</Platform>
11
+ </ProjectConfiguration>
12
+ <ProjectConfiguration Include="Release|Win32">
13
+ <Configuration>Release</Configuration>
14
+ <Platform>Win32</Platform>
15
+ </ProjectConfiguration>
16
+ <ProjectConfiguration Include="Release|x64">
17
+ <Configuration>Release</Configuration>
18
+ <Platform>x64</Platform>
19
+ </ProjectConfiguration>
20
+ </ItemGroup>
21
+ <PropertyGroup Label="Globals">
22
+ <ProjectGuid>{D6B16F2E-DA86-4591-8B50-348AB7E3432E}</ProjectGuid>
23
+ <RootNamespace>crf</RootNamespace>
24
+ <Keyword>Win32Proj</Keyword>
25
+ </PropertyGroup>
26
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.Default.props" />
27
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="Configuration">
28
+ <ConfigurationType>StaticLibrary</ConfigurationType>
29
+ <CharacterSet>Unicode</CharacterSet>
30
+ <WholeProgramOptimization>true</WholeProgramOptimization>
31
+ </PropertyGroup>
32
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="Configuration">
33
+ <ConfigurationType>StaticLibrary</ConfigurationType>
34
+ <CharacterSet>Unicode</CharacterSet>
35
+ <WholeProgramOptimization>true</WholeProgramOptimization>
36
+ </PropertyGroup>
37
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="Configuration">
38
+ <ConfigurationType>StaticLibrary</ConfigurationType>
39
+ <CharacterSet>Unicode</CharacterSet>
40
+ </PropertyGroup>
41
+ <PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="Configuration">
42
+ <ConfigurationType>StaticLibrary</ConfigurationType>
43
+ <CharacterSet>Unicode</CharacterSet>
44
+ </PropertyGroup>
45
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.props" />
46
+ <ImportGroup Label="ExtensionSettings">
47
+ </ImportGroup>
48
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" Label="PropertySheets">
49
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
50
+ </ImportGroup>
51
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'" Label="PropertySheets">
52
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
53
+ </ImportGroup>
54
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" Label="PropertySheets">
55
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
56
+ </ImportGroup>
57
+ <ImportGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" Label="PropertySheets">
58
+ <Import Project="$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props" Condition="exists('$(UserRootDir)\Microsoft.Cpp.$(Platform).user.props')" Label="LocalAppDataPlatform" />
59
+ </ImportGroup>
60
+ <PropertyGroup Label="UserMacros" />
61
+ <PropertyGroup>
62
+ <_ProjectFileVersion>10.0.30319.1</_ProjectFileVersion>
63
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
64
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(SolutionDir)$(Configuration)\</OutDir>
65
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">$(Configuration)\</IntDir>
66
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">$(Configuration)\</IntDir>
67
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(SolutionDir)$(Configuration)\</OutDir>
68
+ <OutDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(SolutionDir)$(Configuration)\</OutDir>
69
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">$(Configuration)\</IntDir>
70
+ <IntDir Condition="'$(Configuration)|$(Platform)'=='Release|x64'">$(Configuration)\</IntDir>
71
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
72
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
73
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
74
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
75
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'" />
76
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Debug|x64'" />
77
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">AllRules.ruleset</CodeAnalysisRuleSet>
78
+ <CodeAnalysisRuleSet Condition="'$(Configuration)|$(Platform)'=='Release|x64'">AllRules.ruleset</CodeAnalysisRuleSet>
79
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
80
+ <CodeAnalysisRules Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
81
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|Win32'" />
82
+ <CodeAnalysisRuleAssemblies Condition="'$(Configuration)|$(Platform)'=='Release|x64'" />
83
+ </PropertyGroup>
84
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|Win32'">
85
+ <ClCompile>
86
+ <Optimization>Disabled</Optimization>
87
+ <AdditionalIncludeDirectories>$(SolutionDir)include;$(SolutionDir)win32;$(SolutionDir)lib\crf\include;$(SolutionDir)win32\liblbfgs;$(SolutionDir)lib\cqdb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
88
+ <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
89
+ <MinimalRebuild>true</MinimalRebuild>
90
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
91
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
92
+ <FloatingPointModel>Strict</FloatingPointModel>
93
+ <FloatingPointExceptions>true</FloatingPointExceptions>
94
+ <PrecompiledHeader>
95
+ </PrecompiledHeader>
96
+ <WarningLevel>Level3</WarningLevel>
97
+ <DebugInformationFormat>EditAndContinue</DebugInformationFormat>
98
+ </ClCompile>
99
+ <Lib>
100
+ <AdditionalDependencies>lbfgs_debug.lib;%(AdditionalDependencies)</AdditionalDependencies>
101
+ <AdditionalLibraryDirectories>$(SolutionDir)win32\liblbfgs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
102
+ </Lib>
103
+ <ProjectReference>
104
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
105
+ </ProjectReference>
106
+ </ItemDefinitionGroup>
107
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Debug|x64'">
108
+ <ClCompile>
109
+ <Optimization>Disabled</Optimization>
110
+ <AdditionalIncludeDirectories>$(SolutionDir)include;$(SolutionDir)win32;$(SolutionDir)lib\crf\include;$(SolutionDir)win32\liblbfgs;$(SolutionDir)lib\cqdb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
111
+ <PreprocessorDefinitions>WIN32;_DEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
112
+ <BasicRuntimeChecks>EnableFastChecks</BasicRuntimeChecks>
113
+ <RuntimeLibrary>MultiThreadedDebugDLL</RuntimeLibrary>
114
+ <FloatingPointModel>Strict</FloatingPointModel>
115
+ <FloatingPointExceptions>true</FloatingPointExceptions>
116
+ <PrecompiledHeader>
117
+ </PrecompiledHeader>
118
+ <WarningLevel>Level3</WarningLevel>
119
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
120
+ </ClCompile>
121
+ <Lib>
122
+ <AdditionalDependencies>lbfgs_debug.lib;%(AdditionalDependencies)</AdditionalDependencies>
123
+ <AdditionalLibraryDirectories>$(SolutionDir)win32\liblbfgs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
124
+ </Lib>
125
+ <ProjectReference>
126
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
127
+ </ProjectReference>
128
+ </ItemDefinitionGroup>
129
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|Win32'">
130
+ <ClCompile>
131
+ <Optimization>Full</Optimization>
132
+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
133
+ <IntrinsicFunctions>true</IntrinsicFunctions>
134
+ <AdditionalIncludeDirectories>$(SolutionDir)include;$(SolutionDir)win32;$(SolutionDir)lib\crf\include;$(SolutionDir)win32\liblbfgs;$(SolutionDir)lib\cqdb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
135
+ <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
136
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
137
+ <FloatingPointExceptions>true</FloatingPointExceptions>
138
+ <PrecompiledHeader>
139
+ </PrecompiledHeader>
140
+ <WarningLevel>Level1</WarningLevel>
141
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
142
+ </ClCompile>
143
+ <Lib>
144
+ <AdditionalDependencies>lbfgs.lib;%(AdditionalDependencies)</AdditionalDependencies>
145
+ <AdditionalLibraryDirectories>$(SolutionDir)win32\liblbfgs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
146
+ </Lib>
147
+ <ProjectReference>
148
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
149
+ </ProjectReference>
150
+ </ItemDefinitionGroup>
151
+ <ItemDefinitionGroup Condition="'$(Configuration)|$(Platform)'=='Release|x64'">
152
+ <ClCompile>
153
+ <Optimization>Full</Optimization>
154
+ <InlineFunctionExpansion>AnySuitable</InlineFunctionExpansion>
155
+ <IntrinsicFunctions>true</IntrinsicFunctions>
156
+ <AdditionalIncludeDirectories>$(SolutionDir)include;$(SolutionDir)win32;$(SolutionDir)lib\crf\include;$(SolutionDir)win32\liblbfgs;$(SolutionDir)lib\cqdb\include;%(AdditionalIncludeDirectories)</AdditionalIncludeDirectories>
157
+ <PreprocessorDefinitions>WIN32;NDEBUG;_LIB;%(PreprocessorDefinitions)</PreprocessorDefinitions>
158
+ <RuntimeLibrary>MultiThreadedDLL</RuntimeLibrary>
159
+ <FloatingPointExceptions>true</FloatingPointExceptions>
160
+ <PrecompiledHeader>
161
+ </PrecompiledHeader>
162
+ <WarningLevel>Level1</WarningLevel>
163
+ <DebugInformationFormat>ProgramDatabase</DebugInformationFormat>
164
+ </ClCompile>
165
+ <Lib>
166
+ <AdditionalDependencies>lbfgs.lib;%(AdditionalDependencies)</AdditionalDependencies>
167
+ <AdditionalLibraryDirectories>$(SolutionDir)win32\liblbfgs;%(AdditionalLibraryDirectories)</AdditionalLibraryDirectories>
168
+ </Lib>
169
+ <ProjectReference>
170
+ <LinkLibraryDependencies>true</LinkLibraryDependencies>
171
+ </ProjectReference>
172
+ </ItemDefinitionGroup>
173
+ <ItemGroup>
174
+ <ClCompile Include="src\crf1d_encode.c" />
175
+ <ClCompile Include="src\crfsuite.c" />
176
+ <ClCompile Include="src\crfsuite_train.c" />
177
+ <ClCompile Include="src\dataset.c" />
178
+ <ClCompile Include="src\dictionary.c" />
179
+ <ClCompile Include="src\holdout.c" />
180
+ <ClCompile Include="src\logging.c" />
181
+ <ClCompile Include="src\params.c" />
182
+ <ClCompile Include="src\quark.c" />
183
+ <ClCompile Include="src\rumavl.c" />
184
+ <ClCompile Include="src\crf1d_context.c" />
185
+ <ClCompile Include="src\crf1d_feature.c" />
186
+ <ClCompile Include="src\crf1d_model.c" />
187
+ <ClCompile Include="src\crf1d_tag.c" />
188
+ <ClCompile Include="src\train_arow.c" />
189
+ <ClCompile Include="src\train_averaged_perceptron.c" />
190
+ <ClCompile Include="src\train_l2sgd.c" />
191
+ <ClCompile Include="src\train_lbfgs.c" />
192
+ <ClCompile Include="src\train_passive_aggressive.c" />
193
+ </ItemGroup>
194
+ <ItemGroup>
195
+ <ClInclude Include="..\..\include\crfsuite.h" />
196
+ <ClInclude Include="..\..\include\crfsuite.hpp" />
197
+ <ClInclude Include="..\..\include\crfsuite_api.hpp" />
198
+ <ClInclude Include="..\..\include\os.h" />
199
+ <ClInclude Include="src\crfsuite_internal.h" />
200
+ <ClInclude Include="src\logging.h" />
201
+ <ClInclude Include="src\params.h" />
202
+ <ClInclude Include="src\quark.h" />
203
+ <ClInclude Include="src\rumavl.h" />
204
+ <ClInclude Include="src\vecmath.h" />
205
+ <ClInclude Include="src\crf1d.h" />
206
+ </ItemGroup>
207
+ <ItemGroup>
208
+ <ProjectReference Include="..\cqdb\cqdb.vcxproj">
209
+ <Project>{46a23de6-7e34-4429-8f15-fcc3c083fc5b}</Project>
210
+ <ReferenceOutputAssembly>false</ReferenceOutputAssembly>
211
+ </ProjectReference>
212
+ </ItemGroup>
213
+ <Import Project="$(VCTargetsPath)\Microsoft.Cpp.targets" />
214
+ <ImportGroup Label="ExtensionTargets">
215
+ </ImportGroup>
216
+ </Project>
@@ -0,0 +1,353 @@
1
+ /*
2
+ * The 1st-order linear-chain CRF with dyad features (CRF1d).
3
+ *
4
+ * Copyright (c) 2007-2010, Naoaki Okazaki
5
+ * All rights reserved.
6
+ *
7
+ * Redistribution and use in source and binary forms, with or without
8
+ * modification, are permitted provided that the following conditions are met:
9
+ * * Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ * * Redistributions in binary form must reproduce the above copyright
12
+ * notice, this list of conditions and the following disclaimer in the
13
+ * documentation and/or other materials provided with the distribution.
14
+ * * Neither the names of the authors nor the names of its contributors
15
+ * may be used to endorse or promote products derived from this
16
+ * software without specific prior written permission.
17
+ *
18
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
19
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
20
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
21
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER
22
+ * OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL,
23
+ * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO,
24
+ * PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR
25
+ * PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
26
+ * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
27
+ * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
28
+ * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
29
+ */
30
+
31
+ /* $Id$ */
32
+
33
+ #ifndef __CRF1D_H__
34
+ #define __CRF1D_H__
35
+
36
+ #include <crfsuite.h>
37
+ #include "crfsuite_internal.h"
38
+
39
+
40
+ /**
41
+ * \defgroup crf1d_context.c
42
+ */
43
+ /** @{ */
44
+
45
+ /**
46
+ * Functionality flags for contexts.
47
+ * @see crf1dc_new().
48
+ */
49
+ enum {
50
+ CTXF_BASE = 0x01,
51
+ CTXF_VITERBI = 0x01,
52
+ CTXF_MARGINALS = 0x02,
53
+ CTXF_ALL = 0xFF,
54
+ };
55
+
56
+ /**
57
+ * Reset flags.
58
+ * @see crf1dc_reset().
59
+ */
60
+ enum {
61
+ RF_STATE = 0x01, /**< Reset state scores. */
62
+ RF_TRANS = 0x02, /**< Reset transition scores. */
63
+ RF_ALL = 0xFF, /**< Reset all. */
64
+ };
65
+
66
+ /**
67
+ * Context structure.
68
+ * This structure maintains internal data for an instance.
69
+ */
70
+ typedef struct {
71
+ /**
72
+ * Flag specifying the functionality.
73
+ */
74
+ int flag;
75
+
76
+ /**
77
+ * The total number of distinct labels (L).
78
+ */
79
+ int num_labels;
80
+
81
+ /**
82
+ * The number of items (T) in the instance.
83
+ */
84
+ int num_items;
85
+
86
+ /**
87
+ * The maximum number of labels.
88
+ */
89
+ int cap_items;
90
+
91
+ /**
92
+ * Logarithm of the normalization factor for the instance.
93
+ * This is equivalent to the total scores of all paths in the lattice.
94
+ */
95
+ floatval_t log_norm;
96
+
97
+ /**
98
+ * State scores.
99
+ * This is a [T][L] matrix whose element [t][l] presents total score
100
+ * of state features associating label #l at #t.
101
+ */
102
+ floatval_t *state;
103
+
104
+ /**
105
+ * Transition scores.
106
+ * This is a [L][L] matrix whose element [i][j] represents the total
107
+ * score of transition features associating labels #i and #j.
108
+ */
109
+ floatval_t *trans;
110
+
111
+ /**
112
+ * Alpha score matrix.
113
+ * This is a [T][L] matrix whose element [t][l] presents the total
114
+ * score of paths starting at BOS and arraiving at (t, l).
115
+ */
116
+ floatval_t *alpha_score;
117
+
118
+ /**
119
+ * Beta score matrix.
120
+ * This is a [T][L] matrix whose element [t][l] presents the total
121
+ * score of paths starting at (t, l) and arraiving at EOS.
122
+ */
123
+ floatval_t *beta_score;
124
+
125
+ /**
126
+ * Scale factor vector.
127
+ * This is a [T] vector whose element [t] presents the scaling
128
+ * coefficient for the alpha_score and beta_score.
129
+ */
130
+ floatval_t *scale_factor;
131
+
132
+ /**
133
+ * Row vector (work space).
134
+ * This is a [T] vector used internally for a work space.
135
+ */
136
+ floatval_t *row;
137
+
138
+ /**
139
+ * Backward edges.
140
+ * This is a [T][L] matrix whose element [t][j] represents the label #i
141
+ * that yields the maximum score to arrive at (t, j).
142
+ * This member is available only with CTXF_VITERBI flag enabled.
143
+ */
144
+ int *backward_edge;
145
+
146
+ /**
147
+ * Exponents of state scores.
148
+ * This is a [T][L] matrix whose element [t][l] presents the exponent
149
+ * of the total score of state features associating label #l at #t.
150
+ * This member is available only with CTXF_MARGINALS flag.
151
+ */
152
+ floatval_t *exp_state;
153
+
154
+ /**
155
+ * Exponents of transition scores.
156
+ * This is a [L][L] matrix whose element [i][j] represents the exponent
157
+ * of the total score of transition features associating labels #i and #j.
158
+ * This member is available only with CTXF_MARGINALS flag.
159
+ */
160
+ floatval_t *exp_trans;
161
+
162
+ /**
163
+ * Model expectations of states.
164
+ * This is a [T][L] matrix whose element [t][l] presents the model
165
+ * expectation (marginal probability) of the state (t,l)
166
+ * This member is available only with CTXF_MARGINALS flag.
167
+ */
168
+ floatval_t *mexp_state;
169
+
170
+ /**
171
+ * Model expectations of transitions.
172
+ * This is a [L][L] matrix whose element [i][j] presents the model
173
+ * expectation of the transition (i--j).
174
+ * This member is available only with CTXF_MARGINALS flag.
175
+ */
176
+ floatval_t *mexp_trans;
177
+
178
+ } crf1d_context_t;
179
+
180
+ #define MATRIX(p, xl, x, y) ((p)[(xl) * (y) + (x)])
181
+
182
+ #define ALPHA_SCORE(ctx, t) \
183
+ (&MATRIX(ctx->alpha_score, ctx->num_labels, 0, t))
184
+ #define BETA_SCORE(ctx, t) \
185
+ (&MATRIX(ctx->beta_score, ctx->num_labels, 0, t))
186
+ #define STATE_SCORE(ctx, i) \
187
+ (&MATRIX(ctx->state, ctx->num_labels, 0, i))
188
+ #define TRANS_SCORE(ctx, i) \
189
+ (&MATRIX(ctx->trans, ctx->num_labels, 0, i))
190
+ #define EXP_STATE_SCORE(ctx, i) \
191
+ (&MATRIX(ctx->exp_state, ctx->num_labels, 0, i))
192
+ #define EXP_TRANS_SCORE(ctx, i) \
193
+ (&MATRIX(ctx->exp_trans, ctx->num_labels, 0, i))
194
+ #define STATE_MEXP(ctx, i) \
195
+ (&MATRIX(ctx->mexp_state, ctx->num_labels, 0, i))
196
+ #define TRANS_MEXP(ctx, i) \
197
+ (&MATRIX(ctx->mexp_trans, ctx->num_labels, 0, i))
198
+ #define BACKWARD_EDGE_AT(ctx, t) \
199
+ (&MATRIX(ctx->backward_edge, ctx->num_labels, 0, t))
200
+
201
+ crf1d_context_t* crf1dc_new(int flag, int L, int T);
202
+ int crf1dc_set_num_items(crf1d_context_t* ctx, int T);
203
+ void crf1dc_delete(crf1d_context_t* ctx);
204
+ void crf1dc_reset(crf1d_context_t* ctx, int flag);
205
+ void crf1dc_exp_state(crf1d_context_t* ctx);
206
+ void crf1dc_exp_transition(crf1d_context_t* ctx);
207
+ void crf1dc_alpha_score(crf1d_context_t* ctx);
208
+ void crf1dc_beta_score(crf1d_context_t* ctx);
209
+ void crf1dc_marginals(crf1d_context_t* ctx);
210
+ floatval_t crf1dc_marginal_point(crf1d_context_t *ctx, int l, int t);
211
+ floatval_t crf1dc_marginal_path(crf1d_context_t *ctx, const int *path, int begin, int end);
212
+ floatval_t crf1dc_score(crf1d_context_t* ctx, const int *labels);
213
+ floatval_t crf1dc_lognorm(crf1d_context_t* ctx);
214
+ floatval_t crf1dc_viterbi(crf1d_context_t* ctx, int *labels);
215
+ void crf1dc_debug_context(FILE *fp);
216
+
217
+ /** @} */
218
+
219
+
220
+
221
+ /**
222
+ * \defgroup crf1d_feature.c
223
+ */
224
+ /** @{ */
225
+
226
+ /**
227
+ * Feature type.
228
+ */
229
+ enum {
230
+ FT_STATE = 0, /**< State features. */
231
+ FT_TRANS, /**< Transition features. */
232
+ };
233
+
234
+ /**
235
+ * A feature (for either state or transition).
236
+ */
237
+ typedef struct {
238
+ /**
239
+ * Feature type.
240
+ * Possible values are:
241
+ * - FT_STATE (0) for state features.
242
+ * - FT_TRANS (1) for transition features.
243
+ */
244
+ int type;
245
+
246
+ /**
247
+ * Source id.
248
+ * The semantic of this field depends on the feature type:
249
+ * - attribute id for state features (type == 0).
250
+ * - output label id for transition features (type != 0).
251
+ */
252
+ int src;
253
+
254
+ /**
255
+ * Destination id.
256
+ * Label id emitted by this feature.
257
+ */
258
+ int dst;
259
+
260
+ /**
261
+ * Frequency (observation expectation).
262
+ */
263
+ floatval_t freq;
264
+ } crf1df_feature_t;
265
+
266
+ /**
267
+ * Feature references.
268
+ * This is a collection of feature ids used for faster accesses.
269
+ */
270
+ typedef struct {
271
+ int num_features; /**< Number of features referred */
272
+ int* fids; /**< Array of feature ids */
273
+ } feature_refs_t;
274
+
275
+ crf1df_feature_t* crf1df_generate(
276
+ int *ptr_num_features,
277
+ dataset_t *ds,
278
+ int num_labels,
279
+ int num_attributes,
280
+ int connect_all_attrs,
281
+ int connect_all_edges,
282
+ floatval_t minfreq,
283
+ crfsuite_logging_callback func,
284
+ void *instance
285
+ );
286
+
287
+ int crf1df_init_references(
288
+ feature_refs_t **ptr_attributes,
289
+ feature_refs_t **ptr_trans,
290
+ const crf1df_feature_t *features,
291
+ const int K,
292
+ const int A,
293
+ const int L
294
+ );
295
+
296
+ /** @} */
297
+
298
+
299
+
300
+ /**
301
+ * \defgroup crf1d_model.c
302
+ */
303
+ /** @{ */
304
+
305
+ struct tag_crf1dm;
306
+ typedef struct tag_crf1dm crf1dm_t;
307
+
308
+ struct tag_crf1dmw;
309
+ typedef struct tag_crf1dmw crf1dmw_t;
310
+
311
+ typedef struct {
312
+ int type;
313
+ int src;
314
+ int dst;
315
+ floatval_t weight;
316
+ } crf1dm_feature_t;
317
+
318
+ crf1dmw_t* crf1mmw(const char *filename);
319
+ int crf1dmw_close(crf1dmw_t* writer);
320
+ int crf1dmw_open_labels(crf1dmw_t* writer, int num_labels);
321
+ int crf1dmw_close_labels(crf1dmw_t* writer);
322
+ int crf1dmw_put_label(crf1dmw_t* writer, int lid, const char *value);
323
+ int crf1dmw_open_attrs(crf1dmw_t* writer, int num_attributes);
324
+ int crf1dmw_close_attrs(crf1dmw_t* writer);
325
+ int crf1dmw_put_attr(crf1dmw_t* writer, int aid, const char *value);
326
+ int crf1dmw_open_labelrefs(crf1dmw_t* writer, int num_labels);
327
+ int crf1dmw_close_labelrefs(crf1dmw_t* writer);
328
+ int crf1dmw_put_labelref(crf1dmw_t* writer, int lid, const feature_refs_t* ref, int *map);
329
+ int crf1dmw_open_attrrefs(crf1dmw_t* writer, int num_attrs);
330
+ int crf1dmw_close_attrrefs(crf1dmw_t* writer);
331
+ int crf1dmw_put_attrref(crf1dmw_t* writer, int aid, const feature_refs_t* ref, int *map);
332
+ int crf1dmw_open_features(crf1dmw_t* writer);
333
+ int crf1dmw_close_features(crf1dmw_t* writer);
334
+ int crf1dmw_put_feature(crf1dmw_t* writer, int fid, const crf1dm_feature_t* f);
335
+
336
+ crf1dm_t* crf1dm_new(const char *filename);
337
+ void crf1dm_close(crf1dm_t* model);
338
+ int crf1dm_get_num_attrs(crf1dm_t* model);
339
+ int crf1dm_get_num_labels(crf1dm_t* model);
340
+ const char *crf1dm_to_label(crf1dm_t* model, int lid);
341
+ int crf1dm_to_lid(crf1dm_t* model, const char *value);
342
+ int crf1dm_to_aid(crf1dm_t* model, const char *value);
343
+ const char *crf1dm_to_attr(crf1dm_t* model, int aid);
344
+ int crf1dm_get_labelref(crf1dm_t* model, int lid, feature_refs_t* ref);
345
+ int crf1dm_get_attrref(crf1dm_t* model, int aid, feature_refs_t* ref);
346
+ int crf1dm_get_featureid(feature_refs_t* ref, int i);
347
+ int crf1dm_get_feature(crf1dm_t* model, int fid, crf1dm_feature_t* f);
348
+ void crf1dm_dump(crf1dm_t* model, FILE *fp);
349
+
350
+ /** @} */
351
+
352
+
353
+ #endif/*__CRF1D_H__*/