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,63 @@
1
+ /* ----------------------------------------------------------------------------
2
+ * This file was automatically generated by SWIG (http://www.swig.org).
3
+ * Version 2.0.4
4
+ *
5
+ * This file is not intended to be easily readable and contains a number of
6
+ * coding conventions designed to improve portability and efficiency. Do not make
7
+ * changes to this file unless you know what you are doing--modify the SWIG
8
+ * interface file instead.
9
+ * ----------------------------------------------------------------------------- */
10
+
11
+ #ifndef SWIG_crfsuite_WRAP_H_
12
+ #define SWIG_crfsuite_WRAP_H_
13
+
14
+ #include <map>
15
+ #include <string>
16
+
17
+
18
+ class SwigDirector_Trainer : public CRFSuite::Trainer, public Swig::Director {
19
+
20
+ public:
21
+ SwigDirector_Trainer(PyObject *self);
22
+ virtual ~SwigDirector_Trainer();
23
+ virtual void message(std::string const &msg);
24
+
25
+
26
+ /* Internal Director utilities */
27
+ public:
28
+ bool swig_get_inner(const char* swig_protected_method_name) const {
29
+ std::map<std::string, bool>::const_iterator iv = swig_inner.find(swig_protected_method_name);
30
+ return (iv != swig_inner.end() ? iv->second : false);
31
+ }
32
+
33
+ void swig_set_inner(const char* swig_protected_method_name, bool val) const
34
+ { swig_inner[swig_protected_method_name] = val;}
35
+
36
+ private:
37
+ mutable std::map<std::string, bool> swig_inner;
38
+
39
+
40
+ #if defined(SWIG_PYTHON_DIRECTOR_VTABLE)
41
+ /* VTable implementation */
42
+ PyObject *swig_get_method(size_t method_index, const char *method_name) const {
43
+ PyObject *method = vtable[method_index];
44
+ if (!method) {
45
+ swig::SwigVar_PyObject name = SWIG_Python_str_FromChar(method_name);
46
+ method = PyObject_GetAttr(swig_get_self(), name);
47
+ if (!method) {
48
+ std::string msg = "Method in class Trainer doesn't exist, undefined ";
49
+ msg += method_name;
50
+ Swig::DirectorMethodException::raise(msg.c_str());
51
+ }
52
+ vtable[method_index] = method;
53
+ };
54
+ return method;
55
+ }
56
+ private:
57
+ mutable swig::SwigVar_PyObject vtable[1];
58
+ #endif
59
+
60
+ };
61
+
62
+
63
+ #endif
@@ -0,0 +1,9 @@
1
+ #!/bin/sh
2
+
3
+ ln -s ../crfsuite.cpp
4
+ ln -s ../export.i
5
+
6
+ if [ "$1" = "--swig" ];
7
+ then
8
+ swig -c++ -python -I../../include -o export_wrap.cpp export.i
9
+ fi
@@ -0,0 +1,52 @@
1
+ #!/usr/bin/env python
2
+
3
+ import crfsuite
4
+ import sys
5
+
6
+ def instances(fi):
7
+ xseq = crfsuite.ItemSequence()
8
+
9
+ for line in fi:
10
+ line = line.strip('\n')
11
+ if not line:
12
+ # An empty line presents an end of a sequence.
13
+ yield xseq
14
+ xseq = crfsuite.ItemSequence()
15
+ continue
16
+
17
+ # Split the line with TAB characters.
18
+ fields = line.split('\t')
19
+ item = crfsuite.Item()
20
+ for field in fields[1:]:
21
+ p = field.rfind(':')
22
+ if p == -1:
23
+ # Unweighted (weight=1) attribute.
24
+ item.append(crfsuite.Attribute(field))
25
+ else:
26
+ # Weighted attribute
27
+ item.append(crfsuite.Attribute(field[:p], float(field[p+1:])))
28
+
29
+ # Append the item to the item sequence.
30
+ xseq.append(item)
31
+
32
+ if __name__ == '__main__':
33
+ fi = sys.stdin
34
+ fo = sys.stdout
35
+
36
+ # Create a tagger object.
37
+ tagger = crfsuite.Tagger()
38
+
39
+ # Load the model to the tagger.
40
+ tagger.open(sys.argv[1])
41
+
42
+ for xseq in instances(fi):
43
+ # Tag the sequence.
44
+ tagger.set(xseq)
45
+ # Obtain the label sequence predicted by the tagger.
46
+ yseq = tagger.viterbi()
47
+ # Output the probability of the predicted label sequence.
48
+ print tagger.probability(yseq)
49
+ for t, y in enumerate(yseq):
50
+ # Output the predicted labels with their marginal probabilities.
51
+ print '%s:%f' % (y, tagger.marginal(y, t))
52
+ print
@@ -0,0 +1,68 @@
1
+ #!/usr/bin/env python
2
+
3
+ import crfsuite
4
+ import sys
5
+
6
+ # Inherit crfsuite.Trainer to implement message() function, which receives
7
+ # progress messages from a training process.
8
+ class Trainer(crfsuite.Trainer):
9
+ def message(self, s):
10
+ # Simply output the progress messages to STDOUT.
11
+ sys.stdout.write(s)
12
+
13
+ def instances(fi):
14
+ xseq = crfsuite.ItemSequence()
15
+ yseq = crfsuite.StringList()
16
+
17
+ for line in fi:
18
+ line = line.strip('\n')
19
+ if not line:
20
+ # An empty line presents an end of a sequence.
21
+ yield xseq, tuple(yseq)
22
+ xseq = crfsuite.ItemSequence()
23
+ yseq = crfsuite.StringList()
24
+ continue
25
+
26
+ # Split the line with TAB characters.
27
+ fields = line.split('\t')
28
+
29
+ # Append attributes to the item.
30
+ item = crfsuite.Item()
31
+ for field in fields[1:]:
32
+ p = field.rfind(':')
33
+ if p == -1:
34
+ # Unweighted (weight=1) attribute.
35
+ item.append(crfsuite.Attribute(field))
36
+ else:
37
+ # Weighted attribute
38
+ item.append(crfsuite.Attribute(field[:p], float(field[p+1:])))
39
+
40
+ # Append the item to the item sequence.
41
+ xseq.append(item)
42
+ # Append the label to the label sequence.
43
+ yseq.append(fields[0])
44
+
45
+ if __name__ == '__main__':
46
+ # This demonstrates how to obtain the version string of CRFsuite.
47
+ print crfsuite.version()
48
+
49
+ # Create a Trainer object.
50
+ trainer = Trainer()
51
+
52
+ # Read training instances from STDIN, and set them to trainer.
53
+ for xseq, yseq in instances(sys.stdin):
54
+ trainer.append(xseq, yseq, 0)
55
+
56
+ # Use L2-regularized SGD and 1st-order dyad features.
57
+ trainer.select('l2sgd', 'crf1d')
58
+
59
+ # This demonstrates how to list parameters and obtain their values.
60
+ for name in trainer.params():
61
+ print name, trainer.get(name), trainer.help(name)
62
+
63
+ # Set the coefficient for L2 regularization to 0.1
64
+ trainer.set('c2', '0.1')
65
+
66
+ # Start training; the training process will invoke trainer.message()
67
+ # to report the progress.
68
+ trainer.train(sys.argv[1], -1)
@@ -0,0 +1,44 @@
1
+ #!/usr/bin/env python
2
+
3
+ """
4
+ setup.py file for SWIG example
5
+ """
6
+
7
+ import sys
8
+ import os.path
9
+
10
+ def get_rootdir():
11
+ return '/home/users/okazaki/local'
12
+ def get_includedir():
13
+ return os.path.join(get_rootdir(), 'include')
14
+ def get_librarydir():
15
+ return os.path.join(get_rootdir(), 'lib')
16
+
17
+ import os; os.environ['CC'] = 'g++'; os.environ['CXX'] = 'g++';
18
+ os.environ['CPP'] = 'g++'; os.environ['LDSHARED'] = 'g++'
19
+
20
+ from distutils.core import setup, Extension
21
+
22
+ crfsuite_module = Extension(
23
+ '_crfsuite',
24
+ sources = [
25
+ 'crfsuite.cpp',
26
+ 'export_wrap.cpp',
27
+ ],
28
+ # include_dirs=['../../include',],
29
+ extra_link_args=['-shared'],
30
+ # library_dirs=['../../lib/crf',],
31
+ libraries=['crfsuite'],
32
+ # extra_objects=['../../lib/crf/libcrfsuite.la'],
33
+ language='c++',
34
+ )
35
+
36
+ setup(
37
+ name = '@PACKAGE@',
38
+ version = '@VERSION@',
39
+ author = 'Naoaki Okazaki',
40
+ description = """CRFSuite Python module""",
41
+ ext_modules = [crfsuite_module],
42
+ py_modules = ["crfsuite"],
43
+ )
44
+
@@ -0,0 +1,679 @@
1
+ /* A portable stdint.h
2
+ *
3
+ * Copyright (c) 2005-2007 Paul Hsieh
4
+ *
5
+ * Redistribution and use in source and binary forms, with or without
6
+ * modification, are permitted provided that the following conditions
7
+ * are met:
8
+ *
9
+ * Redistributions of source code must retain the above copyright
10
+ * notice, this list of conditions and the following disclaimer.
11
+ *
12
+ * Redistributions in binary form must not misrepresent the orignal
13
+ * source in the documentation and/or other materials provided
14
+ * with the distribution.
15
+ *
16
+ * The names of the authors nor its contributors may be used to
17
+ * endorse or promote products derived from this software without
18
+ * specific prior written permission.
19
+ *
20
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
21
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
22
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
23
+ * FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
24
+ * COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
25
+ * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
26
+ * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
27
+ * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
28
+ * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
29
+ * STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
30
+ * ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED
31
+ * OF THE POSSIBILITY OF SUCH DAMAGE.
32
+ *
33
+ ****************************************************************************
34
+ *
35
+ * Version 0.1.8
36
+ *
37
+ * The ANSI C standard committee, for the C99 standard, specified the
38
+ * inclusion of a new standard include file called stdint.h. This is
39
+ * a very useful and long desired include file which contains several
40
+ * very precise definitions for integer scalar types that is
41
+ * critically important for making portable several classes of
42
+ * applications including cryptography, hashing, variable length
43
+ * integer libraries and so on. But for most developers its likely
44
+ * useful just for programming sanity.
45
+ *
46
+ * The problem is that most compiler vendors have decided not to
47
+ * implement the C99 standard, and the next C++ language standard
48
+ * (which has a lot more mindshare these days) will be a long time in
49
+ * coming and its unknown whether or not it will include stdint.h or
50
+ * how much adoption it will have. Either way, it will be a long time
51
+ * before all compilers come with a stdint.h and it also does nothing
52
+ * for the extremely large number of compilers available today which
53
+ * do not include this file, or anything comparable to it.
54
+ *
55
+ * So that's what this file is all about. Its an attempt to build a
56
+ * single universal include file that works on as many platforms as
57
+ * possible to deliver what stdint.h is supposed to. A few things
58
+ * that should be noted about this file:
59
+ *
60
+ * 1) It is not guaranteed to be portable and/or present an identical
61
+ * interface on all platforms. The extreme variability of the
62
+ * ANSI C standard makes this an impossibility right from the
63
+ * very get go. Its really only meant to be useful for the vast
64
+ * majority of platforms that possess the capability of
65
+ * implementing usefully and precisely defined, standard sized
66
+ * integer scalars. Systems which are not intrinsically 2s
67
+ * complement may produce invalid constants.
68
+ *
69
+ * 2) There is an unavoidable use of non-reserved symbols.
70
+ *
71
+ * 3) Other standard include files are invoked.
72
+ *
73
+ * 4) This file may come in conflict with future platforms that do
74
+ * include stdint.h. The hope is that one or the other can be
75
+ * used with no real difference.
76
+ *
77
+ * 5) In the current verison, if your platform can't represent
78
+ * int32_t, int16_t and int8_t, it just dumps out with a compiler
79
+ * error.
80
+ *
81
+ * 6) 64 bit integers may or may not be defined. Test for their
82
+ * presence with the test: #ifdef INT64_MAX or #ifdef UINT64_MAX.
83
+ * Note that this is different from the C99 specification which
84
+ * requires the existence of 64 bit support in the compiler. If
85
+ * this is not defined for your platform, yet it is capable of
86
+ * dealing with 64 bits then it is because this file has not yet
87
+ * been extended to cover all of your system's capabilities.
88
+ *
89
+ * 7) (u)intptr_t may or may not be defined. Test for its presence
90
+ * with the test: #ifdef PTRDIFF_MAX. If this is not defined
91
+ * for your platform, then it is because this file has not yet
92
+ * been extended to cover all of your system's capabilities, not
93
+ * because its optional.
94
+ *
95
+ * 8) The following might not been defined even if your platform is
96
+ * capable of defining it:
97
+ *
98
+ * WCHAR_MIN
99
+ * WCHAR_MAX
100
+ * (u)int64_t
101
+ * PTRDIFF_MIN
102
+ * PTRDIFF_MAX
103
+ * (u)intptr_t
104
+ *
105
+ * 9) The following have not been defined:
106
+ *
107
+ * WINT_MIN
108
+ * WINT_MAX
109
+ *
110
+ * 10) The criteria for defining (u)int_least(*)_t isn't clear,
111
+ * except for systems which don't have a type that precisely
112
+ * defined 8, 16, or 32 bit types (which this include file does
113
+ * not support anyways). Default definitions have been given.
114
+ *
115
+ * 11) The criteria for defining (u)int_fast(*)_t isn't something I
116
+ * would trust to any particular compiler vendor or the ANSI C
117
+ * committee. It is well known that "compatible systems" are
118
+ * commonly created that have very different performance
119
+ * characteristics from the systems they are compatible with,
120
+ * especially those whose vendors make both the compiler and the
121
+ * system. Default definitions have been given, but its strongly
122
+ * recommended that users never use these definitions for any
123
+ * reason (they do *NOT* deliver any serious guarantee of
124
+ * improved performance -- not in this file, nor any vendor's
125
+ * stdint.h).
126
+ *
127
+ * 12) The following macros:
128
+ *
129
+ * PRINTF_INTMAX_MODIFIER
130
+ * PRINTF_INT64_MODIFIER
131
+ * PRINTF_INT32_MODIFIER
132
+ * PRINTF_INT16_MODIFIER
133
+ * PRINTF_LEAST64_MODIFIER
134
+ * PRINTF_LEAST32_MODIFIER
135
+ * PRINTF_LEAST16_MODIFIER
136
+ * PRINTF_INTPTR_MODIFIER
137
+ *
138
+ * are strings which have been defined as the modifiers required
139
+ * for the "d", "u" and "x" printf formats to correctly output
140
+ * (u)intmax_t, (u)int64_t, (u)int32_t, (u)int16_t, (u)least64_t,
141
+ * (u)least32_t, (u)least16_t and (u)intptr_t types respectively.
142
+ * PRINTF_INTPTR_MODIFIER is not defined for some systems which
143
+ * provide their own stdint.h. PRINTF_INT64_MODIFIER is not
144
+ * defined if INT64_MAX is not defined. These are an extension
145
+ * beyond what C99 specifies must be in stdint.h.
146
+ *
147
+ * In addition, the following macros are defined:
148
+ *
149
+ * PRINTF_INTMAX_HEX_WIDTH
150
+ * PRINTF_INT64_HEX_WIDTH
151
+ * PRINTF_INT32_HEX_WIDTH
152
+ * PRINTF_INT16_HEX_WIDTH
153
+ * PRINTF_INT8_HEX_WIDTH
154
+ * PRINTF_INTMAX_DEC_WIDTH
155
+ * PRINTF_INT64_DEC_WIDTH
156
+ * PRINTF_INT32_DEC_WIDTH
157
+ * PRINTF_INT16_DEC_WIDTH
158
+ * PRINTF_INT8_DEC_WIDTH
159
+ *
160
+ * Which specifies the maximum number of characters required to
161
+ * print the number of that type in either hexadecimal or decimal.
162
+ * These are an extension beyond what C99 specifies must be in
163
+ * stdint.h.
164
+ *
165
+ * Compilers tested (all with 0 warnings at their highest respective
166
+ * settings): Borland Turbo C 2.0, WATCOM C/C++ 11.0 (16 bits and 32
167
+ * bits), Microsoft Visual C++ 6.0 (32 bit), Microsoft Visual Studio
168
+ * .net (VC7), Intel C++ 4.0, GNU gcc v3.3.3
169
+ *
170
+ * This file should be considered a work in progress. Suggestions for
171
+ * improvements, especially those which increase coverage are strongly
172
+ * encouraged.
173
+ *
174
+ * Acknowledgements
175
+ *
176
+ * The following people have made significant contributions to the
177
+ * development and testing of this file:
178
+ *
179
+ * Chris Howie
180
+ * John Steele Scott
181
+ * Dave Thorup
182
+ *
183
+ */
184
+
185
+ #include <stddef.h>
186
+ #include <limits.h>
187
+ #include <signal.h>
188
+
189
+ /*
190
+ * For gcc with _STDINT_H, fill in the PRINTF_INT*_MODIFIER macros, and
191
+ * do nothing else. On the Mac OS X version of gcc this is _STDINT_H_.
192
+ */
193
+
194
+ #if ((defined(__STDC__) && __STDC__ && __STDC_VERSION__ >= 199901L) || (defined (__WATCOMC__) && (defined (_STDINT_H_INCLUDED) || __WATCOMC__ >= 1250)) || (defined(__GNUC__) && (defined(_STDINT_H) || defined(_STDINT_H_)) )) && !defined (_PSTDINT_H_INCLUDED)
195
+ #include <stdint.h>
196
+ #define _PSTDINT_H_INCLUDED
197
+ # ifndef PRINTF_INT64_MODIFIER
198
+ # define PRINTF_INT64_MODIFIER "ll"
199
+ # endif
200
+ # ifndef PRINTF_INT32_MODIFIER
201
+ # define PRINTF_INT32_MODIFIER "l"
202
+ # endif
203
+ # ifndef PRINTF_INT16_MODIFIER
204
+ # define PRINTF_INT16_MODIFIER "h"
205
+ # endif
206
+ # ifndef PRINTF_INTMAX_MODIFIER
207
+ # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
208
+ # endif
209
+ # ifndef PRINTF_INT64_HEX_WIDTH
210
+ # define PRINTF_INT64_HEX_WIDTH "16"
211
+ # endif
212
+ # ifndef PRINTF_INT32_HEX_WIDTH
213
+ # define PRINTF_INT32_HEX_WIDTH "8"
214
+ # endif
215
+ # ifndef PRINTF_INT16_HEX_WIDTH
216
+ # define PRINTF_INT16_HEX_WIDTH "4"
217
+ # endif
218
+ # ifndef PRINTF_INT8_HEX_WIDTH
219
+ # define PRINTF_INT8_HEX_WIDTH "2"
220
+ # endif
221
+ # ifndef PRINTF_INT64_DEC_WIDTH
222
+ # define PRINTF_INT64_DEC_WIDTH "20"
223
+ # endif
224
+ # ifndef PRINTF_INT32_DEC_WIDTH
225
+ # define PRINTF_INT32_DEC_WIDTH "10"
226
+ # endif
227
+ # ifndef PRINTF_INT16_DEC_WIDTH
228
+ # define PRINTF_INT16_DEC_WIDTH "5"
229
+ # endif
230
+ # ifndef PRINTF_INT8_DEC_WIDTH
231
+ # define PRINTF_INT8_DEC_WIDTH "3"
232
+ # endif
233
+ # ifndef PRINTF_INTMAX_HEX_WIDTH
234
+ # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
235
+ # endif
236
+ # ifndef PRINTF_INTMAX_DEC_WIDTH
237
+ # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
238
+ # endif
239
+ #endif
240
+
241
+ #ifndef _PSTDINT_H_INCLUDED
242
+ #define _PSTDINT_H_INCLUDED
243
+
244
+ #ifndef SIZE_MAX
245
+ # define SIZE_MAX (~(size_t)0)
246
+ #endif
247
+
248
+ /*
249
+ * Deduce the type assignments from limits.h under the assumption that
250
+ * integer sizes in bits are powers of 2, and follow the ANSI
251
+ * definitions.
252
+ */
253
+
254
+ #ifndef UINT8_MAX
255
+ # define UINT8_MAX 0xff
256
+ #endif
257
+ #ifndef uint8_t
258
+ # if (UCHAR_MAX == UINT8_MAX) || defined (S_SPLINT_S)
259
+ typedef unsigned char uint8_t;
260
+ # define UINT8_C(v) ((uint8_t) v)
261
+ # else
262
+ # error "Platform not supported"
263
+ # endif
264
+ #endif
265
+
266
+ #ifndef INT8_MAX
267
+ # define INT8_MAX 0x7f
268
+ #endif
269
+ #ifndef INT8_MIN
270
+ # define INT8_MIN INT8_C(0x80)
271
+ #endif
272
+ #ifndef int8_t
273
+ # if (SCHAR_MAX == INT8_MAX) || defined (S_SPLINT_S)
274
+ typedef signed char int8_t;
275
+ # define INT8_C(v) ((int8_t) v)
276
+ # else
277
+ # error "Platform not supported"
278
+ # endif
279
+ #endif
280
+
281
+ #ifndef UINT16_MAX
282
+ # define UINT16_MAX 0xffff
283
+ #endif
284
+ #ifndef uint16_t
285
+ #if (UINT_MAX == UINT16_MAX) || defined (S_SPLINT_S)
286
+ typedef unsigned int uint16_t;
287
+ # ifndef PRINTF_INT16_MODIFIER
288
+ # define PRINTF_INT16_MODIFIER ""
289
+ # endif
290
+ # define UINT16_C(v) ((uint16_t) (v))
291
+ #elif (USHRT_MAX == UINT16_MAX)
292
+ typedef unsigned short uint16_t;
293
+ # define UINT16_C(v) ((uint16_t) (v))
294
+ # ifndef PRINTF_INT16_MODIFIER
295
+ # define PRINTF_INT16_MODIFIER "h"
296
+ # endif
297
+ #else
298
+ #error "Platform not supported"
299
+ #endif
300
+ #endif
301
+
302
+ #ifndef INT16_MAX
303
+ # define INT16_MAX 0x7fff
304
+ #endif
305
+ #ifndef INT16_MIN
306
+ # define INT16_MIN INT16_C(0x8000)
307
+ #endif
308
+ #ifndef int16_t
309
+ #if (INT_MAX == INT16_MAX) || defined (S_SPLINT_S)
310
+ typedef signed int int16_t;
311
+ # define INT16_C(v) ((int16_t) (v))
312
+ # ifndef PRINTF_INT16_MODIFIER
313
+ # define PRINTF_INT16_MODIFIER ""
314
+ # endif
315
+ #elif (SHRT_MAX == INT16_MAX)
316
+ typedef signed short int16_t;
317
+ # define INT16_C(v) ((int16_t) (v))
318
+ # ifndef PRINTF_INT16_MODIFIER
319
+ # define PRINTF_INT16_MODIFIER "h"
320
+ # endif
321
+ #else
322
+ #error "Platform not supported"
323
+ #endif
324
+ #endif
325
+
326
+ #ifndef UINT32_MAX
327
+ # define UINT32_MAX (0xffffffffUL)
328
+ #endif
329
+ #ifndef uint32_t
330
+ #if (ULONG_MAX == UINT32_MAX) || defined (S_SPLINT_S)
331
+ typedef unsigned long uint32_t;
332
+ # define UINT32_C(v) v ## UL
333
+ # ifndef PRINTF_INT32_MODIFIER
334
+ # define PRINTF_INT32_MODIFIER "l"
335
+ # endif
336
+ #elif (UINT_MAX == UINT32_MAX)
337
+ typedef unsigned int uint32_t;
338
+ # ifndef PRINTF_INT32_MODIFIER
339
+ # define PRINTF_INT32_MODIFIER ""
340
+ # endif
341
+ # define UINT32_C(v) v ## U
342
+ #elif (USHRT_MAX == UINT32_MAX)
343
+ typedef unsigned short uint32_t;
344
+ # define UINT32_C(v) ((unsigned short) (v))
345
+ # ifndef PRINTF_INT32_MODIFIER
346
+ # define PRINTF_INT32_MODIFIER ""
347
+ # endif
348
+ #else
349
+ #error "Platform not supported"
350
+ #endif
351
+ #endif
352
+
353
+ #ifndef INT32_MAX
354
+ # define INT32_MAX (0x7fffffffL)
355
+ #endif
356
+ #ifndef INT32_MIN
357
+ # define INT32_MIN INT32_C(0x80000000)
358
+ #endif
359
+ #ifndef int32_t
360
+ #if (LONG_MAX == INT32_MAX) || defined (S_SPLINT_S)
361
+ typedef signed long int32_t;
362
+ # define INT32_C(v) v ## L
363
+ # ifndef PRINTF_INT32_MODIFIER
364
+ # define PRINTF_INT32_MODIFIER "l"
365
+ # endif
366
+ #elif (INT_MAX == INT32_MAX)
367
+ typedef signed int int32_t;
368
+ # define INT32_C(v) v
369
+ # ifndef PRINTF_INT32_MODIFIER
370
+ # define PRINTF_INT32_MODIFIER ""
371
+ # endif
372
+ #elif (SHRT_MAX == INT32_MAX)
373
+ typedef signed short int32_t;
374
+ # define INT32_C(v) ((short) (v))
375
+ # ifndef PRINTF_INT32_MODIFIER
376
+ # define PRINTF_INT32_MODIFIER ""
377
+ # endif
378
+ #else
379
+ #error "Platform not supported"
380
+ #endif
381
+ #endif
382
+
383
+ /*
384
+ * The macro stdint_int64_defined is temporarily used to record
385
+ * whether or not 64 integer support is available. It must be
386
+ * defined for any 64 integer extensions for new platforms that are
387
+ * added.
388
+ */
389
+
390
+ #undef stdint_int64_defined
391
+ #if (defined(__STDC__) && defined(__STDC_VERSION__)) || defined (S_SPLINT_S)
392
+ # if (__STDC__ && __STDC_VERSION >= 199901L) || defined (S_SPLINT_S)
393
+ # define stdint_int64_defined
394
+ typedef long long int64_t;
395
+ typedef unsigned long long uint64_t;
396
+ # define UINT64_C(v) v ## ULL
397
+ # define INT64_C(v) v ## LL
398
+ # ifndef PRINTF_INT64_MODIFIER
399
+ # define PRINTF_INT64_MODIFIER "ll"
400
+ # endif
401
+ # endif
402
+ #endif
403
+
404
+ #if !defined (stdint_int64_defined)
405
+ # if defined(__GNUC__)
406
+ # define stdint_int64_defined
407
+ __extension__ typedef long long int64_t;
408
+ __extension__ typedef unsigned long long uint64_t;
409
+ # define UINT64_C(v) v ## ULL
410
+ # define INT64_C(v) v ## LL
411
+ # ifndef PRINTF_INT64_MODIFIER
412
+ # define PRINTF_INT64_MODIFIER "ll"
413
+ # endif
414
+ # elif defined(__MWERKS__) || defined (__SUNPRO_C) || defined (__SUNPRO_CC) || defined (__APPLE_CC__) || defined (_LONG_LONG) || defined (_CRAYC) || defined (S_SPLINT_S)
415
+ # define stdint_int64_defined
416
+ typedef long long int64_t;
417
+ typedef unsigned long long uint64_t;
418
+ # define UINT64_C(v) v ## ULL
419
+ # define INT64_C(v) v ## LL
420
+ # ifndef PRINTF_INT64_MODIFIER
421
+ # define PRINTF_INT64_MODIFIER "ll"
422
+ # endif
423
+ # elif (defined(__WATCOMC__) && defined(__WATCOM_INT64__)) || (defined(_MSC_VER) && _INTEGRAL_MAX_BITS >= 64) || (defined (__BORLANDC__) && __BORLANDC__ > 0x460) || defined (__alpha) || defined (__DECC)
424
+ # define stdint_int64_defined
425
+ typedef __int64 int64_t;
426
+ typedef unsigned __int64 uint64_t;
427
+ # define UINT64_C(v) v ## UI64
428
+ # define INT64_C(v) v ## I64
429
+ # ifndef PRINTF_INT64_MODIFIER
430
+ # define PRINTF_INT64_MODIFIER "I64"
431
+ # endif
432
+ # endif
433
+ #endif
434
+
435
+ #if !defined (LONG_LONG_MAX) && defined (INT64_C)
436
+ # define LONG_LONG_MAX INT64_C (9223372036854775807)
437
+ #endif
438
+ #ifndef ULONG_LONG_MAX
439
+ # define ULONG_LONG_MAX UINT64_C (18446744073709551615)
440
+ #endif
441
+
442
+ #if !defined (INT64_MAX) && defined (INT64_C)
443
+ # define INT64_MAX INT64_C (9223372036854775807)
444
+ #endif
445
+ #if !defined (INT64_MIN) && defined (INT64_C)
446
+ # define INT64_MIN INT64_C (-9223372036854775808)
447
+ #endif
448
+ #if !defined (UINT64_MAX) && defined (INT64_C)
449
+ # define UINT64_MAX UINT64_C (18446744073709551615)
450
+ #endif
451
+
452
+ /*
453
+ * Width of hexadecimal for number field.
454
+ */
455
+
456
+ #ifndef PRINTF_INT64_HEX_WIDTH
457
+ # define PRINTF_INT64_HEX_WIDTH "16"
458
+ #endif
459
+ #ifndef PRINTF_INT32_HEX_WIDTH
460
+ # define PRINTF_INT32_HEX_WIDTH "8"
461
+ #endif
462
+ #ifndef PRINTF_INT16_HEX_WIDTH
463
+ # define PRINTF_INT16_HEX_WIDTH "4"
464
+ #endif
465
+ #ifndef PRINTF_INT8_HEX_WIDTH
466
+ # define PRINTF_INT8_HEX_WIDTH "2"
467
+ #endif
468
+
469
+ #ifndef PRINTF_INT64_DEC_WIDTH
470
+ # define PRINTF_INT64_DEC_WIDTH "20"
471
+ #endif
472
+ #ifndef PRINTF_INT32_DEC_WIDTH
473
+ # define PRINTF_INT32_DEC_WIDTH "10"
474
+ #endif
475
+ #ifndef PRINTF_INT16_DEC_WIDTH
476
+ # define PRINTF_INT16_DEC_WIDTH "5"
477
+ #endif
478
+ #ifndef PRINTF_INT8_DEC_WIDTH
479
+ # define PRINTF_INT8_DEC_WIDTH "3"
480
+ #endif
481
+
482
+ /*
483
+ * Ok, lets not worry about 128 bit integers for now. Moore's law says
484
+ * we don't need to worry about that until about 2040 at which point
485
+ * we'll have bigger things to worry about.
486
+ */
487
+
488
+ #ifdef stdint_int64_defined
489
+ typedef int64_t intmax_t;
490
+ typedef uint64_t uintmax_t;
491
+ # define INTMAX_MAX INT64_MAX
492
+ # define INTMAX_MIN INT64_MIN
493
+ # define UINTMAX_MAX UINT64_MAX
494
+ # define UINTMAX_C(v) UINT64_C(v)
495
+ # define INTMAX_C(v) INT64_C(v)
496
+ # ifndef PRINTF_INTMAX_MODIFIER
497
+ # define PRINTF_INTMAX_MODIFIER PRINTF_INT64_MODIFIER
498
+ # endif
499
+ # ifndef PRINTF_INTMAX_HEX_WIDTH
500
+ # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT64_HEX_WIDTH
501
+ # endif
502
+ # ifndef PRINTF_INTMAX_DEC_WIDTH
503
+ # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT64_DEC_WIDTH
504
+ # endif
505
+ #else
506
+ typedef int32_t intmax_t;
507
+ typedef uint32_t uintmax_t;
508
+ # define INTMAX_MAX INT32_MAX
509
+ # define UINTMAX_MAX UINT32_MAX
510
+ # define UINTMAX_C(v) UINT32_C(v)
511
+ # define INTMAX_C(v) INT32_C(v)
512
+ # ifndef PRINTF_INTMAX_MODIFIER
513
+ # define PRINTF_INTMAX_MODIFIER PRINTF_INT32_MODIFIER
514
+ # endif
515
+ # ifndef PRINTF_INTMAX_HEX_WIDTH
516
+ # define PRINTF_INTMAX_HEX_WIDTH PRINTF_INT32_HEX_WIDTH
517
+ # endif
518
+ # ifndef PRINTF_INTMAX_DEC_WIDTH
519
+ # define PRINTF_INTMAX_DEC_WIDTH PRINTF_INT32_DEC_WIDTH
520
+ # endif
521
+ #endif
522
+
523
+ /*
524
+ * Because this file currently only supports platforms which have
525
+ * precise powers of 2 as bit sizes for the default integers, the
526
+ * least definitions are all trivial. Its possible that a future
527
+ * version of this file could have different definitions.
528
+ */
529
+
530
+ #ifndef stdint_least_defined
531
+ typedef int8_t int_least8_t;
532
+ typedef uint8_t uint_least8_t;
533
+ typedef int16_t int_least16_t;
534
+ typedef uint16_t uint_least16_t;
535
+ typedef int32_t int_least32_t;
536
+ typedef uint32_t uint_least32_t;
537
+ # define PRINTF_LEAST32_MODIFIER PRINTF_INT32_MODIFIER
538
+ # define PRINTF_LEAST16_MODIFIER PRINTF_INT16_MODIFIER
539
+ # define UINT_LEAST8_MAX UINT8_MAX
540
+ # define INT_LEAST8_MAX INT8_MAX
541
+ # define UINT_LEAST16_MAX UINT16_MAX
542
+ # define INT_LEAST16_MAX INT16_MAX
543
+ # define UINT_LEAST32_MAX UINT32_MAX
544
+ # define INT_LEAST32_MAX INT32_MAX
545
+ # define INT_LEAST8_MIN INT8_MIN
546
+ # define INT_LEAST16_MIN INT16_MIN
547
+ # define INT_LEAST32_MIN INT32_MIN
548
+ # ifdef stdint_int64_defined
549
+ typedef int64_t int_least64_t;
550
+ typedef uint64_t uint_least64_t;
551
+ # define PRINTF_LEAST64_MODIFIER PRINTF_INT64_MODIFIER
552
+ # define UINT_LEAST64_MAX UINT64_MAX
553
+ # define INT_LEAST64_MAX INT64_MAX
554
+ # define INT_LEAST64_MIN INT64_MIN
555
+ # endif
556
+ #endif
557
+ #undef stdint_least_defined
558
+
559
+ /*
560
+ * The ANSI C committee pretending to know or specify anything about
561
+ * performance is the epitome of misguided arrogance. The mandate of
562
+ * this file is to *ONLY* ever support that absolute minimum
563
+ * definition of the fast integer types, for compatibility purposes.
564
+ * No extensions, and no attempt to suggest what may or may not be a
565
+ * faster integer type will ever be made in this file. Developers are
566
+ * warned to stay away from these types when using this or any other
567
+ * stdint.h.
568
+ */
569
+
570
+ typedef int_least8_t int_fast8_t;
571
+ typedef uint_least8_t uint_fast8_t;
572
+ typedef int_least16_t int_fast16_t;
573
+ typedef uint_least16_t uint_fast16_t;
574
+ typedef int_least32_t int_fast32_t;
575
+ typedef uint_least32_t uint_fast32_t;
576
+ #define UINT_FAST8_MAX UINT_LEAST8_MAX
577
+ #define INT_FAST8_MAX INT_LEAST8_MAX
578
+ #define UINT_FAST16_MAX UINT_LEAST16_MAX
579
+ #define INT_FAST16_MAX INT_LEAST16_MAX
580
+ #define UINT_FAST32_MAX UINT_LEAST32_MAX
581
+ #define INT_FAST32_MAX INT_LEAST32_MAX
582
+ #define INT_FAST8_MIN IN_LEASTT8_MIN
583
+ #define INT_FAST16_MIN INT_LEAST16_MIN
584
+ #define INT_FAST32_MIN INT_LEAST32_MIN
585
+ #ifdef stdint_int64_defined
586
+ typedef int_least64_t int_fast64_t;
587
+ typedef uint_least64_t uint_fast64_t;
588
+ # define UINT_FAST64_MAX UINT_LEAST64_MAX
589
+ # define INT_FAST64_MAX INT_LEAST64_MAX
590
+ # define INT_FAST64_MIN INT_LEAST64_MIN
591
+ #endif
592
+
593
+ #undef stdint_int64_defined
594
+
595
+ /*
596
+ * Whatever piecemeal, per compiler thing we can do about the wchar_t
597
+ * type limits.
598
+ */
599
+
600
+ #if defined(__WATCOMC__) || defined(_MSC_VER) || defined (__GNUC__)
601
+ # include <wchar.h>
602
+ # ifndef WCHAR_MIN
603
+ # define WCHAR_MIN 0
604
+ # endif
605
+ # ifndef WCHAR_MAX
606
+ # define WCHAR_MAX ((wchar_t)-1)
607
+ # endif
608
+ #endif
609
+
610
+ /*
611
+ * Whatever piecemeal, per compiler/platform thing we can do about the
612
+ * (u)intptr_t types and limits.
613
+ */
614
+
615
+ #if defined (_MSC_VER) && defined (_UINTPTR_T_DEFINED)
616
+ # define STDINT_H_UINTPTR_T_DEFINED
617
+ #endif
618
+
619
+ #ifndef STDINT_H_UINTPTR_T_DEFINED
620
+ # if defined (__alpha__) || defined (__ia64__) || defined (__x86_64__) || defined (_WIN64)
621
+ # define stdint_intptr_bits 64
622
+ # elif defined (__WATCOMC__) || defined (__TURBOC__)
623
+ # if defined(__TINY__) || defined(__SMALL__) || defined(__MEDIUM__)
624
+ # define stdint_intptr_bits 16
625
+ # else
626
+ # define stdint_intptr_bits 32
627
+ # endif
628
+ # elif defined (__i386__) || defined (_WIN32) || defined (WIN32)
629
+ # define stdint_intptr_bits 32
630
+ # elif defined (__INTEL_COMPILER)
631
+ /* TODO -- what will Intel do about x86-64? */
632
+ # endif
633
+
634
+ # ifdef stdint_intptr_bits
635
+ # define stdint_intptr_glue3_i(a,b,c) a##b##c
636
+ # define stdint_intptr_glue3(a,b,c) stdint_intptr_glue3_i(a,b,c)
637
+ # ifndef PRINTF_INTPTR_MODIFIER
638
+ # define PRINTF_INTPTR_MODIFIER stdint_intptr_glue3(PRINTF_INT,stdint_intptr_bits,_MODIFIER)
639
+ # endif
640
+ # ifndef PTRDIFF_MAX
641
+ # define PTRDIFF_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
642
+ # endif
643
+ # ifndef PTRDIFF_MIN
644
+ # define PTRDIFF_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
645
+ # endif
646
+ # ifndef UINTPTR_MAX
647
+ # define UINTPTR_MAX stdint_intptr_glue3(UINT,stdint_intptr_bits,_MAX)
648
+ # endif
649
+ # ifndef INTPTR_MAX
650
+ # define INTPTR_MAX stdint_intptr_glue3(INT,stdint_intptr_bits,_MAX)
651
+ # endif
652
+ # ifndef INTPTR_MIN
653
+ # define INTPTR_MIN stdint_intptr_glue3(INT,stdint_intptr_bits,_MIN)
654
+ # endif
655
+ # ifndef INTPTR_C
656
+ # define INTPTR_C(x) stdint_intptr_glue3(INT,stdint_intptr_bits,_C)(x)
657
+ # endif
658
+ # ifndef UINTPTR_C
659
+ # define UINTPTR_C(x) stdint_intptr_glue3(UINT,stdint_intptr_bits,_C)(x)
660
+ # endif
661
+ typedef stdint_intptr_glue3(uint,stdint_intptr_bits,_t) uintptr_t;
662
+ typedef stdint_intptr_glue3( int,stdint_intptr_bits,_t) intptr_t;
663
+ # else
664
+ /* TODO -- This following is likely wrong for some platforms, and does
665
+ nothing for the definition of uintptr_t. */
666
+ typedef ptrdiff_t intptr_t;
667
+ # endif
668
+ # define STDINT_H_UINTPTR_T_DEFINED
669
+ #endif
670
+
671
+ /*
672
+ * Assumes sig_atomic_t is signed and we have a 2s complement machine.
673
+ */
674
+
675
+ #ifndef SIG_ATOMIC_MAX
676
+ # define SIG_ATOMIC_MAX ((((sig_atomic_t) 1) << (sizeof (sig_atomic_t)*CHAR_BIT-1)) - 1)
677
+ #endif
678
+
679
+ #endif