opener-opinion-detector-base 2.0.0
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +7 -0
- data/README.md +101 -0
- data/bin/opinion-detector-base +19 -0
- data/core/annotation.cfg.erb +9 -0
- data/core/packages/KafNafParser-1.4.tar.gz +0 -0
- data/core/packages/VUA_pylib-1.5.tar.gz +0 -0
- data/core/python-scripts/LICENSE +339 -0
- data/core/python-scripts/README.md +226 -0
- data/core/python-scripts/classify_kaf_naf_file.py +499 -0
- data/core/python-scripts/cross_validation.py +634 -0
- data/core/python-scripts/generate_folds.py +134 -0
- data/core/python-scripts/models.cfg +10 -0
- data/core/python-scripts/my_templates/README +33 -0
- data/core/python-scripts/my_templates/templates_exp.only0.txt +6 -0
- data/core/python-scripts/my_templates/templates_exp.pol0.txt +10 -0
- data/core/python-scripts/my_templates/templates_exp.red.txt +7 -0
- data/core/python-scripts/my_templates/templates_exp.txt +10 -0
- data/core/python-scripts/my_templates/templates_holder.only0.txt +11 -0
- data/core/python-scripts/my_templates/templates_holder.red.txt +9 -0
- data/core/python-scripts/my_templates/templates_holder.txt +10 -0
- data/core/python-scripts/my_templates/templates_target.only0.txt +11 -0
- data/core/python-scripts/my_templates/templates_target.red.txt +9 -0
- data/core/python-scripts/my_templates/templates_target.txt +10 -0
- data/core/python-scripts/run_all_experiments.sh +49 -0
- data/core/python-scripts/run_basic.py +20 -0
- data/core/python-scripts/run_experiment.sh +42 -0
- data/core/python-scripts/scripts/__init__.py +1 -0
- data/core/python-scripts/scripts/config_manager.py +314 -0
- data/core/python-scripts/scripts/crfutils.py +215 -0
- data/core/python-scripts/scripts/extract_feats_relations.py +295 -0
- data/core/python-scripts/scripts/extract_features.py +376 -0
- data/core/python-scripts/scripts/feats_to_crf.exp.py +105 -0
- data/core/python-scripts/scripts/lexicons.py +44 -0
- data/core/python-scripts/scripts/link_entities_distance.py +77 -0
- data/core/python-scripts/scripts/relation_classifier.py +250 -0
- data/core/python-scripts/train.py +566 -0
- data/core/site-packages/pre_build/KafNafParser-1.4-py2.7.egg-info/PKG-INFO +10 -0
- data/core/site-packages/pre_build/KafNafParser-1.4-py2.7.egg-info/SOURCES.txt +22 -0
- data/core/site-packages/pre_build/KafNafParser-1.4-py2.7.egg-info/dependency_links.txt +1 -0
- data/core/site-packages/pre_build/KafNafParser-1.4-py2.7.egg-info/installed-files.txt +47 -0
- data/core/site-packages/pre_build/KafNafParser-1.4-py2.7.egg-info/top_level.txt +1 -0
- data/core/site-packages/pre_build/KafNafParser/KafNafParserMod.py +390 -0
- data/core/site-packages/pre_build/KafNafParser/KafNafParserMod.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/__init__.py +14 -0
- data/core/site-packages/pre_build/KafNafParser/__init__.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/constituency_data.py +125 -0
- data/core/site-packages/pre_build/KafNafParser/constituency_data.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/coreference_data.py +52 -0
- data/core/site-packages/pre_build/KafNafParser/coreference_data.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/dependency_data.py +78 -0
- data/core/site-packages/pre_build/KafNafParser/dependency_data.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/entity_data.py +59 -0
- data/core/site-packages/pre_build/KafNafParser/entity_data.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/external_references_data.py +41 -0
- data/core/site-packages/pre_build/KafNafParser/external_references_data.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/feature_extractor/__init__.py +2 -0
- data/core/site-packages/pre_build/KafNafParser/feature_extractor/__init__.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/feature_extractor/constituency.py +205 -0
- data/core/site-packages/pre_build/KafNafParser/feature_extractor/constituency.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/feature_extractor/dependency.py +309 -0
- data/core/site-packages/pre_build/KafNafParser/feature_extractor/dependency.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/features_data.py +131 -0
- data/core/site-packages/pre_build/KafNafParser/features_data.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/header_data.py +127 -0
- data/core/site-packages/pre_build/KafNafParser/header_data.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/opinion_data.py +211 -0
- data/core/site-packages/pre_build/KafNafParser/opinion_data.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/references_data.py +23 -0
- data/core/site-packages/pre_build/KafNafParser/references_data.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/span_data.py +63 -0
- data/core/site-packages/pre_build/KafNafParser/span_data.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/term_data.py +111 -0
- data/core/site-packages/pre_build/KafNafParser/term_data.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/term_sentiment_data.py +42 -0
- data/core/site-packages/pre_build/KafNafParser/term_sentiment_data.pyc +0 -0
- data/core/site-packages/pre_build/KafNafParser/text_data.py +99 -0
- data/core/site-packages/pre_build/KafNafParser/text_data.pyc +0 -0
- data/core/site-packages/pre_build/VUA_pylib-1.5-py2.7.egg-info/PKG-INFO +10 -0
- data/core/site-packages/pre_build/VUA_pylib-1.5-py2.7.egg-info/SOURCES.txt +14 -0
- data/core/site-packages/pre_build/VUA_pylib-1.5-py2.7.egg-info/dependency_links.txt +1 -0
- data/core/site-packages/pre_build/VUA_pylib-1.5-py2.7.egg-info/installed-files.txt +23 -0
- data/core/site-packages/pre_build/VUA_pylib-1.5-py2.7.egg-info/top_level.txt +1 -0
- data/core/site-packages/pre_build/VUA_pylib/__init__.py +1 -0
- data/core/site-packages/pre_build/VUA_pylib/__init__.pyc +0 -0
- data/core/site-packages/pre_build/VUA_pylib/common/__init__.py +1 -0
- data/core/site-packages/pre_build/VUA_pylib/common/__init__.pyc +0 -0
- data/core/site-packages/pre_build/VUA_pylib/common/common.py +28 -0
- data/core/site-packages/pre_build/VUA_pylib/common/common.pyc +0 -0
- data/core/site-packages/pre_build/VUA_pylib/corpus_reader/__init__.py +1 -0
- data/core/site-packages/pre_build/VUA_pylib/corpus_reader/__init__.pyc +0 -0
- data/core/site-packages/pre_build/VUA_pylib/corpus_reader/google_web_nl.py +156 -0
- data/core/site-packages/pre_build/VUA_pylib/corpus_reader/google_web_nl.pyc +0 -0
- data/core/site-packages/pre_build/VUA_pylib/io_utils/__init__.py +1 -0
- data/core/site-packages/pre_build/VUA_pylib/io_utils/__init__.pyc +0 -0
- data/core/site-packages/pre_build/VUA_pylib/io_utils/feature_file.py +121 -0
- data/core/site-packages/pre_build/VUA_pylib/io_utils/feature_file.pyc +0 -0
- data/core/site-packages/pre_build/VUA_pylib/lexicon/__init__.py +1 -0
- data/core/site-packages/pre_build/VUA_pylib/lexicon/__init__.pyc +0 -0
- data/core/site-packages/pre_build/VUA_pylib/lexicon/lexicon.py +72 -0
- data/core/site-packages/pre_build/VUA_pylib/lexicon/lexicon.pyc +0 -0
- data/core/site-packages/pre_build/VUKafParserPy-1.0-py2.7.egg-info/PKG-INFO +10 -0
- data/core/site-packages/pre_build/VUKafParserPy-1.0-py2.7.egg-info/SOURCES.txt +7 -0
- data/core/site-packages/pre_build/VUKafParserPy-1.0-py2.7.egg-info/dependency_links.txt +1 -0
- data/core/site-packages/pre_build/VUKafParserPy-1.0-py2.7.egg-info/installed-files.txt +11 -0
- data/core/site-packages/pre_build/VUKafParserPy-1.0-py2.7.egg-info/top_level.txt +1 -0
- data/core/site-packages/pre_build/VUKafParserPy/KafDataObjectsMod.py +165 -0
- data/core/site-packages/pre_build/VUKafParserPy/KafDataObjectsMod.pyc +0 -0
- data/core/site-packages/pre_build/VUKafParserPy/KafParserMod.py +439 -0
- data/core/site-packages/pre_build/VUKafParserPy/KafParserMod.pyc +0 -0
- data/core/site-packages/pre_build/VUKafParserPy/__init__.py +7 -0
- data/core/site-packages/pre_build/VUKafParserPy/__init__.pyc +0 -0
- data/core/vendor/src/crfsuite/AUTHORS +1 -0
- data/core/vendor/src/crfsuite/COPYING +27 -0
- data/core/vendor/src/crfsuite/ChangeLog +103 -0
- data/core/vendor/src/crfsuite/INSTALL +236 -0
- data/core/vendor/src/crfsuite/Makefile.am +19 -0
- data/core/vendor/src/crfsuite/Makefile.in +783 -0
- data/core/vendor/src/crfsuite/README +183 -0
- data/core/vendor/src/crfsuite/aclocal.m4 +9018 -0
- data/core/vendor/src/crfsuite/autogen.sh +38 -0
- data/core/vendor/src/crfsuite/compile +143 -0
- data/core/vendor/src/crfsuite/config.guess +1502 -0
- data/core/vendor/src/crfsuite/config.h.in +198 -0
- data/core/vendor/src/crfsuite/config.sub +1714 -0
- data/core/vendor/src/crfsuite/configure +14273 -0
- data/core/vendor/src/crfsuite/configure.in +149 -0
- data/core/vendor/src/crfsuite/crfsuite.sln +42 -0
- data/core/vendor/src/crfsuite/depcomp +630 -0
- data/core/vendor/src/crfsuite/example/chunking.py +49 -0
- data/core/vendor/src/crfsuite/example/crfutils.py +179 -0
- data/core/vendor/src/crfsuite/example/ner.py +270 -0
- data/core/vendor/src/crfsuite/example/pos.py +78 -0
- data/core/vendor/src/crfsuite/example/template.py +88 -0
- data/core/vendor/src/crfsuite/frontend/Makefile.am +29 -0
- data/core/vendor/src/crfsuite/frontend/Makefile.in +640 -0
- data/core/vendor/src/crfsuite/frontend/dump.c +116 -0
- data/core/vendor/src/crfsuite/frontend/frontend.vcxproj +129 -0
- data/core/vendor/src/crfsuite/frontend/iwa.c +273 -0
- data/core/vendor/src/crfsuite/frontend/iwa.h +65 -0
- data/core/vendor/src/crfsuite/frontend/learn.c +439 -0
- data/core/vendor/src/crfsuite/frontend/main.c +137 -0
- data/core/vendor/src/crfsuite/frontend/option.c +93 -0
- data/core/vendor/src/crfsuite/frontend/option.h +86 -0
- data/core/vendor/src/crfsuite/frontend/readdata.h +38 -0
- data/core/vendor/src/crfsuite/frontend/reader.c +136 -0
- data/core/vendor/src/crfsuite/frontend/tag.c +427 -0
- data/core/vendor/src/crfsuite/genbinary.sh.in +15 -0
- data/core/vendor/src/crfsuite/include/Makefile.am +11 -0
- data/core/vendor/src/crfsuite/include/Makefile.in +461 -0
- data/core/vendor/src/crfsuite/include/crfsuite.h +1063 -0
- data/core/vendor/src/crfsuite/include/crfsuite.hpp +555 -0
- data/core/vendor/src/crfsuite/include/crfsuite_api.hpp +400 -0
- data/core/vendor/src/crfsuite/include/os.h +61 -0
- data/core/vendor/src/crfsuite/install-sh +520 -0
- data/core/vendor/src/crfsuite/lib/cqdb/COPYING +28 -0
- data/core/vendor/src/crfsuite/lib/cqdb/Makefile.am +21 -0
- data/core/vendor/src/crfsuite/lib/cqdb/Makefile.in +549 -0
- data/core/vendor/src/crfsuite/lib/cqdb/cqdb.vcxproj +86 -0
- data/core/vendor/src/crfsuite/lib/cqdb/include/cqdb.h +524 -0
- data/core/vendor/src/crfsuite/lib/cqdb/src/cqdb.c +587 -0
- data/core/vendor/src/crfsuite/lib/cqdb/src/lookup3.c +976 -0
- data/core/vendor/src/crfsuite/lib/crf/Makefile.am +46 -0
- data/core/vendor/src/crfsuite/lib/crf/Makefile.in +721 -0
- data/core/vendor/src/crfsuite/lib/crf/crf.vcxproj +216 -0
- data/core/vendor/src/crfsuite/lib/crf/src/crf1d.h +353 -0
- data/core/vendor/src/crfsuite/lib/crf/src/crf1d_context.c +705 -0
- data/core/vendor/src/crfsuite/lib/crf/src/crf1d_encode.c +943 -0
- data/core/vendor/src/crfsuite/lib/crf/src/crf1d_feature.c +352 -0
- data/core/vendor/src/crfsuite/lib/crf/src/crf1d_model.c +994 -0
- data/core/vendor/src/crfsuite/lib/crf/src/crf1d_tag.c +550 -0
- data/core/vendor/src/crfsuite/lib/crf/src/crfsuite.c +492 -0
- data/core/vendor/src/crfsuite/lib/crf/src/crfsuite_internal.h +236 -0
- data/core/vendor/src/crfsuite/lib/crf/src/crfsuite_train.c +272 -0
- data/core/vendor/src/crfsuite/lib/crf/src/dataset.c +106 -0
- data/core/vendor/src/crfsuite/lib/crf/src/dictionary.c +118 -0
- data/core/vendor/src/crfsuite/lib/crf/src/holdout.c +80 -0
- data/core/vendor/src/crfsuite/lib/crf/src/logging.c +91 -0
- data/core/vendor/src/crfsuite/lib/crf/src/logging.h +48 -0
- data/core/vendor/src/crfsuite/lib/crf/src/params.c +335 -0
- data/core/vendor/src/crfsuite/lib/crf/src/params.h +80 -0
- data/core/vendor/src/crfsuite/lib/crf/src/quark.c +172 -0
- data/core/vendor/src/crfsuite/lib/crf/src/quark.h +46 -0
- data/core/vendor/src/crfsuite/lib/crf/src/rumavl.c +1107 -0
- data/core/vendor/src/crfsuite/lib/crf/src/rumavl.h +160 -0
- data/core/vendor/src/crfsuite/lib/crf/src/train_arow.c +408 -0
- data/core/vendor/src/crfsuite/lib/crf/src/train_averaged_perceptron.c +242 -0
- data/core/vendor/src/crfsuite/lib/crf/src/train_l2sgd.c +507 -0
- data/core/vendor/src/crfsuite/lib/crf/src/train_lbfgs.c +338 -0
- data/core/vendor/src/crfsuite/lib/crf/src/train_passive_aggressive.c +435 -0
- data/core/vendor/src/crfsuite/lib/crf/src/vecmath.h +341 -0
- data/core/vendor/src/crfsuite/ltmain.sh +8413 -0
- data/core/vendor/src/crfsuite/missing +376 -0
- data/core/vendor/src/crfsuite/swig/Makefile.am +13 -0
- data/core/vendor/src/crfsuite/swig/Makefile.in +365 -0
- data/core/vendor/src/crfsuite/swig/crfsuite.cpp +2 -0
- data/core/vendor/src/crfsuite/swig/export.i +32 -0
- data/core/vendor/src/crfsuite/swig/python/README +92 -0
- data/core/vendor/src/crfsuite/swig/python/crfsuite.py +329 -0
- data/core/vendor/src/crfsuite/swig/python/export_wrap.cpp +14355 -0
- data/core/vendor/src/crfsuite/swig/python/export_wrap.h +63 -0
- data/core/vendor/src/crfsuite/swig/python/prepare.sh +9 -0
- data/core/vendor/src/crfsuite/swig/python/sample_tag.py +52 -0
- data/core/vendor/src/crfsuite/swig/python/sample_train.py +68 -0
- data/core/vendor/src/crfsuite/swig/python/setup.py +44 -0
- data/core/vendor/src/crfsuite/win32/stdint.h +679 -0
- data/core/vendor/src/liblbfgs/AUTHORS +1 -0
- data/core/vendor/src/liblbfgs/COPYING +22 -0
- data/core/vendor/src/liblbfgs/ChangeLog +120 -0
- data/core/vendor/src/liblbfgs/INSTALL +231 -0
- data/core/vendor/src/liblbfgs/Makefile.am +10 -0
- data/core/vendor/src/liblbfgs/Makefile.in +638 -0
- data/core/vendor/src/liblbfgs/NEWS +0 -0
- data/core/vendor/src/liblbfgs/README +71 -0
- data/core/vendor/src/liblbfgs/aclocal.m4 +6985 -0
- data/core/vendor/src/liblbfgs/autogen.sh +38 -0
- data/core/vendor/src/liblbfgs/config.guess +1411 -0
- data/core/vendor/src/liblbfgs/config.h.in +64 -0
- data/core/vendor/src/liblbfgs/config.sub +1500 -0
- data/core/vendor/src/liblbfgs/configure +21146 -0
- data/core/vendor/src/liblbfgs/configure.in +107 -0
- data/core/vendor/src/liblbfgs/depcomp +522 -0
- data/core/vendor/src/liblbfgs/include/lbfgs.h +745 -0
- data/core/vendor/src/liblbfgs/install-sh +322 -0
- data/core/vendor/src/liblbfgs/lbfgs.sln +26 -0
- data/core/vendor/src/liblbfgs/lib/Makefile.am +24 -0
- data/core/vendor/src/liblbfgs/lib/Makefile.in +499 -0
- data/core/vendor/src/liblbfgs/lib/arithmetic_ansi.h +133 -0
- data/core/vendor/src/liblbfgs/lib/arithmetic_sse_double.h +294 -0
- data/core/vendor/src/liblbfgs/lib/arithmetic_sse_float.h +298 -0
- data/core/vendor/src/liblbfgs/lib/lbfgs.c +1371 -0
- data/core/vendor/src/liblbfgs/lib/lib.vcxproj +95 -0
- data/core/vendor/src/liblbfgs/ltmain.sh +6426 -0
- data/core/vendor/src/liblbfgs/missing +353 -0
- data/core/vendor/src/liblbfgs/sample/Makefile.am +15 -0
- data/core/vendor/src/liblbfgs/sample/Makefile.in +433 -0
- data/core/vendor/src/liblbfgs/sample/sample.c +81 -0
- data/core/vendor/src/liblbfgs/sample/sample.cpp +126 -0
- data/core/vendor/src/liblbfgs/sample/sample.vcxproj +105 -0
- data/core/vendor/src/svm_light/LICENSE.txt +59 -0
- data/core/vendor/src/svm_light/Makefile +105 -0
- data/core/vendor/src/svm_light/kernel.h +40 -0
- data/core/vendor/src/svm_light/svm_classify.c +197 -0
- data/core/vendor/src/svm_light/svm_common.c +985 -0
- data/core/vendor/src/svm_light/svm_common.h +301 -0
- data/core/vendor/src/svm_light/svm_hideo.c +1062 -0
- data/core/vendor/src/svm_light/svm_learn.c +4147 -0
- data/core/vendor/src/svm_light/svm_learn.h +169 -0
- data/core/vendor/src/svm_light/svm_learn_main.c +397 -0
- data/core/vendor/src/svm_light/svm_loqo.c +211 -0
- data/ext/hack/Rakefile +17 -0
- data/ext/hack/support.rb +88 -0
- data/lib/opener/opinion_detectors/base.rb +112 -0
- data/lib/opener/opinion_detectors/base/version.rb +7 -0
- data/lib/opener/opinion_detectors/configuration_creator.rb +86 -0
- data/lib/opener/opinion_detectors/de.rb +7 -0
- data/lib/opener/opinion_detectors/en.rb +7 -0
- data/lib/opener/opinion_detectors/it.rb +7 -0
- data/lib/opener/opinion_detectors/nl.rb +6 -0
- data/opener-opinion-detector-base.gemspec +35 -0
- data/pre_build_requirements.txt +3 -0
- metadata +374 -0
@@ -0,0 +1,335 @@
|
|
1
|
+
/*
|
2
|
+
* Parameter exchange.
|
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
|
+
#include <os.h>
|
34
|
+
|
35
|
+
#include <stdlib.h>
|
36
|
+
#include <string.h>
|
37
|
+
|
38
|
+
#include <crfsuite.h>
|
39
|
+
#include "quark.h"
|
40
|
+
|
41
|
+
enum {
|
42
|
+
PT_NONE = 0,
|
43
|
+
PT_INT,
|
44
|
+
PT_FLOAT,
|
45
|
+
PT_STRING,
|
46
|
+
};
|
47
|
+
|
48
|
+
typedef struct {
|
49
|
+
char* name;
|
50
|
+
int type;
|
51
|
+
int val_i;
|
52
|
+
floatval_t val_f;
|
53
|
+
char* val_s;
|
54
|
+
char* help;
|
55
|
+
} param_t;
|
56
|
+
|
57
|
+
typedef struct {
|
58
|
+
int num_params;
|
59
|
+
param_t* params;
|
60
|
+
} params_t;
|
61
|
+
|
62
|
+
static char *mystrdup(const char *src)
|
63
|
+
{
|
64
|
+
char *dst = (char*)malloc(strlen(src) + 1);
|
65
|
+
if (dst != NULL) {
|
66
|
+
strcpy(dst, src);
|
67
|
+
}
|
68
|
+
return dst;
|
69
|
+
}
|
70
|
+
|
71
|
+
static int params_addref(crfsuite_params_t* params)
|
72
|
+
{
|
73
|
+
return crfsuite_interlocked_increment(¶ms->nref);
|
74
|
+
}
|
75
|
+
|
76
|
+
static int params_release(crfsuite_params_t* params)
|
77
|
+
{
|
78
|
+
int count = crfsuite_interlocked_decrement(¶ms->nref);
|
79
|
+
if (count == 0) {
|
80
|
+
int i;
|
81
|
+
params_t* pars = (params_t*)params->internal;
|
82
|
+
for (i = 0;i < pars->num_params;++i) {
|
83
|
+
free(pars->params[i].name);
|
84
|
+
free(pars->params[i].val_s);
|
85
|
+
free(pars->params[i].help);
|
86
|
+
}
|
87
|
+
free(pars);
|
88
|
+
}
|
89
|
+
return count;
|
90
|
+
}
|
91
|
+
|
92
|
+
static param_t* find_param(params_t* pars, const char *name)
|
93
|
+
{
|
94
|
+
int i;
|
95
|
+
|
96
|
+
for (i = 0;i < pars->num_params;++i) {
|
97
|
+
if (strcmp(pars->params[i].name, name) == 0) {
|
98
|
+
return &pars->params[i];
|
99
|
+
}
|
100
|
+
}
|
101
|
+
|
102
|
+
return NULL;
|
103
|
+
}
|
104
|
+
|
105
|
+
static int params_num(crfsuite_params_t* params)
|
106
|
+
{
|
107
|
+
params_t* pars = (params_t*)params->internal;
|
108
|
+
return pars->num_params;
|
109
|
+
}
|
110
|
+
|
111
|
+
static int params_name(crfsuite_params_t* params, int i, char **ptr_name)
|
112
|
+
{
|
113
|
+
params_t* pars = (params_t*)params->internal;
|
114
|
+
*ptr_name = mystrdup(pars->params[i].name);
|
115
|
+
return 0;
|
116
|
+
}
|
117
|
+
|
118
|
+
static int params_set(crfsuite_params_t* params, const char *name, const char *value)
|
119
|
+
{
|
120
|
+
params_t* pars = (params_t*)params->internal;
|
121
|
+
param_t* par = find_param(pars, name);
|
122
|
+
if (par == NULL) return -1;
|
123
|
+
switch (par->type) {
|
124
|
+
case PT_INT:
|
125
|
+
par->val_i = (value != NULL) ? atoi(value) : 0;
|
126
|
+
break;
|
127
|
+
case PT_FLOAT:
|
128
|
+
par->val_f = (value != NULL) ? (floatval_t)atof(value) : 0;
|
129
|
+
break;
|
130
|
+
case PT_STRING:
|
131
|
+
free(par->val_s);
|
132
|
+
par->val_s = (value != NULL) ? mystrdup(value) : mystrdup("");
|
133
|
+
}
|
134
|
+
return 0;
|
135
|
+
}
|
136
|
+
|
137
|
+
static int params_get(crfsuite_params_t* params, const char *name, char **value)
|
138
|
+
{
|
139
|
+
char buffer[1024];
|
140
|
+
params_t* pars = (params_t*)params->internal;
|
141
|
+
param_t* par = find_param(pars, name);
|
142
|
+
if (par == NULL) return -1;
|
143
|
+
switch (par->type) {
|
144
|
+
case PT_INT:
|
145
|
+
snprintf(buffer, sizeof(buffer)-1, "%d", par->val_i);
|
146
|
+
*value = mystrdup(buffer);
|
147
|
+
break;
|
148
|
+
case PT_FLOAT:
|
149
|
+
snprintf(buffer, sizeof(buffer)-1, "%f", par->val_f);
|
150
|
+
*value = mystrdup(buffer);
|
151
|
+
break;
|
152
|
+
case PT_STRING:
|
153
|
+
*value = mystrdup(par->val_s);
|
154
|
+
}
|
155
|
+
return 0;
|
156
|
+
}
|
157
|
+
|
158
|
+
static void params_free(crfsuite_params_t* params, const char *value)
|
159
|
+
{
|
160
|
+
free((char*)value);
|
161
|
+
}
|
162
|
+
|
163
|
+
static int params_set_int(crfsuite_params_t* params, const char *name, int value)
|
164
|
+
{
|
165
|
+
params_t* pars = (params_t*)params->internal;
|
166
|
+
param_t* par = find_param(pars, name);
|
167
|
+
if (par == NULL) return -1;
|
168
|
+
if (par->type != PT_INT) return -1;
|
169
|
+
par->val_i = value;
|
170
|
+
return 0;
|
171
|
+
}
|
172
|
+
|
173
|
+
static int params_set_float(crfsuite_params_t* params, const char *name, floatval_t value)
|
174
|
+
{
|
175
|
+
params_t* pars = (params_t*)params->internal;
|
176
|
+
param_t* par = find_param(pars, name);
|
177
|
+
if (par == NULL) return -1;
|
178
|
+
if (par->type != PT_FLOAT) return -1;
|
179
|
+
par->val_f = value;
|
180
|
+
return 0;
|
181
|
+
}
|
182
|
+
|
183
|
+
static int params_set_string(crfsuite_params_t* params, const char *name, const char *value)
|
184
|
+
{
|
185
|
+
params_t* pars = (params_t*)params->internal;
|
186
|
+
param_t* par = find_param(pars, name);
|
187
|
+
if (par == NULL) return -1;
|
188
|
+
if (par->type != PT_STRING) return -1;
|
189
|
+
free(par->val_s);
|
190
|
+
par->val_s = mystrdup(value);
|
191
|
+
return 0;
|
192
|
+
}
|
193
|
+
|
194
|
+
static int params_get_int(crfsuite_params_t* params, const char *name, int *value)
|
195
|
+
{
|
196
|
+
params_t* pars = (params_t*)params->internal;
|
197
|
+
param_t* par = find_param(pars, name);
|
198
|
+
if (par == NULL) return -1;
|
199
|
+
if (par->type != PT_INT) return -1;
|
200
|
+
*value = par->val_i;
|
201
|
+
return 0;
|
202
|
+
}
|
203
|
+
|
204
|
+
static int params_get_float(crfsuite_params_t* params, const char *name, floatval_t *value)
|
205
|
+
{
|
206
|
+
params_t* pars = (params_t*)params->internal;
|
207
|
+
param_t* par = find_param(pars, name);
|
208
|
+
if (par == NULL) return -1;
|
209
|
+
if (par->type != PT_FLOAT) return -1;
|
210
|
+
*value = par->val_f;
|
211
|
+
return 0;
|
212
|
+
}
|
213
|
+
|
214
|
+
static int params_get_string(crfsuite_params_t* params, const char *name, char **value)
|
215
|
+
{
|
216
|
+
params_t* pars = (params_t*)params->internal;
|
217
|
+
param_t* par = find_param(pars, name);
|
218
|
+
if (par == NULL) return -1;
|
219
|
+
if (par->type != PT_STRING) return -1;
|
220
|
+
*value = par->val_s;
|
221
|
+
return 0;
|
222
|
+
}
|
223
|
+
|
224
|
+
static int params_help(crfsuite_params_t* params, const char *name, char **ptr_type, char **ptr_help)
|
225
|
+
{
|
226
|
+
params_t* pars = (params_t*)params->internal;
|
227
|
+
param_t* par = find_param(pars, name);
|
228
|
+
if (par == NULL) return -1;
|
229
|
+
if (ptr_type != NULL) {
|
230
|
+
switch (par->type) {
|
231
|
+
case PT_INT:
|
232
|
+
*ptr_type = mystrdup("int");
|
233
|
+
break;
|
234
|
+
case PT_FLOAT:
|
235
|
+
*ptr_type = mystrdup("float");
|
236
|
+
break;
|
237
|
+
case PT_STRING:
|
238
|
+
*ptr_type = mystrdup("string");
|
239
|
+
break;
|
240
|
+
default:
|
241
|
+
*ptr_type = mystrdup("unknown");
|
242
|
+
}
|
243
|
+
}
|
244
|
+
if (ptr_help != NULL) {
|
245
|
+
*ptr_help = mystrdup(par->help);
|
246
|
+
}
|
247
|
+
return 0;
|
248
|
+
}
|
249
|
+
|
250
|
+
crfsuite_params_t* params_create_instance()
|
251
|
+
{
|
252
|
+
crfsuite_params_t* params = (crfsuite_params_t*)calloc(1, sizeof(crfsuite_params_t));
|
253
|
+
|
254
|
+
if (params != NULL) {
|
255
|
+
/* Construct the internal data. */
|
256
|
+
params->internal = (params_t*)calloc(1, sizeof(params_t));
|
257
|
+
if (params->internal == NULL) {
|
258
|
+
free(params);
|
259
|
+
return NULL;
|
260
|
+
}
|
261
|
+
|
262
|
+
/* Set member functions. */
|
263
|
+
params->nref = 1;
|
264
|
+
params->addref = params_addref;
|
265
|
+
params->release = params_release;
|
266
|
+
params->num = params_num;
|
267
|
+
params->name = params_name;
|
268
|
+
params->set = params_set;
|
269
|
+
params->get = params_get;
|
270
|
+
params->free = params_free;
|
271
|
+
params->set_int = params_set_int;
|
272
|
+
params->set_float = params_set_float;
|
273
|
+
params->set_string = params_set_string;
|
274
|
+
params->get_int = params_get_int;
|
275
|
+
params->get_float = params_get_float;
|
276
|
+
params->get_string = params_get_string;
|
277
|
+
params->help = params_help;
|
278
|
+
}
|
279
|
+
|
280
|
+
return params;
|
281
|
+
}
|
282
|
+
|
283
|
+
int params_add_int(crfsuite_params_t* params, const char *name, int value, const char *help)
|
284
|
+
{
|
285
|
+
param_t* par = NULL;
|
286
|
+
params_t* pars = (params_t*)params->internal;
|
287
|
+
pars->params = (param_t*)realloc(pars->params, (pars->num_params+1) * sizeof(param_t));
|
288
|
+
if (pars->params == NULL) {
|
289
|
+
return -1;
|
290
|
+
}
|
291
|
+
|
292
|
+
par = &pars->params[pars->num_params++];
|
293
|
+
memset(par, 0, sizeof(*par));
|
294
|
+
par->name = mystrdup(name);
|
295
|
+
par->type = PT_INT;
|
296
|
+
par->val_i = value;
|
297
|
+
par->help = mystrdup(help);
|
298
|
+
return 0;
|
299
|
+
}
|
300
|
+
|
301
|
+
int params_add_float(crfsuite_params_t* params, const char *name, floatval_t value, const char *help)
|
302
|
+
{
|
303
|
+
param_t* par = NULL;
|
304
|
+
params_t* pars = (params_t*)params->internal;
|
305
|
+
pars->params = (param_t*)realloc(pars->params, (pars->num_params+1) * sizeof(param_t));
|
306
|
+
if (pars->params == NULL) {
|
307
|
+
return -1;
|
308
|
+
}
|
309
|
+
|
310
|
+
par = &pars->params[pars->num_params++];
|
311
|
+
memset(par, 0, sizeof(*par));
|
312
|
+
par->name = mystrdup(name);
|
313
|
+
par->type = PT_FLOAT;
|
314
|
+
par->val_f = value;
|
315
|
+
par->help = mystrdup(help);
|
316
|
+
return 0;
|
317
|
+
}
|
318
|
+
|
319
|
+
int params_add_string(crfsuite_params_t* params, const char *name, const char *value, const char *help)
|
320
|
+
{
|
321
|
+
param_t* par = NULL;
|
322
|
+
params_t* pars = (params_t*)params->internal;
|
323
|
+
pars->params = (param_t*)realloc(pars->params, (pars->num_params+1) * sizeof(param_t));
|
324
|
+
if (pars->params == NULL) {
|
325
|
+
return -1;
|
326
|
+
}
|
327
|
+
|
328
|
+
par = &pars->params[pars->num_params++];
|
329
|
+
memset(par, 0, sizeof(*par));
|
330
|
+
par->name = mystrdup(name);
|
331
|
+
par->type = PT_STRING;
|
332
|
+
par->val_s = mystrdup(value);
|
333
|
+
par->help = mystrdup(help);
|
334
|
+
return 0;
|
335
|
+
}
|
@@ -0,0 +1,80 @@
|
|
1
|
+
/*
|
2
|
+
* Parameter exchange.
|
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 __PARAMS_H__
|
34
|
+
#define __PARAMS_H__
|
35
|
+
|
36
|
+
crfsuite_params_t* params_create_instance();
|
37
|
+
int params_add_int(crfsuite_params_t* params, const char *name, int value, const char *help);
|
38
|
+
int params_add_float(crfsuite_params_t* params, const char *name, floatval_t value, const char *help);
|
39
|
+
int params_add_string(crfsuite_params_t* params, const char *name, const char *value, const char *help);
|
40
|
+
|
41
|
+
enum {
|
42
|
+
PARAMS_READ = -1,
|
43
|
+
PARAMS_INIT = 0,
|
44
|
+
PARAMS_WRITE = 1,
|
45
|
+
};
|
46
|
+
|
47
|
+
#define BEGIN_PARAM_MAP(params, mode) \
|
48
|
+
do { \
|
49
|
+
int __ret = 0; \
|
50
|
+
int __mode = mode; \
|
51
|
+
crfsuite_params_t* __params = params;
|
52
|
+
|
53
|
+
#define END_PARAM_MAP() \
|
54
|
+
} while (0) ;
|
55
|
+
|
56
|
+
#define DDX_PARAM_INT(name, var, defval, help) \
|
57
|
+
if (__mode < 0) \
|
58
|
+
__ret = __params->get_int(__params, name, &var); \
|
59
|
+
else if (__mode > 0) \
|
60
|
+
__ret = __params->set_int(__params, name, var); \
|
61
|
+
else \
|
62
|
+
__ret = params_add_int(__params, name, defval, help);
|
63
|
+
|
64
|
+
#define DDX_PARAM_FLOAT(name, var, defval, help) \
|
65
|
+
if (__mode < 0) \
|
66
|
+
__ret = __params->get_float(__params, name, &var); \
|
67
|
+
else if (__mode > 0) \
|
68
|
+
__ret = __params->set_float(__params, name, var); \
|
69
|
+
else \
|
70
|
+
__ret = params_add_float(__params, name, defval, help);
|
71
|
+
|
72
|
+
#define DDX_PARAM_STRING(name, var, defval, help) \
|
73
|
+
if (__mode < 0) \
|
74
|
+
__ret = __params->get_string(__params, name, &var); \
|
75
|
+
else if (__mode > 0) \
|
76
|
+
__ret = __params->set_string(__params, name, var); \
|
77
|
+
else \
|
78
|
+
__ret = params_add_string(__params, name, defval, help);
|
79
|
+
|
80
|
+
#endif/*__PARAMS_H__*/
|
@@ -0,0 +1,172 @@
|
|
1
|
+
/*
|
2
|
+
* Quark object.
|
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
|
+
#include "os.h"
|
34
|
+
#include <stdlib.h>
|
35
|
+
#include <string.h>
|
36
|
+
#include "rumavl.h"
|
37
|
+
#include "quark.h"
|
38
|
+
|
39
|
+
typedef struct {
|
40
|
+
char *str;
|
41
|
+
int qid;
|
42
|
+
} record_t;
|
43
|
+
|
44
|
+
struct tag_quark {
|
45
|
+
int num;
|
46
|
+
int max;
|
47
|
+
RUMAVL* string_to_id;
|
48
|
+
char **id_to_string;
|
49
|
+
};
|
50
|
+
|
51
|
+
static int keycmp(const void *_x, const void *_y, size_t n, void *udata)
|
52
|
+
{
|
53
|
+
const record_t* x = (const record_t*)_x;
|
54
|
+
const record_t* y = (const record_t*)_y;
|
55
|
+
return strcmp(x->str, y->str);
|
56
|
+
}
|
57
|
+
|
58
|
+
static int owcb(RUMAVL *tree, RUMAVL_NODE *n, void *_x, const void *_y, void *udata)
|
59
|
+
{
|
60
|
+
record_t* x = (record_t*)_x;
|
61
|
+
free(x->str);
|
62
|
+
return 0;
|
63
|
+
}
|
64
|
+
|
65
|
+
static int delcb(RUMAVL *tree, RUMAVL_NODE *n, void *_record, void *udata)
|
66
|
+
{
|
67
|
+
record_t* record = (record_t*)_record;
|
68
|
+
free(record->str);
|
69
|
+
return 0;
|
70
|
+
}
|
71
|
+
|
72
|
+
quark_t* quark_new()
|
73
|
+
{
|
74
|
+
quark_t* qrk = (quark_t*)malloc(sizeof(quark_t));
|
75
|
+
if (qrk != NULL) {
|
76
|
+
qrk->num = 0;
|
77
|
+
qrk->max = 0;
|
78
|
+
qrk->string_to_id = rumavl_new(sizeof(record_t), keycmp, NULL, NULL);
|
79
|
+
if (qrk->string_to_id != NULL) {
|
80
|
+
*rumavl_delcb(qrk->string_to_id) = delcb;
|
81
|
+
*rumavl_owcb(qrk->string_to_id) = owcb;
|
82
|
+
}
|
83
|
+
qrk->id_to_string = NULL;
|
84
|
+
}
|
85
|
+
return qrk;
|
86
|
+
}
|
87
|
+
|
88
|
+
void quark_delete(quark_t* qrk)
|
89
|
+
{
|
90
|
+
if (qrk != NULL) {
|
91
|
+
rumavl_destroy(qrk->string_to_id);
|
92
|
+
free(qrk->id_to_string);
|
93
|
+
free(qrk);
|
94
|
+
}
|
95
|
+
}
|
96
|
+
|
97
|
+
int quark_get(quark_t* qrk, const char *str)
|
98
|
+
{
|
99
|
+
record_t key, *record = NULL;
|
100
|
+
|
101
|
+
key.str = (char *)str;
|
102
|
+
record = (record_t*)rumavl_find(qrk->string_to_id, &key);
|
103
|
+
if (record == NULL) {
|
104
|
+
char *newstr = (char*)malloc(strlen(str)+1);
|
105
|
+
if (newstr != NULL) {
|
106
|
+
strcpy(newstr, str);
|
107
|
+
}
|
108
|
+
|
109
|
+
if (qrk->max <= qrk->num) {
|
110
|
+
qrk->max = (qrk->max + 1) * 2;
|
111
|
+
qrk->id_to_string = (char **)realloc(qrk->id_to_string, sizeof(char *) * qrk->max);
|
112
|
+
}
|
113
|
+
|
114
|
+
qrk->id_to_string[qrk->num] = newstr;
|
115
|
+
key.str = newstr;
|
116
|
+
key.qid = qrk->num;
|
117
|
+
rumavl_insert(qrk->string_to_id, &key);
|
118
|
+
|
119
|
+
++qrk->num;
|
120
|
+
return key.qid;
|
121
|
+
} else {
|
122
|
+
return record->qid;
|
123
|
+
}
|
124
|
+
}
|
125
|
+
|
126
|
+
int quark_to_id(quark_t* qrk, const char *str)
|
127
|
+
{
|
128
|
+
record_t key, *record = NULL;
|
129
|
+
|
130
|
+
key.str = (char *)str;
|
131
|
+
record = (record_t*)rumavl_find(qrk->string_to_id, &key);
|
132
|
+
return (record != NULL) ? record->qid : -1;
|
133
|
+
}
|
134
|
+
|
135
|
+
const char *quark_to_string(quark_t* qrk, int qid)
|
136
|
+
{
|
137
|
+
return (qid < qrk->num) ? qrk->id_to_string[qid] : NULL;
|
138
|
+
}
|
139
|
+
|
140
|
+
int quark_num(quark_t* qrk)
|
141
|
+
{
|
142
|
+
return qrk->num;
|
143
|
+
}
|
144
|
+
|
145
|
+
|
146
|
+
|
147
|
+
#if 0
|
148
|
+
int main(int argc, char *argv[])
|
149
|
+
{
|
150
|
+
quark_t *qrk = quark_new();
|
151
|
+
int qid = 0;
|
152
|
+
|
153
|
+
qid = quark_get(qrk, "zero");
|
154
|
+
qid = quark_get(qrk, "one");
|
155
|
+
qid = quark_get(qrk, "zero");
|
156
|
+
qid = quark_to_id(qrk, "three");
|
157
|
+
qid = quark_get(qrk, "two");
|
158
|
+
qid = quark_get(qrk, "three");
|
159
|
+
qid = quark_to_id(qrk, "three");
|
160
|
+
qid = quark_get(qrk, "zero");
|
161
|
+
qid = quark_get(qrk, "one");
|
162
|
+
|
163
|
+
printf("%s\n", quark_to_string(qrk, 0));
|
164
|
+
printf("%s\n", quark_to_string(qrk, 1));
|
165
|
+
printf("%s\n", quark_to_string(qrk, 2));
|
166
|
+
printf("%s\n", quark_to_string(qrk, 3));
|
167
|
+
|
168
|
+
quark_delete(qrk);
|
169
|
+
|
170
|
+
return 0;
|
171
|
+
}
|
172
|
+
#endif
|