├── .appveyor.yml ├── .clang-format ├── .github └── workflows │ ├── cmake.yml │ ├── nodejs.yml │ ├── python.yml │ └── release-pypi.yml ├── .gitignore ├── .npmignore ├── .travis.yml ├── AUTHORS ├── CMakeLists.txt ├── LICENSE ├── Makefile ├── NEWS.md ├── README.md ├── binding.gyp ├── build.cmd ├── data ├── CMakeLists.txt ├── config │ ├── hk2s.json │ ├── hk2t.json │ ├── jp2t.json │ ├── s2hk.json │ ├── s2t.json │ ├── s2tw.json │ ├── s2twp.json │ ├── t2hk.json │ ├── t2jp.json │ ├── t2s.json │ ├── t2tw.json │ ├── tw2s.json │ ├── tw2sp.json │ └── tw2t.json ├── dictionary │ ├── HKVariants.txt │ ├── HKVariantsRevPhrases.txt │ ├── JPShinjitaiCharacters.txt │ ├── JPShinjitaiPhrases.txt │ ├── JPVariants.txt │ ├── STCharacters.txt │ ├── STPhrases.txt │ ├── TSCharacters.txt │ ├── TSPhrases.txt │ ├── TWPhrasesIT.txt │ ├── TWPhrasesName.txt │ ├── TWPhrasesOther.txt │ ├── TWVariants.txt │ └── TWVariantsRevPhrases.txt ├── icon │ └── opencc.svg ├── scheme │ ├── st_multi.txt │ ├── ts_multi.txt │ └── variant.txt └── scripts │ ├── common.py │ ├── find_target.py │ ├── merge.py │ ├── reverse.py │ ├── sort.py │ └── sort_all.py ├── deps ├── darts-clone │ └── darts.h ├── google-benchmark │ ├── .clang-format │ ├── .github │ │ └── ISSUE_TEMPLATE │ │ │ ├── bug_report.md │ │ │ └── feature_request.md │ ├── .gitignore │ ├── .travis-libcxx-setup.sh │ ├── .travis.yml │ ├── .ycm_extra_conf.py │ ├── AUTHORS │ ├── BUILD.bazel │ ├── CMakeLists.txt │ ├── CONTRIBUTING.md │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── README.md │ ├── WORKSPACE │ ├── _config.yml │ ├── appveyor.yml │ ├── bindings │ │ └── python │ │ │ ├── BUILD │ │ │ ├── benchmark │ │ │ ├── BUILD │ │ │ ├── __init__.py │ │ │ ├── benchmark.cc │ │ │ └── example.py │ │ │ ├── build_defs.bzl │ │ │ ├── pybind11.BUILD │ │ │ ├── python_headers.BUILD │ │ │ └── requirements.txt │ ├── cmake │ │ ├── AddCXXCompilerFlag.cmake │ │ ├── CXXFeatureCheck.cmake │ │ ├── Config.cmake.in │ │ ├── GetGitVersion.cmake │ │ ├── GoogleTest.cmake │ │ ├── GoogleTest.cmake.in │ │ ├── benchmark.pc.in │ │ ├── gnu_posix_regex.cpp │ │ ├── llvm-toolchain.cmake │ │ ├── posix_regex.cpp │ │ ├── split_list.cmake │ │ ├── std_regex.cpp │ │ ├── steady_clock.cpp │ │ └── thread_safety_attributes.cpp │ ├── conan │ │ ├── CMakeLists.txt │ │ └── test_package │ │ │ ├── CMakeLists.txt │ │ │ ├── conanfile.py │ │ │ └── test_package.cpp │ ├── conanfile.py │ ├── dependencies.md │ ├── docs │ │ ├── AssemblyTests.md │ │ ├── _config.yml │ │ └── tools.md │ ├── include │ │ └── benchmark │ │ │ └── benchmark.h │ ├── mingw.py │ ├── releasing.md │ ├── setup.py │ ├── src │ │ ├── CMakeLists.txt │ │ ├── arraysize.h │ │ ├── benchmark.cc │ │ ├── benchmark_api_internal.cc │ │ ├── benchmark_api_internal.h │ │ ├── benchmark_main.cc │ │ ├── benchmark_name.cc │ │ ├── benchmark_register.cc │ │ ├── benchmark_register.h │ │ ├── benchmark_runner.cc │ │ ├── benchmark_runner.h │ │ ├── check.h │ │ ├── colorprint.cc │ │ ├── colorprint.h │ │ ├── commandlineflags.cc │ │ ├── commandlineflags.h │ │ ├── complexity.cc │ │ ├── complexity.h │ │ ├── console_reporter.cc │ │ ├── counter.cc │ │ ├── counter.h │ │ ├── csv_reporter.cc │ │ ├── cycleclock.h │ │ ├── internal_macros.h │ │ ├── json_reporter.cc │ │ ├── log.h │ │ ├── mutex.h │ │ ├── re.h │ │ ├── reporter.cc │ │ ├── sleep.cc │ │ ├── sleep.h │ │ ├── statistics.cc │ │ ├── statistics.h │ │ ├── string_util.cc │ │ ├── string_util.h │ │ ├── sysinfo.cc │ │ ├── thread_manager.h │ │ ├── thread_timer.h │ │ ├── timers.cc │ │ └── timers.h │ ├── test │ │ ├── AssemblyTests.cmake │ │ ├── BUILD │ │ ├── CMakeLists.txt │ │ ├── basic_test.cc │ │ ├── benchmark_gtest.cc │ │ ├── benchmark_name_gtest.cc │ │ ├── benchmark_test.cc │ │ ├── clobber_memory_assembly_test.cc │ │ ├── commandlineflags_gtest.cc │ │ ├── complexity_test.cc │ │ ├── cxx03_test.cc │ │ ├── diagnostics_test.cc │ │ ├── display_aggregates_only_test.cc │ │ ├── donotoptimize_assembly_test.cc │ │ ├── donotoptimize_test.cc │ │ ├── filter_test.cc │ │ ├── fixture_test.cc │ │ ├── internal_threading_test.cc │ │ ├── link_main_test.cc │ │ ├── map_test.cc │ │ ├── memory_manager_test.cc │ │ ├── multiple_ranges_test.cc │ │ ├── options_test.cc │ │ ├── output_test.h │ │ ├── output_test_helper.cc │ │ ├── register_benchmark_test.cc │ │ ├── report_aggregates_only_test.cc │ │ ├── reporter_output_test.cc │ │ ├── skip_with_error_test.cc │ │ ├── state_assembly_test.cc │ │ ├── statistics_gtest.cc │ │ ├── string_util_gtest.cc │ │ ├── templated_fixture_test.cc │ │ ├── user_counters_tabular_test.cc │ │ ├── user_counters_test.cc │ │ └── user_counters_thousands_test.cc │ └── tools │ │ ├── compare.py │ │ ├── gbench │ │ ├── Inputs │ │ │ ├── test1_run1.json │ │ │ ├── test1_run2.json │ │ │ ├── test2_run.json │ │ │ ├── test3_run0.json │ │ │ └── test3_run1.json │ │ ├── __init__.py │ │ ├── report.py │ │ └── util.py │ │ └── strip_asm.py ├── gtest-1.11.0 │ ├── CMakeLists.txt │ ├── CONTRIBUTORS │ ├── LICENSE │ ├── README.md │ ├── cmake │ │ ├── Config.cmake.in │ │ ├── gtest.pc.in │ │ ├── gtest_main.pc.in │ │ ├── internal_utils.cmake │ │ └── libgtest.la.in │ ├── docs │ │ ├── advanced.md │ │ ├── faq.md │ │ ├── pkgconfig.md │ │ ├── primer.md │ │ ├── pump_manual.md │ │ └── samples.md │ ├── include │ │ └── gtest │ │ │ ├── gtest-death-test.h │ │ │ ├── gtest-matchers.h │ │ │ ├── gtest-message.h │ │ │ ├── gtest-param-test.h │ │ │ ├── gtest-printers.h │ │ │ ├── gtest-spi.h │ │ │ ├── gtest-test-part.h │ │ │ ├── gtest-typed-test.h │ │ │ ├── gtest.h │ │ │ ├── gtest_pred_impl.h │ │ │ ├── gtest_prod.h │ │ │ └── internal │ │ │ ├── custom │ │ │ ├── README.md │ │ │ ├── gtest-port.h │ │ │ ├── gtest-printers.h │ │ │ └── gtest.h │ │ │ ├── gtest-death-test-internal.h │ │ │ ├── gtest-filepath.h │ │ │ ├── gtest-internal.h │ │ │ ├── gtest-param-util.h │ │ │ ├── gtest-port-arch.h │ │ │ ├── gtest-port.h │ │ │ ├── gtest-string.h │ │ │ ├── gtest-type-util.h │ │ │ └── gtest-type-util.h.pump │ ├── samples │ │ ├── prime_tables.h │ │ ├── sample1.cc │ │ ├── sample1.h │ │ ├── sample10_unittest.cc │ │ ├── sample1_unittest.cc │ │ ├── sample2.cc │ │ ├── sample2.h │ │ ├── sample2_unittest.cc │ │ ├── sample3-inl.h │ │ ├── sample3_unittest.cc │ │ ├── sample4.cc │ │ ├── sample4.h │ │ ├── sample4_unittest.cc │ │ ├── sample5_unittest.cc │ │ ├── sample6_unittest.cc │ │ ├── sample7_unittest.cc │ │ ├── sample8_unittest.cc │ │ └── sample9_unittest.cc │ ├── scripts │ │ ├── common.py │ │ ├── fuse_gtest_files.py │ │ ├── gen_gtest_pred_impl.py │ │ ├── gtest-config.in │ │ ├── pump.py │ │ ├── release_docs.py │ │ ├── test │ │ │ └── Makefile │ │ ├── upload.py │ │ └── upload_gtest.py │ ├── src │ │ ├── gtest-all.cc │ │ ├── gtest-death-test.cc │ │ ├── gtest-filepath.cc │ │ ├── gtest-internal-inl.h │ │ ├── gtest-matchers.cc │ │ ├── gtest-port.cc │ │ ├── gtest-printers.cc │ │ ├── gtest-test-part.cc │ │ ├── gtest-typed-test.cc │ │ ├── gtest.cc │ │ └── gtest_main.cc │ └── test │ │ ├── BUILD.bazel │ │ ├── googletest-break-on-failure-unittest.py │ │ ├── googletest-break-on-failure-unittest_.cc │ │ ├── googletest-catch-exceptions-test.py │ │ ├── googletest-catch-exceptions-test_.cc │ │ ├── googletest-color-test.py │ │ ├── googletest-color-test_.cc │ │ ├── googletest-death-test-test.cc │ │ ├── googletest-death-test_ex_test.cc │ │ ├── googletest-env-var-test.py │ │ ├── googletest-env-var-test_.cc │ │ ├── googletest-filepath-test.cc │ │ ├── googletest-filter-unittest.py │ │ ├── googletest-filter-unittest_.cc │ │ ├── googletest-json-outfiles-test.py │ │ ├── googletest-json-output-unittest.py │ │ ├── googletest-list-tests-unittest.py │ │ ├── googletest-list-tests-unittest_.cc │ │ ├── googletest-listener-test.cc │ │ ├── googletest-message-test.cc │ │ ├── googletest-options-test.cc │ │ ├── googletest-output-test-golden-lin.txt │ │ ├── googletest-output-test.py │ │ ├── googletest-output-test_.cc │ │ ├── googletest-param-test-invalid-name1-test.py │ │ ├── googletest-param-test-invalid-name1-test_.cc │ │ ├── googletest-param-test-invalid-name2-test.py │ │ ├── googletest-param-test-invalid-name2-test_.cc │ │ ├── googletest-param-test-test.cc │ │ ├── googletest-param-test-test.h │ │ ├── googletest-param-test2-test.cc │ │ ├── googletest-port-test.cc │ │ ├── googletest-printers-test.cc │ │ ├── googletest-shuffle-test.py │ │ ├── googletest-shuffle-test_.cc │ │ ├── googletest-test-part-test.cc │ │ ├── googletest-test2_test.cc │ │ ├── googletest-throw-on-failure-test.py │ │ ├── googletest-throw-on-failure-test_.cc │ │ ├── googletest-uninitialized-test.py │ │ ├── googletest-uninitialized-test_.cc │ │ ├── gtest-typed-test2_test.cc │ │ ├── gtest-typed-test_test.cc │ │ ├── gtest-typed-test_test.h │ │ ├── gtest-unittest-api_test.cc │ │ ├── gtest_all_test.cc │ │ ├── gtest_assert_by_exception_test.cc │ │ ├── gtest_environment_test.cc │ │ ├── gtest_help_test.py │ │ ├── gtest_help_test_.cc │ │ ├── gtest_json_test_utils.py │ │ ├── gtest_list_output_unittest.py │ │ ├── gtest_list_output_unittest_.cc │ │ ├── gtest_main_unittest.cc │ │ ├── gtest_no_test_unittest.cc │ │ ├── gtest_pred_impl_unittest.cc │ │ ├── gtest_premature_exit_test.cc │ │ ├── gtest_prod_test.cc │ │ ├── gtest_repeat_test.cc │ │ ├── gtest_skip_environment_check_output_test.py │ │ ├── gtest_skip_in_environment_setup_test.cc │ │ ├── gtest_skip_test.cc │ │ ├── gtest_sole_header_test.cc │ │ ├── gtest_stress_test.cc │ │ ├── gtest_test_macro_stack_footprint_test.cc │ │ ├── gtest_test_utils.py │ │ ├── gtest_testbridge_test.py │ │ ├── gtest_testbridge_test_.cc │ │ ├── gtest_throw_on_failure_ex_test.cc │ │ ├── gtest_unittest.cc │ │ ├── gtest_xml_outfile1_test_.cc │ │ ├── gtest_xml_outfile2_test_.cc │ │ ├── gtest_xml_outfiles_test.py │ │ ├── gtest_xml_output_unittest.py │ │ ├── gtest_xml_output_unittest_.cc │ │ ├── gtest_xml_test_utils.py │ │ ├── production.cc │ │ └── production.h ├── marisa-0.2.6 │ ├── AUTHORS │ ├── CMakeLists.txt │ ├── COPYING.md │ ├── README.md │ ├── include │ │ ├── marisa.h │ │ └── marisa │ │ │ ├── agent.h │ │ │ ├── base.h │ │ │ ├── exception.h │ │ │ ├── iostream.h │ │ │ ├── key.h │ │ │ ├── keyset.h │ │ │ ├── query.h │ │ │ ├── scoped-array.h │ │ │ ├── scoped-ptr.h │ │ │ ├── stdio.h │ │ │ └── trie.h │ └── lib │ │ └── marisa │ │ ├── agent.cc │ │ ├── grimoire │ │ ├── algorithm.h │ │ ├── algorithm │ │ │ └── sort.h │ │ ├── intrin.h │ │ ├── io.h │ │ ├── io │ │ │ ├── mapper.cc │ │ │ ├── mapper.h │ │ │ ├── reader.cc │ │ │ ├── reader.h │ │ │ ├── writer.cc │ │ │ └── writer.h │ │ ├── trie.h │ │ ├── trie │ │ │ ├── cache.h │ │ │ ├── config.h │ │ │ ├── entry.h │ │ │ ├── header.h │ │ │ ├── history.h │ │ │ ├── key.h │ │ │ ├── louds-trie.cc │ │ │ ├── louds-trie.h │ │ │ ├── range.h │ │ │ ├── state.h │ │ │ ├── tail.cc │ │ │ └── tail.h │ │ ├── vector.h │ │ └── vector │ │ │ ├── bit-vector.cc │ │ │ ├── bit-vector.h │ │ │ ├── flat-vector.h │ │ │ ├── pop-count.h │ │ │ ├── rank-index.h │ │ │ └── vector.h │ │ ├── keyset.cc │ │ └── trie.cc ├── pybind11-2.5.0 │ ├── .appveyor.yml │ ├── .gitignore │ ├── .gitmodules │ ├── .readthedocs.yml │ ├── .travis.yml │ ├── CMakeLists.txt │ ├── CONTRIBUTING.md │ ├── ISSUE_TEMPLATE.md │ ├── LICENSE │ ├── MANIFEST.in │ ├── README.md │ ├── docs │ │ ├── Doxyfile │ │ ├── _static │ │ │ └── theme_overrides.css │ │ ├── advanced │ │ │ ├── cast │ │ │ │ ├── chrono.rst │ │ │ │ ├── custom.rst │ │ │ │ ├── eigen.rst │ │ │ │ ├── functional.rst │ │ │ │ ├── index.rst │ │ │ │ ├── overview.rst │ │ │ │ ├── stl.rst │ │ │ │ └── strings.rst │ │ │ ├── classes.rst │ │ │ ├── embedding.rst │ │ │ ├── exceptions.rst │ │ │ ├── functions.rst │ │ │ ├── misc.rst │ │ │ ├── pycpp │ │ │ │ ├── index.rst │ │ │ │ ├── numpy.rst │ │ │ │ ├── object.rst │ │ │ │ └── utilities.rst │ │ │ └── smart_ptrs.rst │ │ ├── basics.rst │ │ ├── benchmark.py │ │ ├── benchmark.rst │ │ ├── changelog.rst │ │ ├── classes.rst │ │ ├── compiling.rst │ │ ├── conf.py │ │ ├── faq.rst │ │ ├── index.rst │ │ ├── intro.rst │ │ ├── limitations.rst │ │ ├── pybind11-logo.png │ │ ├── pybind11_vs_boost_python1.png │ │ ├── pybind11_vs_boost_python1.svg │ │ ├── pybind11_vs_boost_python2.png │ │ ├── pybind11_vs_boost_python2.svg │ │ ├── reference.rst │ │ ├── release.rst │ │ ├── requirements.txt │ │ └── upgrade.rst │ ├── include │ │ └── pybind11 │ │ │ ├── attr.h │ │ │ ├── buffer_info.h │ │ │ ├── cast.h │ │ │ ├── chrono.h │ │ │ ├── common.h │ │ │ ├── complex.h │ │ │ ├── detail │ │ │ ├── class.h │ │ │ ├── common.h │ │ │ ├── descr.h │ │ │ ├── init.h │ │ │ ├── internals.h │ │ │ └── typeid.h │ │ │ ├── eigen.h │ │ │ ├── embed.h │ │ │ ├── eval.h │ │ │ ├── functional.h │ │ │ ├── iostream.h │ │ │ ├── numpy.h │ │ │ ├── operators.h │ │ │ ├── options.h │ │ │ ├── pybind11.h │ │ │ ├── pytypes.h │ │ │ ├── stl.h │ │ │ └── stl_bind.h │ ├── pybind11 │ │ ├── __init__.py │ │ ├── __main__.py │ │ └── _version.py │ ├── setup.cfg │ ├── setup.py │ ├── tests │ │ ├── CMakeLists.txt │ │ ├── conftest.py │ │ ├── constructor_stats.h │ │ ├── cross_module_gil_utils.cpp │ │ ├── local_bindings.h │ │ ├── object.h │ │ ├── pybind11_cross_module_tests.cpp │ │ ├── pybind11_tests.cpp │ │ ├── pybind11_tests.h │ │ ├── pytest.ini │ │ ├── test_async.cpp │ │ ├── test_async.py │ │ ├── test_buffers.cpp │ │ ├── test_buffers.py │ │ ├── test_builtin_casters.cpp │ │ ├── test_builtin_casters.py │ │ ├── test_call_policies.cpp │ │ ├── test_call_policies.py │ │ ├── test_callbacks.cpp │ │ ├── test_callbacks.py │ │ ├── test_chrono.cpp │ │ ├── test_chrono.py │ │ ├── test_class.cpp │ │ ├── test_class.py │ │ ├── test_cmake_build │ │ │ ├── CMakeLists.txt │ │ │ ├── embed.cpp │ │ │ ├── installed_embed │ │ │ │ └── CMakeLists.txt │ │ │ ├── installed_function │ │ │ │ └── CMakeLists.txt │ │ │ ├── installed_target │ │ │ │ └── CMakeLists.txt │ │ │ ├── main.cpp │ │ │ ├── subdirectory_embed │ │ │ │ └── CMakeLists.txt │ │ │ ├── subdirectory_function │ │ │ │ └── CMakeLists.txt │ │ │ ├── subdirectory_target │ │ │ │ └── CMakeLists.txt │ │ │ └── test.py │ │ ├── test_constants_and_functions.cpp │ │ ├── test_constants_and_functions.py │ │ ├── test_copy_move.cpp │ │ ├── test_copy_move.py │ │ ├── test_docstring_options.cpp │ │ ├── test_docstring_options.py │ │ ├── test_eigen.cpp │ │ ├── test_eigen.py │ │ ├── test_embed │ │ │ ├── CMakeLists.txt │ │ │ ├── catch.cpp │ │ │ ├── external_module.cpp │ │ │ ├── test_interpreter.cpp │ │ │ └── test_interpreter.py │ │ ├── test_enum.cpp │ │ ├── test_enum.py │ │ ├── test_eval.cpp │ │ ├── test_eval.py │ │ ├── test_eval_call.py │ │ ├── test_exceptions.cpp │ │ ├── test_exceptions.py │ │ ├── test_factory_constructors.cpp │ │ ├── test_factory_constructors.py │ │ ├── test_gil_scoped.cpp │ │ ├── test_gil_scoped.py │ │ ├── test_iostream.cpp │ │ ├── test_iostream.py │ │ ├── test_kwargs_and_defaults.cpp │ │ ├── test_kwargs_and_defaults.py │ │ ├── test_local_bindings.cpp │ │ ├── test_local_bindings.py │ │ ├── test_methods_and_attributes.cpp │ │ ├── test_methods_and_attributes.py │ │ ├── test_modules.cpp │ │ ├── test_modules.py │ │ ├── test_multiple_inheritance.cpp │ │ ├── test_multiple_inheritance.py │ │ ├── test_numpy_array.cpp │ │ ├── test_numpy_array.py │ │ ├── test_numpy_dtypes.cpp │ │ ├── test_numpy_dtypes.py │ │ ├── test_numpy_vectorize.cpp │ │ ├── test_numpy_vectorize.py │ │ ├── test_opaque_types.cpp │ │ ├── test_opaque_types.py │ │ ├── test_operator_overloading.cpp │ │ ├── test_operator_overloading.py │ │ ├── test_pickling.cpp │ │ ├── test_pickling.py │ │ ├── test_pytypes.cpp │ │ ├── test_pytypes.py │ │ ├── test_sequences_and_iterators.cpp │ │ ├── test_sequences_and_iterators.py │ │ ├── test_smart_ptr.cpp │ │ ├── test_smart_ptr.py │ │ ├── test_stl.cpp │ │ ├── test_stl.py │ │ ├── test_stl_binders.cpp │ │ ├── test_stl_binders.py │ │ ├── test_tagbased_polymorphic.cpp │ │ ├── test_tagbased_polymorphic.py │ │ ├── test_union.cpp │ │ ├── test_union.py │ │ ├── test_virtual_functions.cpp │ │ └── test_virtual_functions.py │ └── tools │ │ ├── FindCatch.cmake │ │ ├── FindEigen3.cmake │ │ ├── FindPythonLibsNew.cmake │ │ ├── check-style.sh │ │ ├── libsize.py │ │ ├── mkdoc.py │ │ ├── pybind11Config.cmake.in │ │ └── pybind11Tools.cmake ├── rapidjson-1.1.0 │ └── rapidjson │ │ ├── allocators.h │ │ ├── document.h │ │ ├── encodedstream.h │ │ ├── encodings.h │ │ ├── error │ │ ├── en.h │ │ └── error.h │ │ ├── filereadstream.h │ │ ├── filewritestream.h │ │ ├── fwd.h │ │ ├── internal │ │ ├── biginteger.h │ │ ├── diyfp.h │ │ ├── dtoa.h │ │ ├── ieee754.h │ │ ├── itoa.h │ │ ├── meta.h │ │ ├── pow10.h │ │ ├── regex.h │ │ ├── stack.h │ │ ├── strfunc.h │ │ ├── strtod.h │ │ └── swap.h │ │ ├── istreamwrapper.h │ │ ├── memorybuffer.h │ │ ├── memorystream.h │ │ ├── msinttypes │ │ ├── inttypes.h │ │ └── stdint.h │ │ ├── ostreamwrapper.h │ │ ├── pointer.h │ │ ├── prettywriter.h │ │ ├── rapidjson.h │ │ ├── reader.h │ │ ├── schema.h │ │ ├── stream.h │ │ ├── stringbuffer.h │ │ └── writer.h └── tclap-1.2.2 │ └── tclap │ ├── Arg.h │ ├── ArgException.h │ ├── ArgTraits.h │ ├── CmdLine.h │ ├── CmdLineInterface.h │ ├── CmdLineOutput.h │ ├── Constraint.h │ ├── DocBookOutput.h │ ├── HelpVisitor.h │ ├── IgnoreRestVisitor.h │ ├── MultiArg.h │ ├── MultiSwitchArg.h │ ├── OptionalUnlabeledTracker.h │ ├── StandardTraits.h │ ├── StdOutput.h │ ├── SwitchArg.h │ ├── UnlabeledMultiArg.h │ ├── UnlabeledValueArg.h │ ├── ValueArg.h │ ├── ValuesConstraint.h │ ├── VersionVisitor.h │ ├── Visitor.h │ ├── XorHandler.h │ ├── ZshCompletionOutput.h │ └── sstream.h ├── doc ├── CMakeLists.txt ├── README.md └── opencc.doxy.in ├── iOS ├── OpenCCService.h ├── OpenCCService.mm ├── config │ ├── hk2s.json │ ├── hk2t.json │ ├── jp2t.json │ ├── s2hk.json │ ├── s2t.json │ ├── s2tw.json │ ├── s2twp.json │ ├── t2hk.json │ ├── t2jp.json │ ├── t2s.json │ ├── t2tw.json │ ├── tw2s.json │ ├── tw2sp.json │ └── tw2t.json ├── marisa │ ├── include │ │ └── marisa │ │ │ ├── agent.h │ │ │ ├── base.h │ │ │ ├── exception.h │ │ │ ├── iostream.h │ │ │ ├── key.h │ │ │ ├── keyset.h │ │ │ ├── query.h │ │ │ ├── scoped-array.h │ │ │ ├── scoped-ptr.h │ │ │ ├── stdio.h │ │ │ └── trie.h │ ├── libmarisa.a │ └── marisa.h ├── ocd2 │ ├── HKVariants.ocd2 │ ├── HKVariantsRev.ocd2 │ ├── HKVariantsRevPhrases.ocd2 │ ├── JPShinjitaiCharacters.ocd2 │ ├── JPShinjitaiPhrases.ocd2 │ ├── JPVariants.ocd2 │ ├── JPVariantsRev.ocd2 │ ├── STCharacters.ocd2 │ ├── STPhrases.ocd2 │ ├── TSCharacters.ocd2 │ ├── TSPhrases.ocd2 │ ├── TWPhrases.ocd2 │ ├── TWPhrasesRev.ocd2 │ ├── TWVariants.ocd2 │ ├── TWVariantsRev.ocd2 │ └── TWVariantsRevPhrases.ocd2 └── opencc_config.h ├── iOSOpenCC.podspec ├── node ├── configs.gypi ├── demo.js ├── dict.js ├── dicts.gypi ├── global.gypi ├── marisa.cc ├── node_opencc.gypi ├── opencc.cc ├── opencc.d.ts ├── opencc.js ├── opencc_config.h ├── test.js └── ts-demo.ts ├── opencc.pc.in ├── package-lock.json ├── package.json ├── python ├── .gitignore ├── opencc │ ├── .gitignore │ └── __init__.py └── tests │ └── test_opencc.py ├── release-pypi-linux.sh ├── release-pypi-macos.sh ├── release-pypi-windows.cmd ├── setup.py ├── src ├── BinaryDict.cpp ├── BinaryDict.hpp ├── BinaryDictTest.cpp ├── CMakeLists.txt ├── CmdLineOutput.hpp ├── Common.hpp ├── Config.cpp ├── Config.hpp ├── ConfigTest.cpp ├── ConfigTestBase.hpp ├── Conversion.cpp ├── Conversion.hpp ├── ConversionChain.cpp ├── ConversionChain.hpp ├── ConversionChainTest.cpp ├── ConversionTest.cpp ├── Converter.cpp ├── Converter.hpp ├── DartsDict.cpp ├── DartsDict.hpp ├── DartsDictTest.cpp ├── Dict.cpp ├── Dict.hpp ├── DictConverter.cpp ├── DictConverter.hpp ├── DictEntry.cpp ├── DictEntry.hpp ├── DictGroup.cpp ├── DictGroup.hpp ├── DictGroupTest.cpp ├── DictGroupTestBase.hpp ├── Exception.hpp ├── Export.hpp ├── Lexicon.cpp ├── Lexicon.hpp ├── MarisaDict.cpp ├── MarisaDict.hpp ├── MarisaDictTest.cpp ├── MaxMatchSegmentation.cpp ├── MaxMatchSegmentation.hpp ├── MaxMatchSegmentationTest.cpp ├── Optional.hpp ├── PhraseExtract.cpp ├── PhraseExtract.hpp ├── PhraseExtractTest.cpp ├── README.md ├── Segmentation.cpp ├── Segmentation.hpp ├── Segments.hpp ├── SerializableDict.hpp ├── SerializedValues.cpp ├── SerializedValues.hpp ├── SerializedValuesTest.cpp ├── SimpleConverter.cpp ├── SimpleConverter.hpp ├── SimpleConverterTest.cpp ├── TestUtils.hpp ├── TestUtilsUTF8.hpp ├── TextDict.cpp ├── TextDict.hpp ├── TextDictTest.cpp ├── TextDictTestBase.hpp ├── UTF8StringSlice.cpp ├── UTF8StringSlice.hpp ├── UTF8StringSliceTest.cpp ├── UTF8Util.cpp ├── UTF8Util.hpp ├── UTF8UtilTest.cpp ├── benchmark │ ├── CMakeLists.txt │ └── Performance.cpp ├── opencc.h ├── opencc_config.h.in ├── py_opencc.cpp └── tools │ ├── CMakeLists.txt │ ├── CommandLine.cpp │ ├── DictConverter.cpp │ └── PhraseExtract.cpp ├── test.cmd └── test ├── CMakeLists.txt ├── CommandLineConvertTest.cpp ├── benchmark └── zuozhuan.txt ├── config_test ├── config_test.json ├── config_test_characters.txt └── config_test_phrases.txt └── testcases ├── hk2s.ans ├── hk2s.in ├── hk2t.ans ├── hk2t.in ├── jp2t.ans ├── jp2t.in ├── s2hk.ans ├── s2hk.in ├── s2t.ans ├── s2t.in ├── s2tw.ans ├── s2tw.in ├── s2twp.ans ├── s2twp.in ├── t2hk.ans ├── t2hk.in ├── t2jp.ans ├── t2jp.in ├── t2s.ans ├── t2s.in ├── tw2s.ans ├── tw2s.in ├── tw2sp.ans ├── tw2sp.in ├── tw2t.ans └── tw2t.in /.appveyor.yml: -------------------------------------------------------------------------------- 1 | version: "{build}" 2 | skip_branch_with_pr: true 3 | skip_tags: true 4 | build: off 5 | 6 | os: Visual Studio 2019 7 | 8 | environment: 9 | matrix: 10 | # Build Node.js 11 | - nodejs_version: stable 12 | - nodejs_version: 16 13 | - nodejs_version: 14 14 | - nodejs_version: 12 15 | 16 | # Build plain C++ 17 | - nodejs_version: none 18 | 19 | platform: 20 | - x64 21 | - x86 22 | 23 | for: 24 | - matrix: 25 | except: 26 | - nodejs_version: none 27 | install: 28 | - ps: Install-Product node $env:nodejs_version $env:platform 29 | - npm -g i npm@latest 30 | build_script: 31 | - appveyor-retry call npm install --build-from-source 32 | test_script: 33 | - npm test 34 | 35 | - matrix: 36 | only: 37 | - nodejs_version: none 38 | build_script: 39 | - SET arch=%platform% 40 | - IF "%platform%"=="x86" SET arch=Win32 41 | 42 | - cmake -A%arch% -S. -Bbuild -DCMAKE_INSTALL_PREFIX:PATH=. -DENABLE_GTEST:BOOL=ON -DENABLE_BENCHMARK:BOOL=ON -DCMAKE_BUILD_TYPE=Release 43 | - cmake --build build --config Release --target install 44 | test_script: 45 | - cd build 46 | - ctest --verbose -C Release 47 | after_build: 48 | - 7z a OpenCC.zip build/bin build/include build/lib build/share 49 | artifacts: 50 | - path: OpenCC.zip 51 | name: OpenCC 52 | -------------------------------------------------------------------------------- /.clang-format: -------------------------------------------------------------------------------- 1 | BasedOnStyle: LLVM 2 | 3 | Language: Cpp 4 | PointerAlignment: Left 5 | -------------------------------------------------------------------------------- /.github/workflows/cmake.yml: -------------------------------------------------------------------------------- 1 | name: C/C++ CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | steps: 15 | - uses: actions/checkout@v2 16 | - name: Install doxygen 17 | run: sudo apt-get install doxygen 18 | - name: make build 19 | run: make build VERBOSE=1 20 | - name: make test 21 | run: make test VERBOSE=1 22 | - name: make benchmark 23 | run: make benchmark VERBOSE=1 24 | -------------------------------------------------------------------------------- /.github/workflows/nodejs.yml: -------------------------------------------------------------------------------- 1 | name: Node.js CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | build: 11 | 12 | runs-on: ubuntu-latest 13 | 14 | strategy: 15 | matrix: 16 | node-version: [12.x, 14.x, 16.x] 17 | 18 | steps: 19 | - uses: actions/checkout@v2 20 | - name: Use Node.js ${{ matrix.node-version }} 21 | uses: actions/setup-node@v1 22 | with: 23 | node-version: ${{ matrix.node-version }} 24 | - run: npm ci 25 | - run: npm test 26 | -------------------------------------------------------------------------------- /.github/workflows/python.yml: -------------------------------------------------------------------------------- 1 | name: Python CI 2 | 3 | on: 4 | push: 5 | branches: [ master ] 6 | pull_request: 7 | branches: [ master ] 8 | 9 | jobs: 10 | unit-test: 11 | 12 | runs-on: ubuntu-latest 13 | strategy: 14 | matrix: 15 | python-version: [3.5, 3.6, 3.7, 3.8, 3.9, '3.10'] 16 | 17 | steps: 18 | - uses: actions/checkout@v2 19 | - name: Set up Python ${{ matrix.python-version }} 20 | uses: actions/setup-python@v1 21 | with: 22 | python-version: ${{ matrix.python-version }} 23 | - name: Install dependencies 24 | run: | 25 | python -m pip install --upgrade pip 26 | pip install flake8 pytest wheel 27 | if [ -f requirements.txt ]; then pip install -r requirements.txt; fi 28 | - name: Lint with flake8 29 | run: | 30 | # stop the build if there are Python syntax errors or undefined names 31 | flake8 . --exclude deps --count --select=E9,F63,F7,F82 --show-source --statistics 32 | # exit-zero treats all errors as warnings. The GitHub editor is 127 chars wide 33 | flake8 . --exclude deps --count --exit-zero --max-complexity=10 --max-line-length=127 --statistics 34 | - name: Build and install 35 | run: python setup.py build_ext install 36 | - name: Test with pytest 37 | run: cd python && pytest 38 | -------------------------------------------------------------------------------- /.github/workflows/release-pypi.yml: -------------------------------------------------------------------------------- 1 | name: Build and upload python package to PyPI 2 | 3 | on: 4 | workflow_dispatch 5 | 6 | jobs: 7 | release-pypi: 8 | strategy: 9 | matrix: 10 | os: [ubuntu-latest, macos-latest, windows-latest] 11 | runs-on: ${{ matrix.os }} 12 | 13 | steps: 14 | - uses: actions/checkout@v1 15 | 16 | - name: Build package and upload from docker (Linux) 17 | if: runner.os == 'Linux' 18 | run: | 19 | docker run --rm -v "${PWD}:/opt/OpenCC" \ 20 | -e TWINE_USERNAME=__token__ \ 21 | -e TWINE_PASSWORD=${{ secrets.PYPI_TOKEN }} \ 22 | ubuntu:16.04 /bin/bash /opt/OpenCC/release-pypi-linux.sh 23 | 24 | - name: Build package and upload (macOS) 25 | if: runner.os == 'macOS' 26 | run: bash release-pypi-macos.sh 27 | env: 28 | TWINE_USERNAME: __token__ 29 | TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} 30 | 31 | - name: Build package and upload (Windows) 32 | if: runner.os == 'Windows' 33 | run: | 34 | C:\Miniconda/condabin/conda.bat init powershell 35 | ./release-pypi-windows.cmd 36 | env: 37 | TWINE_USERNAME: __token__ 38 | TWINE_PASSWORD: ${{ secrets.PYPI_TOKEN }} 39 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | *.pyc 2 | *.tgz 3 | .project 4 | .cproject 5 | /.vscode 6 | /.mypy_cache 7 | /build 8 | /other 9 | /doc/html 10 | /dist 11 | /opencc.xcodeproj 12 | /test/dict.ocd 13 | /test/dict.txt 14 | /test/dict.bin 15 | /xcode 16 | /node_modules 17 | /*.egg-info 18 | -------------------------------------------------------------------------------- /.npmignore: -------------------------------------------------------------------------------- 1 | .npmignore 2 | .gitignore 3 | CMakeLists.txt 4 | *.cmake 5 | *.pyc 6 | *.cmd 7 | *.tgz 8 | 9 | /.github 10 | /.vscode 11 | /.appveyor.yml 12 | /.clang-format 13 | /.travis.yml 14 | /Makefile 15 | /src/*Test.cpp 16 | /src/*TestBase.cpp 17 | /doc 18 | /data/scheme 19 | /deps/google-benchmark 20 | /deps/gtest* 21 | /deps/pybind* 22 | /deps/tclap* 23 | /build 24 | /debug 25 | /dist 26 | /release 27 | /other 28 | /opencc.pc.in 29 | /doc/html 30 | /opencc.xcodeproj 31 | /python 32 | /src/benchmark 33 | /test/benchmark 34 | /test/dict.ocd 35 | /test/dict.txt 36 | /test/dict.bin 37 | /test/CommandLineConvertTest.cpp 38 | /node_modules 39 | /xcode 40 | /*.egg-info 41 | -------------------------------------------------------------------------------- /.travis.yml: -------------------------------------------------------------------------------- 1 | language: node_js 2 | 3 | cache: 4 | npm: true 5 | ccache: true 6 | 7 | node_js: 8 | - stable 9 | - 16 10 | - 14 11 | - 12 12 | - 10 13 | 14 | os: 15 | - linux 16 | - osx 17 | 18 | arch: 19 | - amd64 20 | - arm64 21 | 22 | addons: 23 | apt: 24 | sources: 25 | - ubuntu-toolchain-r-test 26 | packages: 27 | - doxygen 28 | 29 | # Install scripts. (runs after repo cloning) 30 | install: 31 | # install modules 32 | - npm install --build-from-source 33 | 34 | # Post-install test scripts. 35 | script: 36 | - export PATH="/usr/lib/ccache/:$PATH" 37 | - if [ $TRAVIS_NODE_VERSION == "stable" ]; then 38 | make test VERBOSE=1; 39 | make package VERBOSE=1; 40 | make benchmark VERBOSE=1; 41 | fi 42 | 43 | - npm test 44 | 45 | after_success: 46 | - npm run deploy 47 | -------------------------------------------------------------------------------- /AUTHORS: -------------------------------------------------------------------------------- 1 | Author: 2 | Carbo Kuo 3 | 4 | Contributors: 5 | Peng Huang 6 | Kefu Chai 7 | LI Daobing 8 | Asias 9 | Peng Wu 10 | Xiaojun Ma 11 | 佛振 12 | 13 | -------------------------------------------------------------------------------- /binding.gyp: -------------------------------------------------------------------------------- 1 | { 2 | "includes": [ 3 | "node/global.gypi", 4 | "node/configs.gypi", 5 | "node/dicts.gypi", 6 | "node/node_opencc.gypi", 7 | ] 8 | } 9 | -------------------------------------------------------------------------------- /build.cmd: -------------------------------------------------------------------------------- 1 | cmake -S. -Bbuild -DCMAKE_INSTALL_PREFIX:PATH=. 2 | cmake --build build --config Release --target install 3 | -------------------------------------------------------------------------------- /data/config/hk2s.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese (Hong Kong variant) to Simplified Chinese", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "TSPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "HKVariantsRevPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "HKVariantsRev.ocd2" 19 | }] 20 | } 21 | }, { 22 | "dict": { 23 | "type": "group", 24 | "dicts": [{ 25 | "type": "ocd2", 26 | "file": "TSPhrases.ocd2" 27 | }, { 28 | "type": "ocd2", 29 | "file": "TSCharacters.ocd2" 30 | }] 31 | } 32 | }] 33 | } 34 | -------------------------------------------------------------------------------- /data/config/hk2t.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese (Hong Kong variant) to Traditional Chinese", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "HKVariantsRevPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "HKVariantsRevPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "HKVariantsRev.ocd2" 19 | }] 20 | } 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /data/config/jp2t.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "JPShinjitaiPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "JPShinjitaiPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "JPShinjitaiCharacters.ocd2" 19 | }, { 20 | "type": "ocd2", 21 | "file": "JPVariantsRev.ocd2" 22 | }] 23 | } 24 | }] 25 | } 26 | -------------------------------------------------------------------------------- /data/config/s2hk.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Simplified Chinese to Traditional Chinese (Hong Kong variant)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "STPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "STPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "STCharacters.ocd2" 19 | }] 20 | } 21 | }, { 22 | "dict": { 23 | "type": "ocd2", 24 | "file": "HKVariants.ocd2" 25 | } 26 | }] 27 | } 28 | -------------------------------------------------------------------------------- /data/config/s2t.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Simplified Chinese to Traditional Chinese", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "STPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "STPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "STCharacters.ocd2" 19 | }] 20 | } 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /data/config/s2tw.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Simplified Chinese to Traditional Chinese (Taiwan standard)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "STPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "STPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "STCharacters.ocd2" 19 | }] 20 | } 21 | }, { 22 | "dict": { 23 | "type": "ocd2", 24 | "file": "TWVariants.ocd2" 25 | } 26 | }] 27 | } 28 | -------------------------------------------------------------------------------- /data/config/s2twp.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Simplified Chinese to Traditional Chinese (Taiwan standard, with phrases)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "STPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "STPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "STCharacters.ocd2" 19 | }] 20 | } 21 | }, { 22 | "dict": { 23 | "type": "ocd2", 24 | "file": "TWPhrases.ocd2" 25 | } 26 | }, { 27 | "dict": { 28 | "type": "ocd2", 29 | "file": "TWVariants.ocd2" 30 | } 31 | }] 32 | } 33 | -------------------------------------------------------------------------------- /data/config/t2hk.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese to Traditional Chinese (Hong Kong variant)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "HKVariants.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "ocd2", 13 | "file": "HKVariants.ocd2" 14 | } 15 | }] 16 | } 17 | -------------------------------------------------------------------------------- /data/config/t2jp.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese Characters (Kyūjitai) to New Japanese Kanji (Shinjitai)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "JPVariants.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "ocd2", 13 | "file": "JPVariants.ocd2" 14 | } 15 | }] 16 | } 17 | -------------------------------------------------------------------------------- /data/config/t2s.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese to Simplified Chinese", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "TSPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "TSPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "TSCharacters.ocd2" 19 | }] 20 | } 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /data/config/t2tw.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese to Traditional Chinese (Taiwan standard)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "TWVariants.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "ocd2", 13 | "file": "TWVariants.ocd2" 14 | } 15 | }] 16 | } 17 | -------------------------------------------------------------------------------- /data/config/tw2s.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese (Taiwan standard) to Simplified Chinese", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "TSPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "TWVariantsRevPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "TWVariantsRev.ocd2" 19 | }] 20 | } 21 | }, { 22 | "dict": { 23 | "type": "group", 24 | "dicts": [{ 25 | "type": "ocd2", 26 | "file": "TSPhrases.ocd2" 27 | }, { 28 | "type": "ocd2", 29 | "file": "TSCharacters.ocd2" 30 | }] 31 | } 32 | }] 33 | } 34 | -------------------------------------------------------------------------------- /data/config/tw2sp.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese (Taiwan standard) to Simplified Chinese (with phrases)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "TSPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "TWPhrasesRev.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "TWVariantsRevPhrases.ocd2" 19 | }, { 20 | "type": "ocd2", 21 | "file": "TWVariantsRev.ocd2" 22 | }] 23 | } 24 | }, { 25 | "dict": { 26 | "type": "group", 27 | "dicts": [{ 28 | "type": "ocd2", 29 | "file": "TSPhrases.ocd2" 30 | }, { 31 | "type": "ocd2", 32 | "file": "TSCharacters.ocd2" 33 | }] 34 | } 35 | }] 36 | } 37 | -------------------------------------------------------------------------------- /data/config/tw2t.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese (Taiwan standard) to Traditional Chinese", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "TWVariantsRevPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "TWVariantsRevPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "TWVariantsRev.ocd2" 19 | }] 20 | } 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /data/dictionary/HKVariants.txt: -------------------------------------------------------------------------------- 1 | 僞 偽 2 | 兌 兑 3 | 叄 叁 4 | 只 只 衹 5 | 啓 啓 啟 6 | 喫 吃 7 | 囪 囱 8 | 妝 妝 粧 9 | 媼 媪 10 | 嬀 媯 11 | 悅 悦 12 | 慍 愠 13 | 戶 户 14 | 挩 捝 15 | 搵 揾 16 | 擡 抬 17 | 敓 敚 18 | 敘 敍 敘 19 | 柺 枴 20 | 梲 棁 21 | 棱 稜 棱 22 | 榲 榅 23 | 檯 枱 24 | 氳 氲 25 | 涗 涚 26 | 溫 温 27 | 溼 濕 28 | 潙 溈 29 | 潨 潀 30 | 熅 煴 31 | 爲 為 32 | 癡 痴 33 | 皁 皂 34 | 祕 秘 35 | 稅 税 36 | 竈 灶 37 | 糉 粽 糉 糭 38 | 縕 緼 39 | 纔 才 40 | 脣 唇 41 | 脫 脱 42 | 膃 腽 43 | 臥 卧 44 | 臺 台 45 | 菸 煙 46 | 蒕 蒀 47 | 蔥 葱 48 | 蔿 蒍 49 | 蘊 藴 50 | 蛻 蜕 51 | 衆 眾 52 | 衛 衞 53 | 覈 核 54 | 說 説 55 | 踊 踴 56 | 轀 輼 57 | 醞 醖 58 | 鉢 缽 59 | 鉤 鈎 60 | 銳 鋭 61 | 鍼 針 62 | 閱 閲 63 | 鰮 鰛 64 | -------------------------------------------------------------------------------- /data/dictionary/JPShinjitaiCharacters.txt: -------------------------------------------------------------------------------- 1 | 両 兩 輛 2 | 弁 辨 辯 瓣 辦 弁 3 | 御 御 禦 4 | 欠 缺 欠 5 | 糸 絲 糸 6 | 芸 藝 芸 7 | 浜 濱 浜 8 | -------------------------------------------------------------------------------- /data/dictionary/TWPhrasesName.txt: -------------------------------------------------------------------------------- 1 | 乍得 查德 2 | 也門 葉門 3 | 仙童半導體 快捷半導體 4 | 伯利茲 貝里斯 5 | 佛得角 維德角 6 | 傅里葉 傅立葉 7 | 克羅地亞 克羅埃西亞 8 | 列支敦士登 列支敦斯登 9 | 利比里亞 賴比瑞亞 10 | 加納 迦納 11 | 加蓬 加彭 12 | 博茨瓦納 波札那 13 | 卡塔爾 卡達 14 | 危地馬拉 瓜地馬拉 15 | 厄瓜多爾 厄瓜多 16 | 厄立特里亞 厄利垂亞 17 | 吉布堤 吉布地 18 | 哈薩克斯坦 哈薩克 19 | 哥斯達黎加 哥斯大黎加 20 | 喫茶小舖 喫茶小舖 21 | 圖瓦盧 吐瓦魯 22 | 土庫曼斯坦 土庫曼 23 | 圭亞那 蓋亞那 24 | 坦桑尼亞 坦尚尼亞 25 | 埃塞俄比亞 衣索比亞 26 | 基里巴斯 吉里巴斯 27 | 塔吉克斯坦 塔吉克 28 | 塞拉利昂 獅子山 29 | 塞浦路斯 塞普勒斯 30 | 塞舌爾 塞席爾 31 | 多米尼加 多明尼加 32 | 安提瓜和巴布達 安地卡及巴布達 33 | 尼日利亞 奈及利亞 34 | 尼日爾 尼日 35 | 岡比亞 甘比亞 36 | 巴巴多斯 巴貝多 37 | 巴布亞新幾內亞 巴布亞紐幾內亞 38 | 布基納法索 布吉納法索 39 | 布隆迪 蒲隆地 40 | 帕勞 帛琉 41 | 幾內亞比紹 幾內亞比索 42 | 意大利 義大利 43 | 所羅門羣島 索羅門羣島 44 | 文萊 汶萊 45 | 斯威士蘭 史瓦濟蘭 46 | 斯洛文尼亞 斯洛維尼亞 47 | 新西蘭 紐西蘭 48 | 格林納達 格瑞那達 49 | 格魯吉亞 喬治亞 50 | 歐拉 尤拉 51 | 毛里塔尼亞 茅利塔尼亞 52 | 毛里求斯 模里西斯 53 | 沙特阿拉伯 沙烏地阿拉伯 54 | 波斯尼亞黑塞哥維那 波士尼亞赫塞哥維納 55 | 津巴布韋 辛巴威 56 | 洪都拉斯 宏都拉斯 57 | 溫納圖萬 那杜 58 | 烏茲別克斯坦 烏茲別克 59 | 特立尼達和多巴哥 千里達及托巴哥 60 | 瑙魯 諾魯 61 | 瓦努阿圖 萬那杜 62 | 盧旺達 盧安達 63 | 科摩羅 葛摩 64 | 科特迪瓦 象牙海岸 65 | 突尼斯 突尼西亞 66 | 純喫茶 純喫茶 67 | 索馬里 索馬利亞 68 | 老撾 寮國 69 | 聖基茨和尼維斯 聖克里斯多福及尼維斯 70 | 聖文森特和格林納丁斯 聖文森及格瑞那丁 71 | 聖盧西亞 聖露西亞 72 | 聖馬力諾 聖馬利諾 73 | 肯尼亞 肯亞 74 | 莫桑比克 莫三比克 75 | 萊索托 賴索托 76 | 萬象 永珍 77 | 蘇里南 蘇利南 78 | 貝寧 貝南 79 | 贊比亞 尚比亞 80 | 阿塞拜疆 亞塞拜然 81 | 阿拉伯聯合酋長國 阿拉伯聯合大公國 82 | 香農 夏農 83 | 馬爾代夫 馬爾地夫 84 | 馬里共和國 馬利共和國 85 | -------------------------------------------------------------------------------- /data/dictionary/TWPhrasesOther.txt: -------------------------------------------------------------------------------- 1 | 元音 母音 2 | 冰棍 冰棒 3 | 出租車 計程車 4 | 咖喱 咖哩 5 | 塑料 塑膠 6 | 奔馳 賓士 7 | 奶酪 乳酪 8 | 幾率 機率 9 | 方便麪 泡麵 速食麵 10 | 李彥宏 李彥宏 11 | 概率 機率 12 | 海內存知己 海內存知己 13 | 涼菜 冷盤 14 | 的士 計程車 15 | 砹 砈 16 | 硅 矽 17 | 程序不正義 程序不正義 18 | 程序正義 程序正義 19 | 空氣淨化器 空氣清淨機 20 | 納米 奈米 21 | 自行車 腳踏車 22 | 詞組 片語 23 | 蹦極 高空彈跳 24 | 輔音 子音 25 | 通過 透過 通過 26 | 酰 醯 27 | 鈁 鍅 28 | 鈈 鈽 29 | 錇 鉳 30 | 鍀 鎝 31 | 鎄 鑀 32 | 鎇 鋂 33 | 鎿 錼 34 | 鐦 鉲 35 | 鑥 鎦 36 | 黃宏 黃宏 37 | -------------------------------------------------------------------------------- /data/dictionary/TWVariants.txt: -------------------------------------------------------------------------------- 1 | 僞 偽 2 | 啓 啟 3 | 喫 吃 4 | 嫺 嫻 5 | 嬀 媯 6 | 峯 峰 7 | 幺 么 8 | 擡 抬 9 | 棱 稜 10 | 檐 簷 11 | 污 汙 12 | 泄 洩 13 | 潙 溈 14 | 潨 潀 15 | 爲 為 16 | 牀 床 17 | 痹 痺 18 | 癡 痴 19 | 皁 皂 20 | 着 著 21 | 睾 睪 22 | 祕 秘 23 | 竈 灶 24 | 糉 粽 25 | 繮 韁 26 | 纔 才 27 | 羣 群 28 | 脣 唇 29 | 蔘 參 30 | 蔿 蒍 31 | 衆 眾 32 | 裏 裡 33 | 覈 核 34 | 踊 踴 35 | 鉢 缽 36 | 鍼 針 37 | 鮎 鯰 38 | 麪 麵 39 | 齶 顎 40 | -------------------------------------------------------------------------------- /data/dictionary/TWVariantsRevPhrases.txt: -------------------------------------------------------------------------------- 1 | 一口吃個 一口喫個 2 | 一口吃成 一口喫成 3 | 一家三口 一家三口 4 | 一家五口 一家五口 5 | 一家六口 一家六口 6 | 一家四口 一家四口 7 | 凶事 凶事 8 | 凶信 凶信 9 | 凶兆 凶兆 10 | 凶吉 凶吉 11 | 凶地 凶地 12 | 凶多吉少 凶多吉少 13 | 凶宅 凶宅 14 | 凶年 凶年 15 | 凶德 凶德 16 | 凶怪 凶怪 17 | 凶日 凶日 18 | 凶服 凶服 19 | 凶歲 凶歲 20 | 凶死 凶死 21 | 凶氣 凶氣 22 | 凶煞 凶煞 23 | 凶燄 凶燄 24 | 凶神 凶神 25 | 凶禮 凶禮 26 | 凶耗 凶耗 27 | 凶肆 凶肆 28 | 凶荒 凶荒 29 | 凶訊 凶訊 30 | 凶豎 凶豎 31 | 凶身 凶身 32 | 凶逆 凶逆 33 | 凶門 凶門 34 | 口吃 口吃 35 | 吃口 喫口 吃口 36 | 吃口令 吃口令 37 | 吃口飯 喫口飯 38 | 吃吃 喫喫 吃吃 39 | 吃子 喫子 吃子 40 | 合著 合著 41 | 吉凶 吉凶 42 | 名著 名著 43 | 四凶 四凶 44 | 大凶 大凶 45 | 巨著 巨著 46 | 張口 張口 47 | 昭著 昭著 48 | 歲凶 歲凶 49 | 胃口 胃口 50 | 著作 著作 51 | 著名 著名 52 | 著式 著式 53 | 著志 著志 54 | 著於 著於 55 | 著書 著書 56 | 著白 著白 57 | 著稱 著稱 58 | 著者 著者 59 | 著述 著述 60 | 著錄 著錄 61 | 蹇吃 蹇吃 62 | 逢凶 逢凶 63 | 避凶 避凶 64 | 鄧艾吃 鄧艾吃 65 | 鉅著 鉅著 66 | 開口 開口 67 | 閔凶 閔凶 68 | 顯著 顯著 69 | -------------------------------------------------------------------------------- /data/scheme/ts_multi.txt: -------------------------------------------------------------------------------- 1 | 畫 画 划 2 | 覆 覆 复 3 | 藉 藉 借 4 | 乾 乾 干 5 | 瞭 瞭 了 6 | 鍊 炼 链 7 | 蘋 苹 蘋 8 | 於 于 於 9 | 鉅 巨 钜 10 | 衹 衹 只 11 | 著 着 著 12 | 沈 沈 沉 13 | -------------------------------------------------------------------------------- /data/scripts/find_target.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import sys 5 | from common import find_target_items 6 | 7 | if len(sys.argv) != 3: 8 | print("Find the value keyword in all pairs") 9 | print(("Usage: ", sys.argv[0], "[input] [keyword]")) 10 | exit(1) 11 | 12 | find_target_items(sys.argv[1], sys.argv[2]) 13 | -------------------------------------------------------------------------------- /data/scripts/merge.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import codecs 5 | import sys 6 | 7 | from common import sort_items 8 | 9 | if len(sys.argv) < 4: 10 | print("Merge and sort all text dictionaries") 11 | print(("Usage: ", sys.argv[0], "[input1] [input2] ... [inputN] [output]")) 12 | exit(1) 13 | 14 | all_lines = [] 15 | for i in range(1, len(sys.argv) - 1): 16 | input_file = codecs.open(sys.argv[i], "r", encoding="utf-8") 17 | for line in input_file: 18 | all_lines += line 19 | input_file.close() 20 | all_lines += '\n' 21 | 22 | output_filename = sys.argv[-1] 23 | output_file = open(output_filename, "wb") 24 | for line in all_lines: 25 | output_file.write(line.encode('utf-8')) 26 | output_file.close() 27 | 28 | sort_items(output_filename, output_filename) 29 | -------------------------------------------------------------------------------- /data/scripts/reverse.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | import sys 5 | 6 | from common import reverse_items 7 | 8 | if len(sys.argv) != 3: 9 | print("Reverse key and value of all pairs") 10 | print(("Usage: ", sys.argv[0], "[input] [output]")) 11 | exit(1) 12 | 13 | reverse_items(sys.argv[1], sys.argv[2]) 14 | -------------------------------------------------------------------------------- /data/scripts/sort.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import sys 4 | 5 | from common import sort_items 6 | 7 | if len(sys.argv) < 2: 8 | print("Sort the dictionary") 9 | print(("Usage: ", sys.argv[0], "[input] ([output])")) 10 | exit(1) 11 | 12 | input = sys.argv[1] 13 | 14 | if len(sys.argv) < 3: 15 | output = input 16 | else: 17 | output = sys.argv[2] 18 | 19 | sort_items(input, output) 20 | -------------------------------------------------------------------------------- /data/scripts/sort_all.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | import glob 4 | import sys 5 | 6 | from common import sort_items 7 | 8 | if len(sys.argv) < 2: 9 | print("Sort the dictionary") 10 | print(("Usage: ", sys.argv[0], "[directory]")) 11 | exit(1) 12 | 13 | dirtectory = sys.argv[1] 14 | files = glob.glob(dirtectory + "/*") 15 | for filename in files: 16 | print(filename) 17 | sort_items(filename, filename) 18 | -------------------------------------------------------------------------------- /deps/google-benchmark/.clang-format: -------------------------------------------------------------------------------- 1 | --- 2 | Language: Cpp 3 | BasedOnStyle: Google 4 | PointerAlignment: Left 5 | ... 6 | -------------------------------------------------------------------------------- /deps/google-benchmark/.github/ISSUE_TEMPLATE/bug_report.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Bug report 3 | about: Create a report to help us improve 4 | title: "[BUG]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Describe the bug** 11 | A clear and concise description of what the bug is. 12 | 13 | **System** 14 | Which OS, compiler, and compiler version are you using: 15 | - OS: 16 | - Compiler and version: 17 | 18 | **To reproduce** 19 | Steps to reproduce the behavior: 20 | 1. sync to commit ... 21 | 2. cmake/bazel... 22 | 3. make ... 23 | 4. See error 24 | 25 | **Expected behavior** 26 | A clear and concise description of what you expected to happen. 27 | 28 | **Screenshots** 29 | If applicable, add screenshots to help explain your problem. 30 | 31 | **Additional context** 32 | Add any other context about the problem here. 33 | -------------------------------------------------------------------------------- /deps/google-benchmark/.github/ISSUE_TEMPLATE/feature_request.md: -------------------------------------------------------------------------------- 1 | --- 2 | name: Feature request 3 | about: Suggest an idea for this project 4 | title: "[FR]" 5 | labels: '' 6 | assignees: '' 7 | 8 | --- 9 | 10 | **Is your feature request related to a problem? Please describe.** 11 | A clear and concise description of what the problem is. Ex. I'm always frustrated when [...] 12 | 13 | **Describe the solution you'd like** 14 | A clear and concise description of what you want to happen. 15 | 16 | **Describe alternatives you've considered** 17 | A clear and concise description of any alternative solutions or features you've considered. 18 | 19 | **Additional context** 20 | Add any other context or screenshots about the feature request here. 21 | -------------------------------------------------------------------------------- /deps/google-benchmark/.gitignore: -------------------------------------------------------------------------------- 1 | *.a 2 | *.so 3 | *.so.?* 4 | *.dll 5 | *.exe 6 | *.dylib 7 | *.cmake 8 | !/cmake/*.cmake 9 | !/test/AssemblyTests.cmake 10 | *~ 11 | *.swp 12 | *.pyc 13 | __pycache__ 14 | 15 | # lcov 16 | *.lcov 17 | /lcov 18 | 19 | # cmake files. 20 | /Testing 21 | CMakeCache.txt 22 | CMakeFiles/ 23 | cmake_install.cmake 24 | 25 | # makefiles. 26 | Makefile 27 | 28 | # in-source build. 29 | bin/ 30 | lib/ 31 | /test/*_test 32 | 33 | # exuberant ctags. 34 | tags 35 | 36 | # YouCompleteMe configuration. 37 | .ycm_extra_conf.pyc 38 | 39 | # ninja generated files. 40 | .ninja_deps 41 | .ninja_log 42 | build.ninja 43 | install_manifest.txt 44 | rules.ninja 45 | 46 | # bazel output symlinks. 47 | bazel-* 48 | 49 | # out-of-source build top-level folders. 50 | build/ 51 | _build/ 52 | build*/ 53 | 54 | # in-source dependencies 55 | /googletest/ 56 | 57 | # Visual Studio 2015/2017 cache/options directory 58 | .vs/ 59 | CMakeSettings.json 60 | 61 | # Visual Studio Code cache/options directory 62 | .vscode/ 63 | -------------------------------------------------------------------------------- /deps/google-benchmark/.travis-libcxx-setup.sh: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env bash 2 | 3 | # Install a newer CMake version 4 | curl -sSL https://cmake.org/files/v3.6/cmake-3.6.1-Linux-x86_64.sh -o install-cmake.sh 5 | chmod +x install-cmake.sh 6 | sudo ./install-cmake.sh --prefix=/usr/local --skip-license 7 | 8 | # Checkout LLVM sources 9 | git clone --depth=1 https://github.com/llvm-mirror/llvm.git llvm-source 10 | git clone --depth=1 https://github.com/llvm-mirror/libcxx.git llvm-source/projects/libcxx 11 | git clone --depth=1 https://github.com/llvm-mirror/libcxxabi.git llvm-source/projects/libcxxabi 12 | 13 | # Setup libc++ options 14 | if [ -z "$BUILD_32_BITS" ]; then 15 | export BUILD_32_BITS=OFF && echo disabling 32 bit build 16 | fi 17 | 18 | # Build and install libc++ (Use unstable ABI for better sanitizer coverage) 19 | mkdir llvm-build && cd llvm-build 20 | cmake -DCMAKE_C_COMPILER=${C_COMPILER} -DCMAKE_CXX_COMPILER=${COMPILER} \ 21 | -DCMAKE_BUILD_TYPE=RelWithDebInfo -DCMAKE_INSTALL_PREFIX=/usr \ 22 | -DLIBCXX_ABI_UNSTABLE=ON \ 23 | -DLLVM_USE_SANITIZER=${LIBCXX_SANITIZER} \ 24 | -DLLVM_BUILD_32_BITS=${BUILD_32_BITS} \ 25 | ../llvm-source 26 | make cxx -j2 27 | sudo make install-cxxabi install-cxx 28 | cd ../ 29 | -------------------------------------------------------------------------------- /deps/google-benchmark/BUILD.bazel: -------------------------------------------------------------------------------- 1 | licenses(["notice"]) 2 | 3 | config_setting( 4 | name = "windows", 5 | values = { 6 | "cpu": "x64_windows", 7 | }, 8 | visibility = [":__subpackages__"], 9 | ) 10 | 11 | load("@rules_cc//cc:defs.bzl", "cc_library") 12 | 13 | cc_library( 14 | name = "benchmark", 15 | srcs = glob( 16 | [ 17 | "src/*.cc", 18 | "src/*.h", 19 | ], 20 | exclude = ["src/benchmark_main.cc"], 21 | ), 22 | hdrs = ["include/benchmark/benchmark.h"], 23 | linkopts = select({ 24 | ":windows": ["-DEFAULTLIB:shlwapi.lib"], 25 | "//conditions:default": ["-pthread"], 26 | }), 27 | strip_include_prefix = "include", 28 | visibility = ["//visibility:public"], 29 | ) 30 | 31 | cc_library( 32 | name = "benchmark_main", 33 | srcs = ["src/benchmark_main.cc"], 34 | hdrs = ["include/benchmark/benchmark.h"], 35 | strip_include_prefix = "include", 36 | visibility = ["//visibility:public"], 37 | deps = [":benchmark"], 38 | ) 39 | 40 | cc_library( 41 | name = "benchmark_internal_headers", 42 | hdrs = glob(["src/*.h"]), 43 | visibility = ["//test:__pkg__"], 44 | ) 45 | -------------------------------------------------------------------------------- /deps/google-benchmark/WORKSPACE: -------------------------------------------------------------------------------- 1 | workspace(name = "com_github_google_benchmark") 2 | 3 | load("@bazel_tools//tools/build_defs/repo:http.bzl", "http_archive") 4 | 5 | http_archive( 6 | name = "rules_cc", 7 | strip_prefix = "rules_cc-a508235df92e71d537fcbae0c7c952ea6957a912", 8 | urls = ["https://github.com/bazelbuild/rules_cc/archive/a508235df92e71d537fcbae0c7c952ea6957a912.zip"], 9 | ) 10 | 11 | http_archive( 12 | name = "com_google_googletest", 13 | strip_prefix = "googletest-3f0cf6b62ad1eb50d8736538363d3580dd640c3e", 14 | urls = ["https://github.com/google/googletest/archive/3f0cf6b62ad1eb50d8736538363d3580dd640c3e.zip"], 15 | ) 16 | 17 | http_archive( 18 | name = "pybind11", 19 | build_file = "@//bindings/python:pybind11.BUILD", 20 | sha256 = "1eed57bc6863190e35637290f97a20c81cfe4d9090ac0a24f3bbf08f265eb71d", 21 | strip_prefix = "pybind11-2.4.3", 22 | urls = ["https://github.com/pybind/pybind11/archive/v2.4.3.tar.gz"], 23 | ) 24 | 25 | new_local_repository( 26 | name = "python_headers", 27 | build_file = "@//bindings/python:python_headers.BUILD", 28 | path = "/usr/include/python3.6", # May be overwritten by setup.py. 29 | ) 30 | 31 | -------------------------------------------------------------------------------- /deps/google-benchmark/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-midnight -------------------------------------------------------------------------------- /deps/google-benchmark/appveyor.yml: -------------------------------------------------------------------------------- 1 | version: '{build}' 2 | 3 | image: Visual Studio 2017 4 | 5 | configuration: 6 | - Debug 7 | - Release 8 | 9 | environment: 10 | matrix: 11 | - compiler: msvc-15-seh 12 | generator: "Visual Studio 15 2017" 13 | 14 | - compiler: msvc-15-seh 15 | generator: "Visual Studio 15 2017 Win64" 16 | 17 | - compiler: msvc-14-seh 18 | generator: "Visual Studio 14 2015" 19 | 20 | - compiler: msvc-14-seh 21 | generator: "Visual Studio 14 2015 Win64" 22 | 23 | - compiler: gcc-5.3.0-posix 24 | generator: "MinGW Makefiles" 25 | cxx_path: 'C:\mingw-w64\i686-5.3.0-posix-dwarf-rt_v4-rev0\mingw32\bin' 26 | APPVEYOR_BUILD_WORKER_IMAGE: Visual Studio 2015 27 | 28 | matrix: 29 | fast_finish: true 30 | 31 | install: 32 | # git bash conflicts with MinGW makefiles 33 | - if "%generator%"=="MinGW Makefiles" (set "PATH=%PATH:C:\Program Files\Git\usr\bin;=%") 34 | - if not "%cxx_path%"=="" (set "PATH=%PATH%;%cxx_path%") 35 | 36 | build_script: 37 | - md _build -Force 38 | - cd _build 39 | - echo %configuration% 40 | - cmake -G "%generator%" "-DCMAKE_BUILD_TYPE=%configuration%" -DBENCHMARK_DOWNLOAD_DEPENDENCIES=ON .. 41 | - cmake --build . --config %configuration% 42 | 43 | test_script: 44 | - ctest --build-config %configuration% --timeout 300 --output-on-failure 45 | 46 | artifacts: 47 | - path: '_build/CMakeFiles/*.log' 48 | name: logs 49 | - path: '_build/Testing/**/*.xml' 50 | name: test_results 51 | -------------------------------------------------------------------------------- /deps/google-benchmark/bindings/python/BUILD: -------------------------------------------------------------------------------- 1 | exports_files(glob(["*.BUILD"])) 2 | exports_files(["build_defs.bzl"]) 3 | 4 | -------------------------------------------------------------------------------- /deps/google-benchmark/bindings/python/benchmark/BUILD: -------------------------------------------------------------------------------- 1 | load("//bindings/python:build_defs.bzl", "py_extension") 2 | 3 | py_library( 4 | name = "benchmark", 5 | srcs = ["__init__.py"], 6 | visibility = ["//visibility:public"], 7 | deps = [ 8 | ":_benchmark", 9 | # pip; absl:app 10 | ], 11 | ) 12 | 13 | py_extension( 14 | name = "_benchmark", 15 | srcs = ["benchmark.cc"], 16 | copts = [ 17 | "-fexceptions", 18 | "-fno-strict-aliasing", 19 | ], 20 | features = ["-use_header_modules"], 21 | deps = [ 22 | "//:benchmark", 23 | "@pybind11", 24 | "@python_headers", 25 | ], 26 | ) 27 | 28 | py_test( 29 | name = "example", 30 | srcs = ["example.py"], 31 | python_version = "PY3", 32 | srcs_version = "PY3", 33 | visibility = ["//visibility:public"], 34 | deps = [ 35 | ":benchmark", 36 | ], 37 | ) 38 | 39 | -------------------------------------------------------------------------------- /deps/google-benchmark/bindings/python/benchmark/example.py: -------------------------------------------------------------------------------- 1 | # Copyright 2020 Google Inc. All rights reserved. 2 | # 3 | # Licensed under the Apache License, Version 2.0 (the "License"); 4 | # you may not use this file except in compliance with the License. 5 | # You may obtain a copy of the License at 6 | # 7 | # http://www.apache.org/licenses/LICENSE-2.0 8 | # 9 | # Unless required by applicable law or agreed to in writing, software 10 | # distributed under the License is distributed on an "AS IS" BASIS, 11 | # WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | # See the License for the specific language governing permissions and 13 | # limitations under the License. 14 | """Example of Python using C++ benchmark framework.""" 15 | 16 | import benchmark 17 | 18 | 19 | @benchmark.register 20 | def empty(state): 21 | while state: 22 | pass 23 | 24 | 25 | @benchmark.register 26 | def sum_million(state): 27 | while state: 28 | sum(range(1_000_000)) 29 | 30 | 31 | if __name__ == '__main__': 32 | benchmark.main() 33 | -------------------------------------------------------------------------------- /deps/google-benchmark/bindings/python/build_defs.bzl: -------------------------------------------------------------------------------- 1 | _SHARED_LIB_SUFFIX = { 2 | "//conditions:default": ".so", 3 | "//:windows": ".dll", 4 | } 5 | 6 | def py_extension(name, srcs, hdrs = [], copts = [], features = [], deps = []): 7 | for shared_lib_suffix in _SHARED_LIB_SUFFIX.values(): 8 | shared_lib_name = name + shared_lib_suffix 9 | native.cc_binary( 10 | name = shared_lib_name, 11 | linkshared = 1, 12 | linkstatic = 1, 13 | srcs = srcs + hdrs, 14 | copts = copts, 15 | features = features, 16 | deps = deps, 17 | ) 18 | 19 | return native.py_library( 20 | name = name, 21 | data = select({ 22 | platform: [name + shared_lib_suffix] 23 | for platform, shared_lib_suffix in _SHARED_LIB_SUFFIX.items() 24 | }), 25 | ) 26 | -------------------------------------------------------------------------------- /deps/google-benchmark/bindings/python/pybind11.BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "pybind11", 3 | hdrs = glob( 4 | include = [ 5 | "include/pybind11/*.h", 6 | "include/pybind11/detail/*.h", 7 | ], 8 | exclude = [ 9 | "include/pybind11/common.h", 10 | "include/pybind11/eigen.h", 11 | ], 12 | ), 13 | copts = [ 14 | "-fexceptions", 15 | "-Wno-undefined-inline", 16 | "-Wno-pragma-once-outside-header", 17 | ], 18 | includes = ["include"], 19 | visibility = ["//visibility:public"], 20 | ) 21 | -------------------------------------------------------------------------------- /deps/google-benchmark/bindings/python/python_headers.BUILD: -------------------------------------------------------------------------------- 1 | cc_library( 2 | name = "python_headers", 3 | hdrs = glob(["**/*.h"]), 4 | includes = ["."], 5 | visibility = ["//visibility:public"], 6 | ) 7 | -------------------------------------------------------------------------------- /deps/google-benchmark/bindings/python/requirements.txt: -------------------------------------------------------------------------------- 1 | absl-py>=0.7.1 2 | 3 | -------------------------------------------------------------------------------- /deps/google-benchmark/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 2 | -------------------------------------------------------------------------------- /deps/google-benchmark/cmake/benchmark.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@CMAKE_INSTALL_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=${prefix}/lib 4 | includedir=${prefix}/include 5 | 6 | Name: @PROJECT_NAME@ 7 | Description: Google microbenchmark framework 8 | Version: @VERSION@ 9 | 10 | Libs: -L${libdir} -lbenchmark 11 | Libs.private: -lpthread 12 | Cflags: -I${includedir} 13 | -------------------------------------------------------------------------------- /deps/google-benchmark/cmake/gnu_posix_regex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | std::string str = "test0159"; 5 | regex_t re; 6 | int ec = regcomp(&re, "^[a-z]+[0-9]+$", REG_EXTENDED | REG_NOSUB); 7 | if (ec != 0) { 8 | return ec; 9 | } 10 | return regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0; 11 | } 12 | 13 | -------------------------------------------------------------------------------- /deps/google-benchmark/cmake/llvm-toolchain.cmake: -------------------------------------------------------------------------------- 1 | find_package(LLVMAr REQUIRED) 2 | set(CMAKE_AR "${LLVMAR_EXECUTABLE}" CACHE FILEPATH "" FORCE) 3 | 4 | find_package(LLVMNm REQUIRED) 5 | set(CMAKE_NM "${LLVMNM_EXECUTABLE}" CACHE FILEPATH "" FORCE) 6 | 7 | find_package(LLVMRanLib REQUIRED) 8 | set(CMAKE_RANLIB "${LLVMRANLIB_EXECUTABLE}" CACHE FILEPATH "" FORCE) 9 | -------------------------------------------------------------------------------- /deps/google-benchmark/cmake/posix_regex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | std::string str = "test0159"; 5 | regex_t re; 6 | int ec = regcomp(&re, "^[a-z]+[0-9]+$", REG_EXTENDED | REG_NOSUB); 7 | if (ec != 0) { 8 | return ec; 9 | } 10 | int ret = regexec(&re, str.c_str(), 0, nullptr, 0) ? -1 : 0; 11 | regfree(&re); 12 | return ret; 13 | } 14 | 15 | -------------------------------------------------------------------------------- /deps/google-benchmark/cmake/split_list.cmake: -------------------------------------------------------------------------------- 1 | macro(split_list listname) 2 | string(REPLACE ";" " " ${listname} "${${listname}}") 3 | endmacro() 4 | -------------------------------------------------------------------------------- /deps/google-benchmark/cmake/std_regex.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | #include 3 | int main() { 4 | const std::string str = "test0159"; 5 | std::regex re; 6 | re = std::regex("^[a-z]+[0-9]+$", 7 | std::regex_constants::extended | std::regex_constants::nosubs); 8 | return std::regex_search(str, re) ? 0 : -1; 9 | } 10 | 11 | -------------------------------------------------------------------------------- /deps/google-benchmark/cmake/steady_clock.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | int main() { 4 | typedef std::chrono::steady_clock Clock; 5 | Clock::time_point tp = Clock::now(); 6 | ((void)tp); 7 | } 8 | -------------------------------------------------------------------------------- /deps/google-benchmark/cmake/thread_safety_attributes.cpp: -------------------------------------------------------------------------------- 1 | #define HAVE_THREAD_SAFETY_ATTRIBUTES 2 | #include "../src/mutex.h" 3 | 4 | int main() {} 5 | -------------------------------------------------------------------------------- /deps/google-benchmark/conan/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(cmake_wrapper) 3 | 4 | include(conanbuildinfo.cmake) 5 | conan_basic_setup() 6 | 7 | include(${CMAKE_SOURCE_DIR}/CMakeListsOriginal.txt) 8 | -------------------------------------------------------------------------------- /deps/google-benchmark/conan/test_package/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.11) 2 | project(test_package) 3 | 4 | set(CMAKE_VERBOSE_MAKEFILE TRUE) 5 | 6 | include(${CMAKE_BINARY_DIR}/conanbuildinfo.cmake) 7 | conan_basic_setup() 8 | 9 | add_executable(${PROJECT_NAME} test_package.cpp) 10 | target_link_libraries(${PROJECT_NAME} ${CONAN_LIBS}) 11 | -------------------------------------------------------------------------------- /deps/google-benchmark/conan/test_package/conanfile.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # -*- coding: utf-8 -*- 3 | 4 | from conans import ConanFile, CMake 5 | import os 6 | 7 | 8 | class TestPackageConan(ConanFile): 9 | settings = "os", "compiler", "build_type", "arch" 10 | generators = "cmake" 11 | 12 | def build(self): 13 | cmake = CMake(self) 14 | cmake.configure() 15 | cmake.build() 16 | 17 | def test(self): 18 | bin_path = os.path.join("bin", "test_package") 19 | self.run(bin_path, run_environment=True) 20 | -------------------------------------------------------------------------------- /deps/google-benchmark/conan/test_package/test_package.cpp: -------------------------------------------------------------------------------- 1 | #include "benchmark/benchmark.h" 2 | 3 | void BM_StringCreation(benchmark::State& state) { 4 | while (state.KeepRunning()) 5 | std::string empty_string; 6 | } 7 | 8 | BENCHMARK(BM_StringCreation); 9 | 10 | void BM_StringCopy(benchmark::State& state) { 11 | std::string x = "hello"; 12 | while (state.KeepRunning()) 13 | std::string copy(x); 14 | } 15 | 16 | BENCHMARK(BM_StringCopy); 17 | 18 | BENCHMARK_MAIN(); 19 | -------------------------------------------------------------------------------- /deps/google-benchmark/dependencies.md: -------------------------------------------------------------------------------- 1 | # Build tool dependency policy 2 | 3 | To ensure the broadest compatibility when building the benchmark library, but 4 | still allow forward progress, we require any build tooling to be available for: 5 | 6 | * Debian stable AND 7 | * The last two Ubuntu LTS releases AND 8 | 9 | Currently, this means using build tool versions that are available for Ubuntu 10 | 16.04 (Xenial), Ubuntu 18.04 (Bionic), and Debian stretch. 11 | 12 | _Note, [travis](.travis.yml) runs under Ubuntu 14.04 (Trusty) for linux builds._ 13 | 14 | ## cmake 15 | The current supported version is cmake 3.5.1 as of 2018-06-06. 16 | 17 | _Note, this version is also available for Ubuntu 14.04, the previous Ubuntu LTS 18 | release, as `cmake3`._ 19 | -------------------------------------------------------------------------------- /deps/google-benchmark/docs/_config.yml: -------------------------------------------------------------------------------- 1 | theme: jekyll-theme-midnight -------------------------------------------------------------------------------- /deps/google-benchmark/releasing.md: -------------------------------------------------------------------------------- 1 | # How to release 2 | 3 | * Make sure you're on master and synced to HEAD 4 | * Ensure the project builds and tests run (sanity check only, obviously) 5 | * `parallel -j0 exec ::: test/*_test` can help ensure everything at least 6 | passes 7 | * Prepare release notes 8 | * `git log $(git describe --abbrev=0 --tags)..HEAD` gives you the list of 9 | commits between the last annotated tag and HEAD 10 | * Pick the most interesting. 11 | * Create a release through github's interface 12 | * Note this will create a lightweight tag. 13 | * Update this to an annotated tag: 14 | * `git pull --tags` 15 | * `git tag -a -f ` 16 | * `git push --force origin` 17 | -------------------------------------------------------------------------------- /deps/google-benchmark/src/arraysize.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_ARRAYSIZE_H_ 2 | #define BENCHMARK_ARRAYSIZE_H_ 3 | 4 | #include "internal_macros.h" 5 | 6 | namespace benchmark { 7 | namespace internal { 8 | // The arraysize(arr) macro returns the # of elements in an array arr. 9 | // The expression is a compile-time constant, and therefore can be 10 | // used in defining new arrays, for example. If you use arraysize on 11 | // a pointer by mistake, you will get a compile-time error. 12 | // 13 | 14 | // This template function declaration is used in defining arraysize. 15 | // Note that the function doesn't need an implementation, as we only 16 | // use its type. 17 | template 18 | char (&ArraySizeHelper(T (&array)[N]))[N]; 19 | 20 | // That gcc wants both of these prototypes seems mysterious. VC, for 21 | // its part, can't decide which to use (another mystery). Matching of 22 | // template overloads: the final frontier. 23 | #ifndef COMPILER_MSVC 24 | template 25 | char (&ArraySizeHelper(const T (&array)[N]))[N]; 26 | #endif 27 | 28 | #define arraysize(array) (sizeof(::benchmark::internal::ArraySizeHelper(array))) 29 | 30 | } // end namespace internal 31 | } // end namespace benchmark 32 | 33 | #endif // BENCHMARK_ARRAYSIZE_H_ 34 | -------------------------------------------------------------------------------- /deps/google-benchmark/src/benchmark_api_internal.cc: -------------------------------------------------------------------------------- 1 | #include "benchmark_api_internal.h" 2 | 3 | namespace benchmark { 4 | namespace internal { 5 | 6 | State BenchmarkInstance::Run(IterationCount iters, int thread_id, 7 | internal::ThreadTimer* timer, 8 | internal::ThreadManager* manager) const { 9 | State st(iters, arg, thread_id, threads, timer, manager); 10 | benchmark->Run(st); 11 | return st; 12 | } 13 | 14 | } // internal 15 | } // benchmark 16 | -------------------------------------------------------------------------------- /deps/google-benchmark/src/benchmark_api_internal.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_API_INTERNAL_H 2 | #define BENCHMARK_API_INTERNAL_H 3 | 4 | #include "benchmark/benchmark.h" 5 | #include "commandlineflags.h" 6 | 7 | #include 8 | #include 9 | #include 10 | #include 11 | #include 12 | #include 13 | 14 | namespace benchmark { 15 | namespace internal { 16 | 17 | // Information kept per benchmark we may want to run 18 | struct BenchmarkInstance { 19 | BenchmarkName name; 20 | Benchmark* benchmark; 21 | AggregationReportMode aggregation_report_mode; 22 | std::vector arg; 23 | TimeUnit time_unit; 24 | int range_multiplier; 25 | bool measure_process_cpu_time; 26 | bool use_real_time; 27 | bool use_manual_time; 28 | BigO complexity; 29 | BigOFunc* complexity_lambda; 30 | UserCounters counters; 31 | const std::vector* statistics; 32 | bool last_benchmark_instance; 33 | int repetitions; 34 | double min_time; 35 | IterationCount iterations; 36 | int threads; // Number of concurrent threads to us 37 | 38 | State Run(IterationCount iters, int thread_id, internal::ThreadTimer* timer, 39 | internal::ThreadManager* manager) const; 40 | }; 41 | 42 | bool FindBenchmarksInternal(const std::string& re, 43 | std::vector* benchmarks, 44 | std::ostream* Err); 45 | 46 | bool IsZero(double n); 47 | 48 | ConsoleReporter::OutputOptions GetOutputOptions(bool force_no_color = false); 49 | 50 | } // end namespace internal 51 | } // end namespace benchmark 52 | 53 | #endif // BENCHMARK_API_INTERNAL_H 54 | -------------------------------------------------------------------------------- /deps/google-benchmark/src/benchmark_main.cc: -------------------------------------------------------------------------------- 1 | // Copyright 2018 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #include "benchmark/benchmark.h" 16 | 17 | BENCHMARK_MAIN(); 18 | -------------------------------------------------------------------------------- /deps/google-benchmark/src/benchmark_runner.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef BENCHMARK_RUNNER_H_ 16 | #define BENCHMARK_RUNNER_H_ 17 | 18 | #include "benchmark_api_internal.h" 19 | #include "internal_macros.h" 20 | 21 | DECLARE_double(benchmark_min_time); 22 | 23 | DECLARE_int32(benchmark_repetitions); 24 | 25 | DECLARE_bool(benchmark_report_aggregates_only); 26 | 27 | DECLARE_bool(benchmark_display_aggregates_only); 28 | 29 | namespace benchmark { 30 | 31 | namespace internal { 32 | 33 | extern MemoryManager* memory_manager; 34 | 35 | struct RunResults { 36 | std::vector non_aggregates; 37 | std::vector aggregates_only; 38 | 39 | bool display_report_aggregates_only = false; 40 | bool file_report_aggregates_only = false; 41 | }; 42 | 43 | RunResults RunBenchmark( 44 | const benchmark::internal::BenchmarkInstance& b, 45 | std::vector* complexity_reports); 46 | 47 | } // namespace internal 48 | 49 | } // end namespace benchmark 50 | 51 | #endif // BENCHMARK_RUNNER_H_ 52 | -------------------------------------------------------------------------------- /deps/google-benchmark/src/colorprint.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_COLORPRINT_H_ 2 | #define BENCHMARK_COLORPRINT_H_ 3 | 4 | #include 5 | #include 6 | #include 7 | 8 | namespace benchmark { 9 | enum LogColor { 10 | COLOR_DEFAULT, 11 | COLOR_RED, 12 | COLOR_GREEN, 13 | COLOR_YELLOW, 14 | COLOR_BLUE, 15 | COLOR_MAGENTA, 16 | COLOR_CYAN, 17 | COLOR_WHITE 18 | }; 19 | 20 | std::string FormatString(const char* msg, va_list args); 21 | std::string FormatString(const char* msg, ...); 22 | 23 | void ColorPrintf(std::ostream& out, LogColor color, const char* fmt, 24 | va_list args); 25 | void ColorPrintf(std::ostream& out, LogColor color, const char* fmt, ...); 26 | 27 | // Returns true if stdout appears to be a terminal that supports colored 28 | // output, false otherwise. 29 | bool IsColorTerminal(); 30 | 31 | } // end namespace benchmark 32 | 33 | #endif // BENCHMARK_COLORPRINT_H_ 34 | -------------------------------------------------------------------------------- /deps/google-benchmark/src/counter.h: -------------------------------------------------------------------------------- 1 | // Copyright 2015 Google Inc. All rights reserved. 2 | // 3 | // Licensed under the Apache License, Version 2.0 (the "License"); 4 | // you may not use this file except in compliance with the License. 5 | // You may obtain a copy of the License at 6 | // 7 | // http://www.apache.org/licenses/LICENSE-2.0 8 | // 9 | // Unless required by applicable law or agreed to in writing, software 10 | // distributed under the License is distributed on an "AS IS" BASIS, 11 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 12 | // See the License for the specific language governing permissions and 13 | // limitations under the License. 14 | 15 | #ifndef BENCHMARK_COUNTER_H_ 16 | #define BENCHMARK_COUNTER_H_ 17 | 18 | #include "benchmark/benchmark.h" 19 | 20 | namespace benchmark { 21 | 22 | // these counter-related functions are hidden to reduce API surface. 23 | namespace internal { 24 | void Finish(UserCounters* l, IterationCount iterations, double time, 25 | double num_threads); 26 | void Increment(UserCounters* l, UserCounters const& r); 27 | bool SameNames(UserCounters const& l, UserCounters const& r); 28 | } // end namespace internal 29 | 30 | } // end namespace benchmark 31 | 32 | #endif // BENCHMARK_COUNTER_H_ 33 | -------------------------------------------------------------------------------- /deps/google-benchmark/src/sleep.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_SLEEP_H_ 2 | #define BENCHMARK_SLEEP_H_ 3 | 4 | namespace benchmark { 5 | const int kNumMillisPerSecond = 1000; 6 | const int kNumMicrosPerMilli = 1000; 7 | const int kNumMicrosPerSecond = kNumMillisPerSecond * 1000; 8 | const int kNumNanosPerMicro = 1000; 9 | const int kNumNanosPerSecond = kNumNanosPerMicro * kNumMicrosPerSecond; 10 | 11 | void SleepForMilliseconds(int milliseconds); 12 | void SleepForSeconds(double seconds); 13 | } // end namespace benchmark 14 | 15 | #endif // BENCHMARK_SLEEP_H_ 16 | -------------------------------------------------------------------------------- /deps/google-benchmark/src/statistics.h: -------------------------------------------------------------------------------- 1 | // Copyright 2016 Ismael Jimenez Martinez. All rights reserved. 2 | // Copyright 2017 Roman Lebedev. All rights reserved. 3 | // 4 | // Licensed under the Apache License, Version 2.0 (the "License"); 5 | // you may not use this file except in compliance with the License. 6 | // You may obtain a copy of the License at 7 | // 8 | // http://www.apache.org/licenses/LICENSE-2.0 9 | // 10 | // Unless required by applicable law or agreed to in writing, software 11 | // distributed under the License is distributed on an "AS IS" BASIS, 12 | // WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 13 | // See the License for the specific language governing permissions and 14 | // limitations under the License. 15 | 16 | #ifndef STATISTICS_H_ 17 | #define STATISTICS_H_ 18 | 19 | #include 20 | 21 | #include "benchmark/benchmark.h" 22 | 23 | namespace benchmark { 24 | 25 | // Return a vector containing the mean, median and standard devation information 26 | // (and any user-specified info) for the specified list of reports. If 'reports' 27 | // contains less than two non-errored runs an empty vector is returned 28 | std::vector ComputeStats( 29 | const std::vector& reports); 30 | 31 | double StatisticsMean(const std::vector& v); 32 | double StatisticsMedian(const std::vector& v); 33 | double StatisticsStdDev(const std::vector& v); 34 | 35 | } // end namespace benchmark 36 | 37 | #endif // STATISTICS_H_ 38 | -------------------------------------------------------------------------------- /deps/google-benchmark/src/timers.h: -------------------------------------------------------------------------------- 1 | #ifndef BENCHMARK_TIMERS_H 2 | #define BENCHMARK_TIMERS_H 3 | 4 | #include 5 | #include 6 | 7 | namespace benchmark { 8 | 9 | // Return the CPU usage of the current process 10 | double ProcessCPUUsage(); 11 | 12 | // Return the CPU usage of the children of the current process 13 | double ChildrenCPUUsage(); 14 | 15 | // Return the CPU usage of the current thread 16 | double ThreadCPUUsage(); 17 | 18 | #if defined(HAVE_STEADY_CLOCK) 19 | template 20 | struct ChooseSteadyClock { 21 | typedef std::chrono::high_resolution_clock type; 22 | }; 23 | 24 | template <> 25 | struct ChooseSteadyClock { 26 | typedef std::chrono::steady_clock type; 27 | }; 28 | #endif 29 | 30 | struct ChooseClockType { 31 | #if defined(HAVE_STEADY_CLOCK) 32 | typedef ChooseSteadyClock<>::type type; 33 | #else 34 | typedef std::chrono::high_resolution_clock type; 35 | #endif 36 | }; 37 | 38 | inline double ChronoClockNow() { 39 | typedef ChooseClockType::type ClockType; 40 | using FpSeconds = std::chrono::duration; 41 | return FpSeconds(ClockType::now().time_since_epoch()).count(); 42 | } 43 | 44 | std::string LocalDateTimeString(); 45 | 46 | } // end namespace benchmark 47 | 48 | #endif // BENCHMARK_TIMERS_H 49 | -------------------------------------------------------------------------------- /deps/google-benchmark/test/AssemblyTests.cmake: -------------------------------------------------------------------------------- 1 | 2 | include(split_list) 3 | 4 | set(ASM_TEST_FLAGS "") 5 | check_cxx_compiler_flag(-O3 BENCHMARK_HAS_O3_FLAG) 6 | if (BENCHMARK_HAS_O3_FLAG) 7 | list(APPEND ASM_TEST_FLAGS -O3) 8 | endif() 9 | 10 | check_cxx_compiler_flag(-g0 BENCHMARK_HAS_G0_FLAG) 11 | if (BENCHMARK_HAS_G0_FLAG) 12 | list(APPEND ASM_TEST_FLAGS -g0) 13 | endif() 14 | 15 | check_cxx_compiler_flag(-fno-stack-protector BENCHMARK_HAS_FNO_STACK_PROTECTOR_FLAG) 16 | if (BENCHMARK_HAS_FNO_STACK_PROTECTOR_FLAG) 17 | list(APPEND ASM_TEST_FLAGS -fno-stack-protector) 18 | endif() 19 | 20 | split_list(ASM_TEST_FLAGS) 21 | string(TOUPPER "${CMAKE_CXX_COMPILER_ID}" ASM_TEST_COMPILER) 22 | 23 | macro(add_filecheck_test name) 24 | cmake_parse_arguments(ARG "" "" "CHECK_PREFIXES" ${ARGV}) 25 | add_library(${name} OBJECT ${name}.cc) 26 | set_target_properties(${name} PROPERTIES COMPILE_FLAGS "-S ${ASM_TEST_FLAGS}") 27 | set(ASM_OUTPUT_FILE "${CMAKE_CURRENT_BINARY_DIR}/${name}.s") 28 | add_custom_target(copy_${name} ALL 29 | COMMAND ${PROJECT_SOURCE_DIR}/tools/strip_asm.py 30 | $ 31 | ${ASM_OUTPUT_FILE} 32 | BYPRODUCTS ${ASM_OUTPUT_FILE}) 33 | add_dependencies(copy_${name} ${name}) 34 | if (NOT ARG_CHECK_PREFIXES) 35 | set(ARG_CHECK_PREFIXES "CHECK") 36 | endif() 37 | foreach(prefix ${ARG_CHECK_PREFIXES}) 38 | add_test(NAME run_${name}_${prefix} 39 | COMMAND 40 | ${LLVM_FILECHECK_EXE} ${name}.cc 41 | --input-file=${ASM_OUTPUT_FILE} 42 | --check-prefixes=CHECK,CHECK-${ASM_TEST_COMPILER} 43 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 44 | endforeach() 45 | endmacro() 46 | 47 | -------------------------------------------------------------------------------- /deps/google-benchmark/test/clobber_memory_assembly_test.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #ifdef __clang__ 4 | #pragma clang diagnostic ignored "-Wreturn-type" 5 | #endif 6 | 7 | extern "C" { 8 | 9 | extern int ExternInt; 10 | extern int ExternInt2; 11 | extern int ExternInt3; 12 | 13 | } 14 | 15 | // CHECK-LABEL: test_basic: 16 | extern "C" void test_basic() { 17 | int x; 18 | benchmark::DoNotOptimize(&x); 19 | x = 101; 20 | benchmark::ClobberMemory(); 21 | // CHECK: leaq [[DEST:[^,]+]], %rax 22 | // CHECK: movl $101, [[DEST]] 23 | // CHECK: ret 24 | } 25 | 26 | // CHECK-LABEL: test_redundant_store: 27 | extern "C" void test_redundant_store() { 28 | ExternInt = 3; 29 | benchmark::ClobberMemory(); 30 | ExternInt = 51; 31 | // CHECK-DAG: ExternInt 32 | // CHECK-DAG: movl $3 33 | // CHECK: movl $51 34 | } 35 | 36 | // CHECK-LABEL: test_redundant_read: 37 | extern "C" void test_redundant_read() { 38 | int x; 39 | benchmark::DoNotOptimize(&x); 40 | x = ExternInt; 41 | benchmark::ClobberMemory(); 42 | x = ExternInt2; 43 | // CHECK: leaq [[DEST:[^,]+]], %rax 44 | // CHECK: ExternInt(%rip) 45 | // CHECK: movl %eax, [[DEST]] 46 | // CHECK-NOT: ExternInt2 47 | // CHECK: ret 48 | } 49 | 50 | // CHECK-LABEL: test_redundant_read2: 51 | extern "C" void test_redundant_read2() { 52 | int x; 53 | benchmark::DoNotOptimize(&x); 54 | x = ExternInt; 55 | benchmark::ClobberMemory(); 56 | x = ExternInt2; 57 | benchmark::ClobberMemory(); 58 | // CHECK: leaq [[DEST:[^,]+]], %rax 59 | // CHECK: ExternInt(%rip) 60 | // CHECK: movl %eax, [[DEST]] 61 | // CHECK: ExternInt2(%rip) 62 | // CHECK: movl %eax, [[DEST]] 63 | // CHECK: ret 64 | } 65 | -------------------------------------------------------------------------------- /deps/google-benchmark/test/donotoptimize_test.cc: -------------------------------------------------------------------------------- 1 | #include "benchmark/benchmark.h" 2 | 3 | #include 4 | 5 | namespace { 6 | #if defined(__GNUC__) 7 | std::uint64_t double_up(const std::uint64_t x) __attribute__((const)); 8 | #endif 9 | std::uint64_t double_up(const std::uint64_t x) { return x * 2; } 10 | } 11 | 12 | // Using DoNotOptimize on types like BitRef seem to cause a lot of problems 13 | // with the inline assembly on both GCC and Clang. 14 | struct BitRef { 15 | int index; 16 | unsigned char &byte; 17 | 18 | public: 19 | static BitRef Make() { 20 | static unsigned char arr[2] = {}; 21 | BitRef b(1, arr[0]); 22 | return b; 23 | } 24 | private: 25 | BitRef(int i, unsigned char& b) : index(i), byte(b) {} 26 | }; 27 | 28 | int main(int, char*[]) { 29 | // this test verifies compilation of DoNotOptimize() for some types 30 | 31 | char buffer8[8] = ""; 32 | benchmark::DoNotOptimize(buffer8); 33 | 34 | char buffer20[20] = ""; 35 | benchmark::DoNotOptimize(buffer20); 36 | 37 | char buffer1024[1024] = ""; 38 | benchmark::DoNotOptimize(buffer1024); 39 | benchmark::DoNotOptimize(&buffer1024[0]); 40 | 41 | int x = 123; 42 | benchmark::DoNotOptimize(x); 43 | benchmark::DoNotOptimize(&x); 44 | benchmark::DoNotOptimize(x += 42); 45 | 46 | benchmark::DoNotOptimize(double_up(x)); 47 | 48 | // These tests are to e 49 | benchmark::DoNotOptimize(BitRef::Make()); 50 | BitRef lval = BitRef::Make(); 51 | benchmark::DoNotOptimize(lval); 52 | } 53 | -------------------------------------------------------------------------------- /deps/google-benchmark/test/fixture_test.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "benchmark/benchmark.h" 3 | 4 | #include 5 | #include 6 | 7 | class MyFixture : public ::benchmark::Fixture { 8 | public: 9 | void SetUp(const ::benchmark::State& state) { 10 | if (state.thread_index == 0) { 11 | assert(data.get() == nullptr); 12 | data.reset(new int(42)); 13 | } 14 | } 15 | 16 | void TearDown(const ::benchmark::State& state) { 17 | if (state.thread_index == 0) { 18 | assert(data.get() != nullptr); 19 | data.reset(); 20 | } 21 | } 22 | 23 | ~MyFixture() { assert(data == nullptr); } 24 | 25 | std::unique_ptr data; 26 | }; 27 | 28 | BENCHMARK_F(MyFixture, Foo)(benchmark::State &st) { 29 | assert(data.get() != nullptr); 30 | assert(*data == 42); 31 | for (auto _ : st) { 32 | } 33 | } 34 | 35 | BENCHMARK_DEFINE_F(MyFixture, Bar)(benchmark::State& st) { 36 | if (st.thread_index == 0) { 37 | assert(data.get() != nullptr); 38 | assert(*data == 42); 39 | } 40 | for (auto _ : st) { 41 | assert(data.get() != nullptr); 42 | assert(*data == 42); 43 | } 44 | st.SetItemsProcessed(st.range(0)); 45 | } 46 | BENCHMARK_REGISTER_F(MyFixture, Bar)->Arg(42); 47 | BENCHMARK_REGISTER_F(MyFixture, Bar)->Arg(42)->ThreadPerCpu(); 48 | 49 | BENCHMARK_MAIN(); 50 | -------------------------------------------------------------------------------- /deps/google-benchmark/test/link_main_test.cc: -------------------------------------------------------------------------------- 1 | #include "benchmark/benchmark.h" 2 | 3 | void BM_empty(benchmark::State& state) { 4 | for (auto _ : state) { 5 | benchmark::DoNotOptimize(state.iterations()); 6 | } 7 | } 8 | BENCHMARK(BM_empty); 9 | -------------------------------------------------------------------------------- /deps/google-benchmark/test/map_test.cc: -------------------------------------------------------------------------------- 1 | #include "benchmark/benchmark.h" 2 | 3 | #include 4 | #include 5 | 6 | namespace { 7 | 8 | std::map ConstructRandomMap(int size) { 9 | std::map m; 10 | for (int i = 0; i < size; ++i) { 11 | m.insert(std::make_pair(std::rand() % size, std::rand() % size)); 12 | } 13 | return m; 14 | } 15 | 16 | } // namespace 17 | 18 | // Basic version. 19 | static void BM_MapLookup(benchmark::State& state) { 20 | const int size = static_cast(state.range(0)); 21 | std::map m; 22 | for (auto _ : state) { 23 | state.PauseTiming(); 24 | m = ConstructRandomMap(size); 25 | state.ResumeTiming(); 26 | for (int i = 0; i < size; ++i) { 27 | benchmark::DoNotOptimize(m.find(std::rand() % size)); 28 | } 29 | } 30 | state.SetItemsProcessed(state.iterations() * size); 31 | } 32 | BENCHMARK(BM_MapLookup)->Range(1 << 3, 1 << 12); 33 | 34 | // Using fixtures. 35 | class MapFixture : public ::benchmark::Fixture { 36 | public: 37 | void SetUp(const ::benchmark::State& st) { 38 | m = ConstructRandomMap(static_cast(st.range(0))); 39 | } 40 | 41 | void TearDown(const ::benchmark::State&) { m.clear(); } 42 | 43 | std::map m; 44 | }; 45 | 46 | BENCHMARK_DEFINE_F(MapFixture, Lookup)(benchmark::State& state) { 47 | const int size = static_cast(state.range(0)); 48 | for (auto _ : state) { 49 | for (int i = 0; i < size; ++i) { 50 | benchmark::DoNotOptimize(m.find(std::rand() % size)); 51 | } 52 | } 53 | state.SetItemsProcessed(state.iterations() * size); 54 | } 55 | BENCHMARK_REGISTER_F(MapFixture, Lookup)->Range(1 << 3, 1 << 12); 56 | 57 | BENCHMARK_MAIN(); 58 | -------------------------------------------------------------------------------- /deps/google-benchmark/test/report_aggregates_only_test.cc: -------------------------------------------------------------------------------- 1 | 2 | #undef NDEBUG 3 | #include 4 | #include 5 | 6 | #include "benchmark/benchmark.h" 7 | #include "output_test.h" 8 | 9 | // Ok this test is super ugly. We want to check what happens with the file 10 | // reporter in the presence of ReportAggregatesOnly(). 11 | // We do not care about console output, the normal tests check that already. 12 | 13 | void BM_SummaryRepeat(benchmark::State& state) { 14 | for (auto _ : state) { 15 | } 16 | } 17 | BENCHMARK(BM_SummaryRepeat)->Repetitions(3)->ReportAggregatesOnly(); 18 | 19 | int main(int argc, char* argv[]) { 20 | const std::string output = GetFileReporterOutput(argc, argv); 21 | 22 | if (SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3") != 3 || 23 | SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_mean\"") != 1 || 24 | SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_median\"") != 25 | 1 || 26 | SubstrCnt(output, "\"name\": \"BM_SummaryRepeat/repeats:3_stddev\"") != 27 | 1) { 28 | std::cout << "Precondition mismatch. Expected to only find three " 29 | "occurrences of \"BM_SummaryRepeat/repeats:3\" substring:\n" 30 | "\"name\": \"BM_SummaryRepeat/repeats:3_mean\", " 31 | "\"name\": \"BM_SummaryRepeat/repeats:3_median\", " 32 | "\"name\": \"BM_SummaryRepeat/repeats:3_stddev\"\nThe entire " 33 | "output:\n"; 34 | std::cout << output; 35 | return 1; 36 | } 37 | 38 | return 0; 39 | } 40 | -------------------------------------------------------------------------------- /deps/google-benchmark/test/statistics_gtest.cc: -------------------------------------------------------------------------------- 1 | //===---------------------------------------------------------------------===// 2 | // statistics_test - Unit tests for src/statistics.cc 3 | //===---------------------------------------------------------------------===// 4 | 5 | #include "../src/statistics.h" 6 | #include "gtest/gtest.h" 7 | 8 | namespace { 9 | TEST(StatisticsTest, Mean) { 10 | EXPECT_DOUBLE_EQ(benchmark::StatisticsMean({42, 42, 42, 42}), 42.0); 11 | EXPECT_DOUBLE_EQ(benchmark::StatisticsMean({1, 2, 3, 4}), 2.5); 12 | EXPECT_DOUBLE_EQ(benchmark::StatisticsMean({1, 2, 5, 10, 10, 14}), 7.0); 13 | } 14 | 15 | TEST(StatisticsTest, Median) { 16 | EXPECT_DOUBLE_EQ(benchmark::StatisticsMedian({42, 42, 42, 42}), 42.0); 17 | EXPECT_DOUBLE_EQ(benchmark::StatisticsMedian({1, 2, 3, 4}), 2.5); 18 | EXPECT_DOUBLE_EQ(benchmark::StatisticsMedian({1, 2, 5, 10, 10}), 5.0); 19 | } 20 | 21 | TEST(StatisticsTest, StdDev) { 22 | EXPECT_DOUBLE_EQ(benchmark::StatisticsStdDev({101, 101, 101, 101}), 0.0); 23 | EXPECT_DOUBLE_EQ(benchmark::StatisticsStdDev({1, 2, 3}), 1.0); 24 | EXPECT_DOUBLE_EQ(benchmark::StatisticsStdDev({2.5, 2.4, 3.3, 4.2, 5.1}), 25 | 1.151086443322134); 26 | } 27 | 28 | } // end namespace 29 | -------------------------------------------------------------------------------- /deps/google-benchmark/test/templated_fixture_test.cc: -------------------------------------------------------------------------------- 1 | 2 | #include "benchmark/benchmark.h" 3 | 4 | #include 5 | #include 6 | 7 | template 8 | class MyFixture : public ::benchmark::Fixture { 9 | public: 10 | MyFixture() : data(0) {} 11 | 12 | T data; 13 | }; 14 | 15 | BENCHMARK_TEMPLATE_F(MyFixture, Foo, int)(benchmark::State& st) { 16 | for (auto _ : st) { 17 | data += 1; 18 | } 19 | } 20 | 21 | BENCHMARK_TEMPLATE_DEFINE_F(MyFixture, Bar, double)(benchmark::State& st) { 22 | for (auto _ : st) { 23 | data += 1.0; 24 | } 25 | } 26 | BENCHMARK_REGISTER_F(MyFixture, Bar); 27 | 28 | BENCHMARK_MAIN(); 29 | -------------------------------------------------------------------------------- /deps/google-benchmark/tools/gbench/Inputs/test3_run0.json: -------------------------------------------------------------------------------- 1 | { 2 | "context": { 3 | "date": "2016-08-02 17:44:46", 4 | "num_cpus": 4, 5 | "mhz_per_cpu": 4228, 6 | "cpu_scaling_enabled": false, 7 | "library_build_type": "release" 8 | }, 9 | "benchmarks": [ 10 | { 11 | "name": "BM_One", 12 | "run_type": "aggregate", 13 | "iterations": 1000, 14 | "real_time": 10, 15 | "cpu_time": 100, 16 | "time_unit": "ns" 17 | }, 18 | { 19 | "name": "BM_Two", 20 | "iterations": 1000, 21 | "real_time": 9, 22 | "cpu_time": 90, 23 | "time_unit": "ns" 24 | }, 25 | { 26 | "name": "BM_Two", 27 | "iterations": 1000, 28 | "real_time": 8, 29 | "cpu_time": 86, 30 | "time_unit": "ns" 31 | }, 32 | { 33 | "name": "short", 34 | "run_type": "aggregate", 35 | "iterations": 1000, 36 | "real_time": 8, 37 | "cpu_time": 80, 38 | "time_unit": "ns" 39 | }, 40 | { 41 | "name": "short", 42 | "run_type": "aggregate", 43 | "iterations": 1000, 44 | "real_time": 8, 45 | "cpu_time": 77, 46 | "time_unit": "ns" 47 | }, 48 | { 49 | "name": "medium", 50 | "run_type": "iteration", 51 | "iterations": 1000, 52 | "real_time": 8, 53 | "cpu_time": 80, 54 | "time_unit": "ns" 55 | }, 56 | { 57 | "name": "medium", 58 | "run_type": "iteration", 59 | "iterations": 1000, 60 | "real_time": 9, 61 | "cpu_time": 82, 62 | "time_unit": "ns" 63 | } 64 | ] 65 | } 66 | -------------------------------------------------------------------------------- /deps/google-benchmark/tools/gbench/Inputs/test3_run1.json: -------------------------------------------------------------------------------- 1 | { 2 | "context": { 3 | "date": "2016-08-02 17:44:46", 4 | "num_cpus": 4, 5 | "mhz_per_cpu": 4228, 6 | "cpu_scaling_enabled": false, 7 | "library_build_type": "release" 8 | }, 9 | "benchmarks": [ 10 | { 11 | "name": "BM_One", 12 | "iterations": 1000, 13 | "real_time": 9, 14 | "cpu_time": 110, 15 | "time_unit": "ns" 16 | }, 17 | { 18 | "name": "BM_Two", 19 | "run_type": "aggregate", 20 | "iterations": 1000, 21 | "real_time": 10, 22 | "cpu_time": 89, 23 | "time_unit": "ns" 24 | }, 25 | { 26 | "name": "BM_Two", 27 | "iterations": 1000, 28 | "real_time": 7, 29 | "cpu_time": 72, 30 | "time_unit": "ns" 31 | }, 32 | { 33 | "name": "short", 34 | "run_type": "aggregate", 35 | "iterations": 1000, 36 | "real_time": 7, 37 | "cpu_time": 75, 38 | "time_unit": "ns" 39 | }, 40 | { 41 | "name": "short", 42 | "run_type": "aggregate", 43 | "iterations": 762, 44 | "real_time": 4.54, 45 | "cpu_time": 66.6, 46 | "time_unit": "ns" 47 | }, 48 | { 49 | "name": "short", 50 | "run_type": "iteration", 51 | "iterations": 1000, 52 | "real_time": 800, 53 | "cpu_time": 1, 54 | "time_unit": "ns" 55 | }, 56 | { 57 | "name": "medium", 58 | "run_type": "iteration", 59 | "iterations": 1200, 60 | "real_time": 5, 61 | "cpu_time": 53, 62 | "time_unit": "ns" 63 | } 64 | ] 65 | } 66 | -------------------------------------------------------------------------------- /deps/google-benchmark/tools/gbench/__init__.py: -------------------------------------------------------------------------------- 1 | """Google Benchmark tooling""" 2 | 3 | __author__ = 'Eric Fiselier' 4 | __email__ = 'eric@efcs.ca' 5 | __versioninfo__ = (0, 5, 0) 6 | __version__ = '.'.join(str(v) for v in __versioninfo__) + 'dev' 7 | 8 | __all__ = [] 9 | -------------------------------------------------------------------------------- /deps/gtest-1.11.0/CONTRIBUTORS: -------------------------------------------------------------------------------- 1 | # This file contains a list of people who've made non-trivial 2 | # contribution to the Google C++ Testing Framework project. People 3 | # who commit code to the project are encouraged to add their names 4 | # here. Please keep the list sorted by first names. 5 | 6 | Ajay Joshi 7 | Balázs Dán 8 | Bharat Mediratta 9 | Chandler Carruth 10 | Chris Prince 11 | Chris Taylor 12 | Dan Egnor 13 | Eric Roman 14 | Hady Zalek 15 | Jeffrey Yasskin 16 | Jói Sigurðsson 17 | Keir Mierle 18 | Keith Ray 19 | Kenton Varda 20 | Manuel Klimek 21 | Markus Heule 22 | Mika Raento 23 | Miklós Fazekas 24 | Pasi Valminen 25 | Patrick Hanna 26 | Patrick Riley 27 | Peter Kaminski 28 | Preston Jackson 29 | Rainer Klaffenboeck 30 | Russ Cox 31 | Russ Rufer 32 | Sean Mcafee 33 | Sigurður Ásgeirsson 34 | Tracy Bialik 35 | Vadim Berman 36 | Vlad Losev 37 | Zhanyong Wan 38 | -------------------------------------------------------------------------------- /deps/gtest-1.11.0/LICENSE: -------------------------------------------------------------------------------- 1 | Copyright 2008, Google Inc. 2 | All rights reserved. 3 | 4 | Redistribution and use in source and binary forms, with or without 5 | modification, are permitted provided that the following conditions are 6 | met: 7 | 8 | * Redistributions of source code must retain the above copyright 9 | notice, this list of conditions and the following disclaimer. 10 | * Redistributions in binary form must reproduce the above 11 | copyright notice, this list of conditions and the following disclaimer 12 | in the documentation and/or other materials provided with the 13 | distribution. 14 | * Neither the name of Google Inc. nor the names of its 15 | contributors may be used to endorse or promote products derived from 16 | this 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 22 | OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 23 | SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 24 | LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 25 | DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 26 | THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 27 | (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 28 | OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 29 | -------------------------------------------------------------------------------- /deps/gtest-1.11.0/cmake/Config.cmake.in: -------------------------------------------------------------------------------- 1 | @PACKAGE_INIT@ 2 | include(CMakeFindDependencyMacro) 3 | if (@GTEST_HAS_PTHREAD@) 4 | set(THREADS_PREFER_PTHREAD_FLAG @THREADS_PREFER_PTHREAD_FLAG@) 5 | find_dependency(Threads) 6 | endif() 7 | 8 | include("${CMAKE_CURRENT_LIST_DIR}/@targets_export_name@.cmake") 9 | check_required_components("@project_name@") 10 | -------------------------------------------------------------------------------- /deps/gtest-1.11.0/cmake/gtest.pc.in: -------------------------------------------------------------------------------- 1 | prefix=${pcfiledir}/../.. 2 | libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ 3 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 4 | 5 | Name: gtest 6 | Description: GoogleTest (without main() function) 7 | Version: @PROJECT_VERSION@ 8 | URL: https://github.com/google/googletest 9 | Libs: -L${libdir} -lgtest @CMAKE_THREAD_LIBS_INIT@ 10 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ 11 | -------------------------------------------------------------------------------- /deps/gtest-1.11.0/cmake/gtest_main.pc.in: -------------------------------------------------------------------------------- 1 | prefix=${pcfiledir}/../.. 2 | libdir=${prefix}/@CMAKE_INSTALL_LIBDIR@ 3 | includedir=${prefix}/@CMAKE_INSTALL_INCLUDEDIR@ 4 | 5 | Name: gtest_main 6 | Description: GoogleTest (with main() function) 7 | Version: @PROJECT_VERSION@ 8 | URL: https://github.com/google/googletest 9 | Requires: gtest 10 | Libs: -L${libdir} -lgtest_main @CMAKE_THREAD_LIBS_INIT@ 11 | Cflags: -I${includedir} @GTEST_HAS_PTHREAD_MACRO@ @CMAKE_THREAD_LIBS_INIT@ 12 | -------------------------------------------------------------------------------- /deps/gtest-1.11.0/cmake/libgtest.la.in: -------------------------------------------------------------------------------- 1 | # libgtest.la - a libtool library file 2 | # Generated by libtool (GNU libtool) 2.4.6 3 | 4 | # Please DO NOT delete this file! 5 | # It is necessary for linking the library. 6 | 7 | # Names of this library. 8 | library_names='libgtest.so' 9 | 10 | # Is this an already installed library? 11 | installed=yes 12 | 13 | # Should we warn about portability when linking against -modules? 14 | shouldnotlink=no 15 | 16 | # Files to dlopen/dlpreopen 17 | dlopen='' 18 | dlpreopen='' 19 | 20 | # Directory that this library needs to be installed in: 21 | libdir='@CMAKE_INSTALL_FULL_LIBDIR@' 22 | -------------------------------------------------------------------------------- /deps/gtest-1.11.0/docs/samples.md: -------------------------------------------------------------------------------- 1 | # Googletest Samples {#samples} 2 | 3 | If you're like us, you'd like to look at 4 | [googletest samples.](https://github.com/google/googletest/tree/master/googletest/samples) 5 | The sample directory has a number of well-commented samples showing how to use a 6 | variety of googletest features. 7 | 8 | * Sample #1 shows the basic steps of using googletest to test C++ functions. 9 | * Sample #2 shows a more complex unit test for a class with multiple member 10 | functions. 11 | * Sample #3 uses a test fixture. 12 | * Sample #4 teaches you how to use googletest and `googletest.h` together to 13 | get the best of both libraries. 14 | * Sample #5 puts shared testing logic in a base test fixture, and reuses it in 15 | derived fixtures. 16 | * Sample #6 demonstrates type-parameterized tests. 17 | * Sample #7 teaches the basics of value-parameterized tests. 18 | * Sample #8 shows using `Combine()` in value-parameterized tests. 19 | * Sample #9 shows use of the listener API to modify Google Test's console 20 | output and the use of its reflection API to inspect test results. 21 | * Sample #10 shows use of the listener API to implement a primitive memory 22 | leak checker. 23 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/AUTHORS: -------------------------------------------------------------------------------- 1 | Susumu Yata 2 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories(include) 2 | include_directories(lib) 3 | 4 | set( 5 | LIBMARISA_SOURCES 6 | lib/marisa/trie.cc 7 | lib/marisa/agent.cc 8 | lib/marisa/grimoire/io/reader.cc 9 | lib/marisa/grimoire/io/writer.cc 10 | lib/marisa/grimoire/io/mapper.cc 11 | lib/marisa/grimoire/trie/louds-trie.cc 12 | lib/marisa/grimoire/trie/tail.cc 13 | lib/marisa/grimoire/vector/bit-vector.cc 14 | lib/marisa/keyset.cc 15 | ) 16 | 17 | add_library(marisa STATIC ${LIBMARISA_SOURCES}) 18 | set_target_properties(marisa PROPERTIES POSITION_INDEPENDENT_CODE ON) 19 | source_group(marisa FILES ${LIBMARISA_SOURCES}) 20 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/include/marisa.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_H_ 2 | #define MARISA_H_ 3 | 4 | // "marisa/stdio.h" includes for I/O using std::FILE. 5 | #include "marisa/stdio.h" 6 | 7 | // "marisa/iostream.h" includes for I/O using std::iostream. 8 | #include "marisa/iostream.h" 9 | 10 | // You can use instead of if you don't need the 11 | // above I/O interfaces and don't want to include the above I/O headers. 12 | #include "marisa/trie.h" 13 | 14 | #endif // MARISA_H_ 15 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/include/marisa/iostream.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_IOSTREAM_H_ 2 | #define MARISA_IOSTREAM_H_ 3 | 4 | #include 5 | 6 | namespace marisa { 7 | 8 | class Trie; 9 | 10 | std::istream &read(std::istream &stream, Trie *trie); 11 | std::ostream &write(std::ostream &stream, const Trie &trie); 12 | 13 | std::istream &operator>>(std::istream &stream, Trie &trie); 14 | std::ostream &operator<<(std::ostream &stream, const Trie &trie); 15 | 16 | } // namespace marisa 17 | 18 | #endif // MARISA_IOSTREAM_H_ 19 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/include/marisa/scoped-array.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_SCOPED_ARRAY_H_ 2 | #define MARISA_SCOPED_ARRAY_H_ 3 | 4 | #include "marisa/base.h" 5 | 6 | namespace marisa { 7 | 8 | template 9 | class scoped_array { 10 | public: 11 | scoped_array() : array_(NULL) {} 12 | explicit scoped_array(T *array) : array_(array) {} 13 | 14 | ~scoped_array() { 15 | delete [] array_; 16 | } 17 | 18 | void reset(T *array = NULL) { 19 | MARISA_THROW_IF((array != NULL) && (array == array_), MARISA_RESET_ERROR); 20 | scoped_array(array).swap(*this); 21 | } 22 | 23 | T &operator[](std::size_t i) const { 24 | MARISA_DEBUG_IF(array_ == NULL, MARISA_STATE_ERROR); 25 | return array_[i]; 26 | } 27 | T *get() const { 28 | return array_; 29 | } 30 | 31 | void clear() { 32 | scoped_array().swap(*this); 33 | } 34 | void swap(scoped_array &rhs) { 35 | marisa::swap(array_, rhs.array_); 36 | } 37 | 38 | private: 39 | T *array_; 40 | 41 | // Disallows copy and assignment. 42 | scoped_array(const scoped_array &); 43 | scoped_array &operator=(const scoped_array &); 44 | }; 45 | 46 | } // namespace marisa 47 | 48 | #endif // MARISA_SCOPED_ARRAY_H_ 49 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/include/marisa/scoped-ptr.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_SCOPED_PTR_H_ 2 | #define MARISA_SCOPED_PTR_H_ 3 | 4 | #include "marisa/base.h" 5 | 6 | namespace marisa { 7 | 8 | template 9 | class scoped_ptr { 10 | public: 11 | scoped_ptr() : ptr_(NULL) {} 12 | explicit scoped_ptr(T *ptr) : ptr_(ptr) {} 13 | 14 | ~scoped_ptr() { 15 | delete ptr_; 16 | } 17 | 18 | void reset(T *ptr = NULL) { 19 | MARISA_THROW_IF((ptr != NULL) && (ptr == ptr_), MARISA_RESET_ERROR); 20 | scoped_ptr(ptr).swap(*this); 21 | } 22 | 23 | T &operator*() const { 24 | MARISA_DEBUG_IF(ptr_ == NULL, MARISA_STATE_ERROR); 25 | return *ptr_; 26 | } 27 | T *operator->() const { 28 | MARISA_DEBUG_IF(ptr_ == NULL, MARISA_STATE_ERROR); 29 | return ptr_; 30 | } 31 | T *get() const { 32 | return ptr_; 33 | } 34 | 35 | void clear() { 36 | scoped_ptr().swap(*this); 37 | } 38 | void swap(scoped_ptr &rhs) { 39 | marisa::swap(ptr_, rhs.ptr_); 40 | } 41 | 42 | private: 43 | T *ptr_; 44 | 45 | // Disallows copy and assignment. 46 | scoped_ptr(const scoped_ptr &); 47 | scoped_ptr &operator=(const scoped_ptr &); 48 | }; 49 | 50 | } // namespace marisa 51 | 52 | #endif // MARISA_SCOPED_PTR_H_ 53 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/include/marisa/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_MYSTDIO_H_ 2 | #define MARISA_MYSTDIO_H_ 3 | 4 | #include 5 | 6 | namespace marisa { 7 | 8 | class Trie; 9 | 10 | void fread(std::FILE *file, Trie *trie); 11 | void fwrite(std::FILE *file, const Trie &trie); 12 | 13 | } // namespace marisa 14 | 15 | #endif // MARISA_MYSTDIO_H_ 16 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/include/marisa/trie.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_TRIE_H_ 2 | #define MARISA_TRIE_H_ 3 | 4 | #include "marisa/keyset.h" 5 | #include "marisa/agent.h" 6 | 7 | namespace marisa { 8 | namespace grimoire { 9 | namespace trie { 10 | 11 | class LoudsTrie; 12 | 13 | } // namespace trie 14 | } // namespace grimoire 15 | 16 | class Trie { 17 | friend class TrieIO; 18 | 19 | public: 20 | Trie(); 21 | ~Trie(); 22 | 23 | void build(Keyset &keyset, int config_flags = 0); 24 | 25 | void mmap(const char *filename); 26 | void map(const void *ptr, std::size_t size); 27 | 28 | void load(const char *filename); 29 | void read(int fd); 30 | 31 | void save(const char *filename) const; 32 | void write(int fd) const; 33 | 34 | bool lookup(Agent &agent) const; 35 | void reverse_lookup(Agent &agent) const; 36 | bool common_prefix_search(Agent &agent) const; 37 | bool predictive_search(Agent &agent) const; 38 | 39 | std::size_t num_tries() const; 40 | std::size_t num_keys() const; 41 | std::size_t num_nodes() const; 42 | 43 | TailMode tail_mode() const; 44 | NodeOrder node_order() const; 45 | 46 | bool empty() const; 47 | std::size_t size() const; 48 | std::size_t total_size() const; 49 | std::size_t io_size() const; 50 | 51 | void clear(); 52 | void swap(Trie &rhs); 53 | 54 | private: 55 | scoped_ptr trie_; 56 | 57 | // Disallows copy and assignment. 58 | Trie(const Trie &); 59 | Trie &operator=(const Trie &); 60 | }; 61 | 62 | } // namespace marisa 63 | 64 | #endif // MARISA_TRIE_H_ 65 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/lib/marisa/agent.cc: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | #include "marisa/agent.h" 4 | #include "marisa/grimoire/trie.h" 5 | 6 | namespace marisa { 7 | 8 | Agent::Agent() : query_(), key_(), state_() {} 9 | 10 | Agent::~Agent() {} 11 | 12 | void Agent::set_query(const char *str) { 13 | MARISA_THROW_IF(str == NULL, MARISA_NULL_ERROR); 14 | if (state_.get() != NULL) { 15 | state_->reset(); 16 | } 17 | query_.set_str(str); 18 | } 19 | 20 | void Agent::set_query(const char *ptr, std::size_t length) { 21 | MARISA_THROW_IF((ptr == NULL) && (length != 0), MARISA_NULL_ERROR); 22 | if (state_.get() != NULL) { 23 | state_->reset(); 24 | } 25 | query_.set_str(ptr, length); 26 | } 27 | 28 | void Agent::set_query(std::size_t key_id) { 29 | if (state_.get() != NULL) { 30 | state_->reset(); 31 | } 32 | query_.set_id(key_id); 33 | } 34 | 35 | void Agent::init_state() { 36 | MARISA_THROW_IF(state_.get() != NULL, MARISA_STATE_ERROR); 37 | state_.reset(new (std::nothrow) grimoire::State); 38 | MARISA_THROW_IF(state_.get() == NULL, MARISA_MEMORY_ERROR); 39 | } 40 | 41 | void Agent::clear() { 42 | Agent().swap(*this); 43 | } 44 | 45 | void Agent::swap(Agent &rhs) { 46 | query_.swap(rhs.query_); 47 | key_.swap(rhs.key_); 48 | state_.swap(rhs.state_); 49 | } 50 | 51 | } // namespace marisa 52 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/lib/marisa/grimoire/algorithm.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_GRIMOIRE_ALGORITHM_H_ 2 | #define MARISA_GRIMOIRE_ALGORITHM_H_ 3 | 4 | #include "marisa/grimoire/algorithm/sort.h" 5 | 6 | namespace marisa { 7 | namespace grimoire { 8 | 9 | class Algorithm { 10 | public: 11 | Algorithm() {} 12 | 13 | template 14 | std::size_t sort(Iterator begin, Iterator end) const { 15 | return algorithm::sort(begin, end); 16 | } 17 | 18 | private: 19 | Algorithm(const Algorithm &); 20 | Algorithm &operator=(const Algorithm &); 21 | }; 22 | 23 | } // namespace grimoire 24 | } // namespace marisa 25 | 26 | #endif // MARISA_GRIMOIRE_ALGORITHM_H_ 27 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/lib/marisa/grimoire/io.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_GRIMOIRE_IO_H_ 2 | #define MARISA_GRIMOIRE_IO_H_ 3 | 4 | #include "marisa/grimoire/io/mapper.h" 5 | #include "marisa/grimoire/io/reader.h" 6 | #include "marisa/grimoire/io/writer.h" 7 | 8 | namespace marisa { 9 | namespace grimoire { 10 | 11 | using io::Mapper; 12 | using io::Reader; 13 | using io::Writer; 14 | 15 | } // namespace grimoire 16 | } // namespace marisa 17 | 18 | #endif // MARISA_GRIMOIRE_IO_H_ 19 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/lib/marisa/grimoire/io/reader.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_GRIMOIRE_IO_READER_H_ 2 | #define MARISA_GRIMOIRE_IO_READER_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include "marisa/base.h" 8 | 9 | namespace marisa { 10 | namespace grimoire { 11 | namespace io { 12 | 13 | class Reader { 14 | public: 15 | Reader(); 16 | ~Reader(); 17 | 18 | void open(const char *filename); 19 | void open(std::FILE *file); 20 | void open(int fd); 21 | void open(std::istream &stream); 22 | 23 | template 24 | void read(T *obj) { 25 | MARISA_THROW_IF(obj == NULL, MARISA_NULL_ERROR); 26 | read_data(obj, sizeof(T)); 27 | } 28 | 29 | template 30 | void read(T *objs, std::size_t num_objs) { 31 | MARISA_THROW_IF((objs == NULL) && (num_objs != 0), MARISA_NULL_ERROR); 32 | MARISA_THROW_IF(num_objs > (MARISA_SIZE_MAX / sizeof(T)), 33 | MARISA_SIZE_ERROR); 34 | read_data(objs, sizeof(T) * num_objs); 35 | } 36 | 37 | void seek(std::size_t size); 38 | 39 | bool is_open() const; 40 | 41 | void clear(); 42 | void swap(Reader &rhs); 43 | 44 | private: 45 | std::FILE *file_; 46 | int fd_; 47 | std::istream *stream_; 48 | bool needs_fclose_; 49 | 50 | void open_(const char *filename); 51 | void open_(std::FILE *file); 52 | void open_(int fd); 53 | void open_(std::istream &stream); 54 | 55 | void read_data(void *buf, std::size_t size); 56 | 57 | // Disallows copy and assignment. 58 | Reader(const Reader &); 59 | Reader &operator=(const Reader &); 60 | }; 61 | 62 | } // namespace io 63 | } // namespace grimoire 64 | } // namespace marisa 65 | 66 | #endif // MARISA_GRIMOIRE_IO_READER_H_ 67 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/lib/marisa/grimoire/io/writer.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_GRIMOIRE_IO_WRITER_H_ 2 | #define MARISA_GRIMOIRE_IO_WRITER_H_ 3 | 4 | #include 5 | #include 6 | 7 | #include "marisa/base.h" 8 | 9 | namespace marisa { 10 | namespace grimoire { 11 | namespace io { 12 | 13 | class Writer { 14 | public: 15 | Writer(); 16 | ~Writer(); 17 | 18 | void open(const char *filename); 19 | void open(std::FILE *file); 20 | void open(int fd); 21 | void open(std::ostream &stream); 22 | 23 | template 24 | void write(const T &obj) { 25 | write_data(&obj, sizeof(T)); 26 | } 27 | 28 | template 29 | void write(const T *objs, std::size_t num_objs) { 30 | MARISA_THROW_IF((objs == NULL) && (num_objs != 0), MARISA_NULL_ERROR); 31 | MARISA_THROW_IF(num_objs > (MARISA_SIZE_MAX / sizeof(T)), 32 | MARISA_SIZE_ERROR); 33 | write_data(objs, sizeof(T) * num_objs); 34 | } 35 | 36 | void seek(std::size_t size); 37 | 38 | bool is_open() const; 39 | 40 | void clear(); 41 | void swap(Writer &rhs); 42 | 43 | private: 44 | std::FILE *file_; 45 | int fd_; 46 | std::ostream *stream_; 47 | bool needs_fclose_; 48 | 49 | void open_(const char *filename); 50 | void open_(std::FILE *file); 51 | void open_(int fd); 52 | void open_(std::ostream &stream); 53 | 54 | void write_data(const void *data, std::size_t size); 55 | 56 | // Disallows copy and assignment. 57 | Writer(const Writer &); 58 | Writer &operator=(const Writer &); 59 | }; 60 | 61 | } // namespace io 62 | } // namespace grimoire 63 | } // namespace marisa 64 | 65 | #endif // MARISA_GRIMOIRE_IO_WRITER_H_ 66 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/lib/marisa/grimoire/trie.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_GRIMOIRE_TRIE_H_ 2 | #define MARISA_GRIMOIRE_TRIE_H_ 3 | 4 | #include "marisa/grimoire/trie/state.h" 5 | #include "marisa/grimoire/trie/louds-trie.h" 6 | 7 | namespace marisa { 8 | namespace grimoire { 9 | 10 | using trie::State; 11 | using trie::LoudsTrie; 12 | 13 | } // namespace grimoire 14 | } // namespace marisa 15 | 16 | #endif // MARISA_GRIMOIRE_TRIE_H_ 17 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/lib/marisa/grimoire/trie/header.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_GRIMOIRE_TRIE_HEADER_H_ 2 | #define MARISA_GRIMOIRE_TRIE_HEADER_H_ 3 | 4 | #include "marisa/grimoire/io.h" 5 | 6 | namespace marisa { 7 | namespace grimoire { 8 | namespace trie { 9 | 10 | class Header { 11 | public: 12 | enum { 13 | HEADER_SIZE = 16 14 | }; 15 | 16 | Header() {} 17 | 18 | void map(Mapper &mapper) { 19 | const char *ptr; 20 | mapper.map(&ptr, HEADER_SIZE); 21 | MARISA_THROW_IF(!test_header(ptr), MARISA_FORMAT_ERROR); 22 | } 23 | void read(Reader &reader) { 24 | char buf[HEADER_SIZE]; 25 | reader.read(buf, HEADER_SIZE); 26 | MARISA_THROW_IF(!test_header(buf), MARISA_FORMAT_ERROR); 27 | } 28 | void write(Writer &writer) const { 29 | writer.write(get_header(), HEADER_SIZE); 30 | } 31 | 32 | std::size_t io_size() const { 33 | return HEADER_SIZE; 34 | } 35 | 36 | private: 37 | 38 | static const char *get_header() { 39 | static const char buf[HEADER_SIZE] = "We love Marisa."; 40 | return buf; 41 | } 42 | 43 | static bool test_header(const char *ptr) { 44 | for (std::size_t i = 0; i < HEADER_SIZE; ++i) { 45 | if (ptr[i] != get_header()[i]) { 46 | return false; 47 | } 48 | } 49 | return true; 50 | } 51 | 52 | // Disallows copy and assignment. 53 | Header(const Header &); 54 | Header &operator=(const Header &); 55 | }; 56 | 57 | } // namespace trie 58 | } // namespace marisa 59 | } // namespace grimoire 60 | 61 | #endif // MARISA_GRIMOIRE_TRIE_HEADER_H_ 62 | -------------------------------------------------------------------------------- /deps/marisa-0.2.6/lib/marisa/grimoire/vector.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_GRIMOIRE_VECTOR_H_ 2 | #define MARISA_GRIMOIRE_VECTOR_H_ 3 | 4 | #include "marisa/grimoire/vector/vector.h" 5 | #include "marisa/grimoire/vector/flat-vector.h" 6 | #include "marisa/grimoire/vector/bit-vector.h" 7 | 8 | namespace marisa { 9 | namespace grimoire { 10 | 11 | using vector::Vector; 12 | typedef vector::FlatVector FlatVector; 13 | typedef vector::BitVector BitVector; 14 | 15 | } // namespace grimoire 16 | } // namespace marisa 17 | 18 | #endif // MARISA_GRIMOIRE_VECTOR_H_ 19 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/.gitignore: -------------------------------------------------------------------------------- 1 | CMakeCache.txt 2 | CMakeFiles 3 | Makefile 4 | cmake_install.cmake 5 | .DS_Store 6 | *.so 7 | *.pyd 8 | *.dll 9 | *.sln 10 | *.sdf 11 | *.opensdf 12 | *.vcxproj 13 | *.filters 14 | example.dir 15 | Win32 16 | x64 17 | Release 18 | Debug 19 | .vs 20 | CTestTestfile.cmake 21 | Testing 22 | autogen 23 | MANIFEST 24 | /.ninja_* 25 | /*.ninja 26 | /docs/.build 27 | *.py[co] 28 | *.egg-info 29 | *~ 30 | .*.swp 31 | .DS_Store 32 | /dist 33 | /build 34 | /cmake/ 35 | .cache/ 36 | sosize-*.txt 37 | pybind11Config*.cmake 38 | pybind11Targets.cmake 39 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/.gitmodules: -------------------------------------------------------------------------------- 1 | [submodule "tools/clang"] 2 | path = tools/clang 3 | url = ../../wjakob/clang-cindex-python3 4 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/.readthedocs.yml: -------------------------------------------------------------------------------- 1 | python: 2 | version: 3 3 | requirements_file: docs/requirements.txt 4 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/ISSUE_TEMPLATE.md: -------------------------------------------------------------------------------- 1 | Make sure you've completed the following steps before submitting your issue -- thank you! 2 | 3 | 1. Check if your question has already been answered in the [FAQ](http://pybind11.readthedocs.io/en/latest/faq.html) section. 4 | 2. Make sure you've read the [documentation](http://pybind11.readthedocs.io/en/latest/). Your issue may be addressed there. 5 | 3. If those resources didn't help and you only have a short question (not a bug report), consider asking in the [Gitter chat room](https://gitter.im/pybind/Lobby). 6 | 4. If you have a genuine bug report or a more complex question which is not answered in the previous items (or not suitable for chat), please fill in the details below. 7 | 5. Include a self-contained and minimal piece of code that reproduces the problem. If that's not possible, try to make the description as clear as possible. 8 | 9 | *After reading, remove this checklist and the template text in parentheses below.* 10 | 11 | ## Issue description 12 | 13 | (Provide a short description, state the expected behavior and what actually happens.) 14 | 15 | ## Reproducible example code 16 | 17 | (The code should be minimal, have no external dependencies, isolate the function(s) that cause breakage. Submit matched and complete C++ and Python snippets that can be easily compiled and run to diagnose the issue.) 18 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/MANIFEST.in: -------------------------------------------------------------------------------- 1 | recursive-include include/pybind11 *.h 2 | include LICENSE README.md CONTRIBUTING.md 3 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/docs/Doxyfile: -------------------------------------------------------------------------------- 1 | PROJECT_NAME = pybind11 2 | INPUT = ../include/pybind11/ 3 | RECURSIVE = YES 4 | 5 | GENERATE_HTML = NO 6 | GENERATE_LATEX = NO 7 | GENERATE_XML = YES 8 | XML_OUTPUT = .build/doxygenxml 9 | XML_PROGRAMLISTING = YES 10 | 11 | MACRO_EXPANSION = YES 12 | EXPAND_ONLY_PREDEF = YES 13 | EXPAND_AS_DEFINED = PYBIND11_RUNTIME_EXCEPTION 14 | 15 | ALIASES = "rst=\verbatim embed:rst" 16 | ALIASES += "endrst=\endverbatim" 17 | 18 | QUIET = YES 19 | WARNINGS = YES 20 | WARN_IF_UNDOCUMENTED = NO 21 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/docs/_static/theme_overrides.css: -------------------------------------------------------------------------------- 1 | .wy-table-responsive table td, 2 | .wy-table-responsive table th { 3 | white-space: initial !important; 4 | } 5 | .rst-content table.docutils td { 6 | vertical-align: top !important; 7 | } 8 | div[class^='highlight'] pre { 9 | white-space: pre; 10 | white-space: pre-wrap; 11 | } 12 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/docs/advanced/pycpp/index.rst: -------------------------------------------------------------------------------- 1 | Python C++ interface 2 | #################### 3 | 4 | pybind11 exposes Python types and functions using thin C++ wrappers, which 5 | makes it possible to conveniently call Python code from C++ without resorting 6 | to Python's C API. 7 | 8 | .. toctree:: 9 | :maxdepth: 2 10 | 11 | object 12 | numpy 13 | utilities 14 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/docs/index.rst: -------------------------------------------------------------------------------- 1 | .. only: not latex 2 | 3 | .. image:: pybind11-logo.png 4 | 5 | pybind11 --- Seamless operability between C++11 and Python 6 | ========================================================== 7 | 8 | .. only: not latex 9 | 10 | Contents: 11 | 12 | .. toctree:: 13 | :maxdepth: 1 14 | 15 | intro 16 | changelog 17 | upgrade 18 | 19 | .. toctree:: 20 | :caption: The Basics 21 | :maxdepth: 2 22 | 23 | basics 24 | classes 25 | compiling 26 | 27 | .. toctree:: 28 | :caption: Advanced Topics 29 | :maxdepth: 2 30 | 31 | advanced/functions 32 | advanced/classes 33 | advanced/exceptions 34 | advanced/smart_ptrs 35 | advanced/cast/index 36 | advanced/pycpp/index 37 | advanced/embedding 38 | advanced/misc 39 | 40 | .. toctree:: 41 | :caption: Extra Information 42 | :maxdepth: 1 43 | 44 | faq 45 | benchmark 46 | limitations 47 | reference 48 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/docs/limitations.rst: -------------------------------------------------------------------------------- 1 | Limitations 2 | ########### 3 | 4 | pybind11 strives to be a general solution to binding generation, but it also has 5 | certain limitations: 6 | 7 | - pybind11 casts away ``const``-ness in function arguments and return values. 8 | This is in line with the Python language, which has no concept of ``const`` 9 | values. This means that some additional care is needed to avoid bugs that 10 | would be caught by the type checker in a traditional C++ program. 11 | 12 | - The NumPy interface ``pybind11::array`` greatly simplifies accessing 13 | numerical data from C++ (and vice versa), but it's not a full-blown array 14 | class like ``Eigen::Array`` or ``boost.multi_array``. 15 | 16 | These features could be implemented but would lead to a significant increase in 17 | complexity. I've decided to draw the line here to keep this project simple and 18 | compact. Users who absolutely require these features are encouraged to fork 19 | pybind11. 20 | 21 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/docs/pybind11-logo.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/deps/pybind11-2.5.0/docs/pybind11-logo.png -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/docs/pybind11_vs_boost_python1.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/deps/pybind11-2.5.0/docs/pybind11_vs_boost_python1.png -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/docs/pybind11_vs_boost_python2.png: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/deps/pybind11-2.5.0/docs/pybind11_vs_boost_python2.png -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/docs/release.rst: -------------------------------------------------------------------------------- 1 | To release a new version of pybind11: 2 | 3 | - Update the version number and push to pypi 4 | - Update ``pybind11/_version.py`` (set release version, remove 'dev'). 5 | - Update ``PYBIND11_VERSION_MAJOR`` etc. in ``include/pybind11/detail/common.h``. 6 | - Ensure that all the information in ``setup.py`` is up-to-date. 7 | - Update version in ``docs/conf.py``. 8 | - Tag release date in ``docs/changelog.rst``. 9 | - ``git add`` and ``git commit``. 10 | - if new minor version: ``git checkout -b vX.Y``, ``git push -u origin vX.Y`` 11 | - ``git tag -a vX.Y.Z -m 'vX.Y.Z release'``. 12 | - ``git push`` 13 | - ``git push --tags``. 14 | - ``python setup.py sdist upload``. 15 | - ``python setup.py bdist_wheel upload``. 16 | - Get back to work 17 | - Update ``_version.py`` (add 'dev' and increment minor). 18 | - Update version in ``docs/conf.py`` 19 | - Update version macros in ``include/pybind11/common.h`` 20 | - ``git add`` and ``git commit``. 21 | ``git push`` 22 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/docs/requirements.txt: -------------------------------------------------------------------------------- 1 | breathe == 4.5.0 2 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/include/pybind11/common.h: -------------------------------------------------------------------------------- 1 | #include "detail/common.h" 2 | #warning "Including 'common.h' is deprecated. It will be removed in v3.0. Use 'pybind11.h'." 3 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/include/pybind11/detail/typeid.h: -------------------------------------------------------------------------------- 1 | /* 2 | pybind11/detail/typeid.h: Compiler-independent access to type identifiers 3 | 4 | Copyright (c) 2016 Wenzel Jakob 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #pragma once 11 | 12 | #include 13 | #include 14 | 15 | #if defined(__GNUG__) 16 | #include 17 | #endif 18 | 19 | #include "common.h" 20 | 21 | NAMESPACE_BEGIN(PYBIND11_NAMESPACE) 22 | NAMESPACE_BEGIN(detail) 23 | /// Erase all occurrences of a substring 24 | inline void erase_all(std::string &string, const std::string &search) { 25 | for (size_t pos = 0;;) { 26 | pos = string.find(search, pos); 27 | if (pos == std::string::npos) break; 28 | string.erase(pos, search.length()); 29 | } 30 | } 31 | 32 | PYBIND11_NOINLINE inline void clean_type_id(std::string &name) { 33 | #if defined(__GNUG__) 34 | int status = 0; 35 | std::unique_ptr res { 36 | abi::__cxa_demangle(name.c_str(), nullptr, nullptr, &status), std::free }; 37 | if (status == 0) 38 | name = res.get(); 39 | #else 40 | detail::erase_all(name, "class "); 41 | detail::erase_all(name, "struct "); 42 | detail::erase_all(name, "enum "); 43 | #endif 44 | detail::erase_all(name, "pybind11::"); 45 | } 46 | NAMESPACE_END(detail) 47 | 48 | /// Return a string representation of a C++ type 49 | template static std::string type_id() { 50 | std::string name(typeid(T).name()); 51 | detail::clean_type_id(name); 52 | return name; 53 | } 54 | 55 | NAMESPACE_END(PYBIND11_NAMESPACE) 56 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/pybind11/__init__.py: -------------------------------------------------------------------------------- 1 | from ._version import version_info, __version__ # noqa: F401 imported but unused 2 | 3 | 4 | def get_include(user=False): 5 | import os 6 | d = os.path.dirname(__file__) 7 | if os.path.exists(os.path.join(d, "include")): 8 | # Package is installed 9 | return os.path.join(d, "include") 10 | else: 11 | # Package is from a source directory 12 | return os.path.join(os.path.dirname(d), "include") 13 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/pybind11/__main__.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function 2 | 3 | import argparse 4 | import sys 5 | import sysconfig 6 | 7 | from . import get_include 8 | 9 | 10 | def print_includes(): 11 | dirs = [sysconfig.get_path('include'), 12 | sysconfig.get_path('platinclude'), 13 | get_include()] 14 | 15 | # Make unique but preserve order 16 | unique_dirs = [] 17 | for d in dirs: 18 | if d not in unique_dirs: 19 | unique_dirs.append(d) 20 | 21 | print(' '.join('-I' + d for d in unique_dirs)) 22 | 23 | 24 | def main(): 25 | parser = argparse.ArgumentParser(prog='python -m pybind11') 26 | parser.add_argument('--includes', action='store_true', 27 | help='Include flags for both pybind11 and Python headers.') 28 | args = parser.parse_args() 29 | if not sys.argv[1:]: 30 | parser.print_help() 31 | if args.includes: 32 | print_includes() 33 | 34 | 35 | if __name__ == '__main__': 36 | main() 37 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/pybind11/_version.py: -------------------------------------------------------------------------------- 1 | version_info = (2, 5, 0) 2 | __version__ = '.'.join(map(str, version_info)) 3 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/setup.cfg: -------------------------------------------------------------------------------- 1 | [bdist_wheel] 2 | universal=1 3 | 4 | [flake8] 5 | max-line-length = 99 6 | show_source = True 7 | exclude = .git, __pycache__, build, dist, docs, tools, venv 8 | ignore = 9 | # required for pretty matrix formatting: multiple spaces after `,` and `[` 10 | E201, E241, W504, 11 | # camelcase 'cPickle' imported as lowercase 'pickle' 12 | N813 13 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/pytest.ini: -------------------------------------------------------------------------------- 1 | [pytest] 2 | minversion = 3.0 3 | norecursedirs = test_cmake_build test_embed 4 | addopts = 5 | # show summary of skipped tests 6 | -rs 7 | # capture only Python print and C++ py::print, but not C output (low-level Python errors) 8 | --capture=sys 9 | filterwarnings = 10 | # make warnings into errors but ignore certain third-party extension issues 11 | error 12 | # importing scipy submodules on some version of Python 13 | ignore::ImportWarning 14 | # bogus numpy ABI warning (see numpy/#432) 15 | ignore:.*numpy.dtype size changed.*:RuntimeWarning 16 | ignore:.*numpy.ufunc size changed.*:RuntimeWarning 17 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_async.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_async.cpp -- __await__ support 3 | 4 | Copyright (c) 2019 Google Inc. 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #include "pybind11_tests.h" 11 | 12 | TEST_SUBMODULE(async_module, m) { 13 | struct DoesNotSupportAsync {}; 14 | py::class_(m, "DoesNotSupportAsync") 15 | .def(py::init<>()); 16 | struct SupportsAsync {}; 17 | py::class_(m, "SupportsAsync") 18 | .def(py::init<>()) 19 | .def("__await__", [](const SupportsAsync& self) -> py::object { 20 | static_cast(self); 21 | py::object loop = py::module::import("asyncio.events").attr("get_event_loop")(); 22 | py::object f = loop.attr("create_future")(); 23 | f.attr("set_result")(5); 24 | return f.attr("__await__")(); 25 | }); 26 | } 27 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_async.py: -------------------------------------------------------------------------------- 1 | import asyncio 2 | import pytest 3 | from pybind11_tests import async_module as m 4 | 5 | 6 | @pytest.fixture 7 | def event_loop(): 8 | loop = asyncio.new_event_loop() 9 | yield loop 10 | loop.close() 11 | 12 | 13 | async def get_await_result(x): 14 | return await x 15 | 16 | 17 | def test_await(event_loop): 18 | assert 5 == event_loop.run_until_complete(get_await_result(m.SupportsAsync())) 19 | 20 | 21 | def test_await_missing(event_loop): 22 | with pytest.raises(TypeError): 23 | event_loop.run_until_complete(get_await_result(m.DoesNotSupportAsync())) 24 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_cmake_build/embed.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | namespace py = pybind11; 3 | 4 | PYBIND11_EMBEDDED_MODULE(test_cmake_build, m) { 5 | m.def("add", [](int i, int j) { return i + j; }); 6 | } 7 | 8 | int main(int argc, char *argv[]) { 9 | if (argc != 2) 10 | throw std::runtime_error("Expected test.py file as the first argument"); 11 | auto test_py_file = argv[1]; 12 | 13 | py::scoped_interpreter guard{}; 14 | 15 | auto m = py::module::import("test_cmake_build"); 16 | if (m.attr("add")(1, 2).cast() != 3) 17 | throw std::runtime_error("embed.cpp failed"); 18 | 19 | py::module::import("sys").attr("argv") = py::make_tuple("test.py", "embed.cpp"); 20 | py::eval_file(test_py_file, py::globals()); 21 | } 22 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_cmake_build/installed_embed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(test_installed_embed CXX) 3 | 4 | set(CMAKE_MODULE_PATH "") 5 | find_package(pybind11 CONFIG REQUIRED) 6 | message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}") 7 | 8 | add_executable(test_cmake_build ../embed.cpp) 9 | target_link_libraries(test_cmake_build PRIVATE pybind11::embed) 10 | 11 | # Do not treat includes from IMPORTED target as SYSTEM (Python headers in pybind11::embed). 12 | # This may be needed to resolve header conflicts, e.g. between Python release and debug headers. 13 | set_target_properties(test_cmake_build PROPERTIES NO_SYSTEM_FROM_IMPORTED ON) 14 | 15 | add_custom_target(check $ ${PROJECT_SOURCE_DIR}/../test.py) 16 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_cmake_build/installed_function/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | project(test_installed_module CXX) 3 | 4 | set(CMAKE_MODULE_PATH "") 5 | 6 | find_package(pybind11 CONFIG REQUIRED) 7 | message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}") 8 | 9 | pybind11_add_module(test_cmake_build SHARED NO_EXTRAS ../main.cpp) 10 | 11 | add_custom_target(check ${CMAKE_COMMAND} -E env PYTHONPATH=$ 12 | ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../test.py ${PROJECT_NAME}) 13 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_cmake_build/installed_target/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(test_installed_target CXX) 3 | 4 | set(CMAKE_MODULE_PATH "") 5 | 6 | find_package(pybind11 CONFIG REQUIRED) 7 | message(STATUS "Found pybind11 v${pybind11_VERSION}: ${pybind11_INCLUDE_DIRS}") 8 | 9 | add_library(test_cmake_build MODULE ../main.cpp) 10 | 11 | target_link_libraries(test_cmake_build PRIVATE pybind11::module) 12 | 13 | # make sure result is, for example, test_installed_target.so, not libtest_installed_target.dylib 14 | set_target_properties(test_cmake_build PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}" 15 | SUFFIX "${PYTHON_MODULE_EXTENSION}") 16 | 17 | # Do not treat includes from IMPORTED target as SYSTEM (Python headers in pybind11::module). 18 | # This may be needed to resolve header conflicts, e.g. between Python release and debug headers. 19 | set_target_properties(test_cmake_build PROPERTIES NO_SYSTEM_FROM_IMPORTED ON) 20 | 21 | add_custom_target(check ${CMAKE_COMMAND} -E env PYTHONPATH=$ 22 | ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../test.py ${PROJECT_NAME}) 23 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_cmake_build/main.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | namespace py = pybind11; 3 | 4 | PYBIND11_MODULE(test_cmake_build, m) { 5 | m.def("add", [](int i, int j) { return i + j; }); 6 | } 7 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_cmake_build/subdirectory_embed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(test_subdirectory_embed CXX) 3 | 4 | set(PYBIND11_INSTALL ON CACHE BOOL "") 5 | set(PYBIND11_EXPORT_NAME test_export) 6 | 7 | add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11) 8 | 9 | # Test basic target functionality 10 | add_executable(test_cmake_build ../embed.cpp) 11 | target_link_libraries(test_cmake_build PRIVATE pybind11::embed) 12 | 13 | add_custom_target(check $ ${PROJECT_SOURCE_DIR}/../test.py) 14 | 15 | # Test custom export group -- PYBIND11_EXPORT_NAME 16 | add_library(test_embed_lib ../embed.cpp) 17 | target_link_libraries(test_embed_lib PRIVATE pybind11::embed) 18 | 19 | install(TARGETS test_embed_lib 20 | EXPORT test_export 21 | ARCHIVE DESTINATION bin 22 | LIBRARY DESTINATION lib 23 | RUNTIME DESTINATION lib) 24 | install(EXPORT test_export 25 | DESTINATION lib/cmake/test_export/test_export-Targets.cmake) 26 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_cmake_build/subdirectory_function/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 2.8.12) 2 | project(test_subdirectory_module CXX) 3 | 4 | add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11) 5 | pybind11_add_module(test_cmake_build THIN_LTO ../main.cpp) 6 | 7 | add_custom_target(check ${CMAKE_COMMAND} -E env PYTHONPATH=$ 8 | ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../test.py ${PROJECT_NAME}) 9 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_cmake_build/subdirectory_target/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | cmake_minimum_required(VERSION 3.0) 2 | project(test_subdirectory_target CXX) 3 | 4 | add_subdirectory(${PYBIND11_PROJECT_DIR} pybind11) 5 | 6 | add_library(test_cmake_build MODULE ../main.cpp) 7 | 8 | target_link_libraries(test_cmake_build PRIVATE pybind11::module) 9 | 10 | # make sure result is, for example, test_installed_target.so, not libtest_installed_target.dylib 11 | set_target_properties(test_cmake_build PROPERTIES PREFIX "${PYTHON_MODULE_PREFIX}" 12 | SUFFIX "${PYTHON_MODULE_EXTENSION}") 13 | 14 | add_custom_target(check ${CMAKE_COMMAND} -E env PYTHONPATH=$ 15 | ${PYTHON_EXECUTABLE} ${PROJECT_SOURCE_DIR}/../test.py ${PROJECT_NAME}) 16 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_cmake_build/test.py: -------------------------------------------------------------------------------- 1 | import sys 2 | import test_cmake_build 3 | 4 | assert test_cmake_build.add(1, 2) == 3 5 | print("{} imports, runs, and adds: 1 + 2 = 3".format(sys.argv[1])) 6 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_constants_and_functions.py: -------------------------------------------------------------------------------- 1 | from pybind11_tests import constants_and_functions as m 2 | 3 | 4 | def test_constants(): 5 | assert m.some_constant == 14 6 | 7 | 8 | def test_function_overloading(): 9 | assert m.test_function() == "test_function()" 10 | assert m.test_function(7) == "test_function(7)" 11 | assert m.test_function(m.MyEnum.EFirstEntry) == "test_function(enum=1)" 12 | assert m.test_function(m.MyEnum.ESecondEntry) == "test_function(enum=2)" 13 | 14 | assert m.test_function() == "test_function()" 15 | assert m.test_function("abcd") == "test_function(char *)" 16 | assert m.test_function(1, 1.0) == "test_function(int, float)" 17 | assert m.test_function(1, 1.0) == "test_function(int, float)" 18 | assert m.test_function(2.0, 2) == "test_function(float, int)" 19 | 20 | 21 | def test_bytes(): 22 | assert m.print_bytes(m.return_bytes()) == "bytes[1 0 2 0]" 23 | 24 | 25 | def test_exception_specifiers(): 26 | c = m.C() 27 | assert c.m1(2) == 1 28 | assert c.m2(3) == 1 29 | assert c.m3(5) == 2 30 | assert c.m4(7) == 3 31 | assert c.m5(10) == 5 32 | assert c.m6(14) == 8 33 | assert c.m7(20) == 13 34 | assert c.m8(29) == 21 35 | 36 | assert m.f1(33) == 34 37 | assert m.f2(53) == 55 38 | assert m.f3(86) == 89 39 | assert m.f4(140) == 144 40 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_docstring_options.py: -------------------------------------------------------------------------------- 1 | from pybind11_tests import docstring_options as m 2 | 3 | 4 | def test_docstring_options(): 5 | # options.disable_function_signatures() 6 | assert not m.test_function1.__doc__ 7 | 8 | assert m.test_function2.__doc__ == "A custom docstring" 9 | 10 | # docstring specified on just the first overload definition: 11 | assert m.test_overloaded1.__doc__ == "Overload docstring" 12 | 13 | # docstring on both overloads: 14 | assert m.test_overloaded2.__doc__ == "overload docstring 1\noverload docstring 2" 15 | 16 | # docstring on only second overload: 17 | assert m.test_overloaded3.__doc__ == "Overload docstr" 18 | 19 | # options.enable_function_signatures() 20 | assert m.test_function3.__doc__ .startswith("test_function3(a: int, b: int) -> None") 21 | 22 | assert m.test_function4.__doc__ .startswith("test_function4(a: int, b: int) -> None") 23 | assert m.test_function4.__doc__ .endswith("A custom docstring\n") 24 | 25 | # options.disable_function_signatures() 26 | # options.disable_user_defined_docstrings() 27 | assert not m.test_function5.__doc__ 28 | 29 | # nested options.enable_user_defined_docstrings() 30 | assert m.test_function6.__doc__ == "A custom docstring" 31 | 32 | # RAII destructor 33 | assert m.test_function7.__doc__ .startswith("test_function7(a: int, b: int) -> None") 34 | assert m.test_function7.__doc__ .endswith("A custom docstring\n") 35 | 36 | # Suppression of user-defined docstrings for non-function objects 37 | assert not m.DocstringTestFoo.__doc__ 38 | assert not m.DocstringTestFoo.value_prop.__doc__ 39 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_embed/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(${PYTHON_MODULE_EXTENSION} MATCHES "pypy") 2 | add_custom_target(cpptest) # Dummy target on PyPy. Embedding is not supported. 3 | set(_suppress_unused_variable_warning "${DOWNLOAD_CATCH}") 4 | return() 5 | endif() 6 | 7 | find_package(Catch 1.9.3) 8 | if(CATCH_FOUND) 9 | message(STATUS "Building interpreter tests using Catch v${CATCH_VERSION}") 10 | else() 11 | message(STATUS "Catch not detected. Interpreter tests will be skipped. Install Catch headers" 12 | " manually or use `cmake -DDOWNLOAD_CATCH=1` to fetch them automatically.") 13 | return() 14 | endif() 15 | 16 | add_executable(test_embed 17 | catch.cpp 18 | test_interpreter.cpp 19 | ) 20 | target_include_directories(test_embed PRIVATE ${CATCH_INCLUDE_DIR}) 21 | pybind11_enable_warnings(test_embed) 22 | 23 | if(NOT CMAKE_VERSION VERSION_LESS 3.0) 24 | target_link_libraries(test_embed PRIVATE pybind11::embed) 25 | else() 26 | target_include_directories(test_embed PRIVATE ${PYBIND11_INCLUDE_DIR} ${PYTHON_INCLUDE_DIRS}) 27 | target_compile_options(test_embed PRIVATE ${PYBIND11_CPP_STANDARD}) 28 | target_link_libraries(test_embed PRIVATE ${PYTHON_LIBRARIES}) 29 | endif() 30 | 31 | find_package(Threads REQUIRED) 32 | target_link_libraries(test_embed PUBLIC ${CMAKE_THREAD_LIBS_INIT}) 33 | 34 | add_custom_target(cpptest COMMAND $ 35 | WORKING_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 36 | 37 | pybind11_add_module(external_module THIN_LTO external_module.cpp) 38 | set_target_properties(external_module PROPERTIES LIBRARY_OUTPUT_DIRECTORY ${CMAKE_CURRENT_SOURCE_DIR}) 39 | add_dependencies(cpptest external_module) 40 | 41 | add_dependencies(check cpptest) 42 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_embed/catch.cpp: -------------------------------------------------------------------------------- 1 | // The Catch implementation is compiled here. This is a standalone 2 | // translation unit to avoid recompiling it for every test change. 3 | 4 | #include 5 | 6 | #ifdef _MSC_VER 7 | // Silence MSVC C++17 deprecation warning from Catch regarding std::uncaught_exceptions (up to catch 8 | // 2.0.1; this should be fixed in the next catch release after 2.0.1). 9 | # pragma warning(disable: 4996) 10 | #endif 11 | 12 | #define CATCH_CONFIG_RUNNER 13 | #include 14 | 15 | namespace py = pybind11; 16 | 17 | int main(int argc, char *argv[]) { 18 | py::scoped_interpreter guard{}; 19 | auto result = Catch::Session().run(argc, argv); 20 | 21 | return result < 0xff ? result : 0xff; 22 | } 23 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_embed/external_module.cpp: -------------------------------------------------------------------------------- 1 | #include 2 | 3 | namespace py = pybind11; 4 | 5 | /* Simple test module/test class to check that the referenced internals data of external pybind11 6 | * modules aren't preserved over a finalize/initialize. 7 | */ 8 | 9 | PYBIND11_MODULE(external_module, m) { 10 | class A { 11 | public: 12 | A(int value) : v{value} {}; 13 | int v; 14 | }; 15 | 16 | py::class_(m, "A") 17 | .def(py::init()) 18 | .def_readwrite("value", &A::v); 19 | 20 | m.def("internals_at", []() { 21 | return reinterpret_cast(&py::detail::get_internals()); 22 | }); 23 | } 24 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_embed/test_interpreter.py: -------------------------------------------------------------------------------- 1 | from widget_module import Widget 2 | 3 | 4 | class DerivedWidget(Widget): 5 | def __init__(self, message): 6 | super(DerivedWidget, self).__init__(message) 7 | 8 | def the_answer(self): 9 | return 42 10 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_eval.py: -------------------------------------------------------------------------------- 1 | import os 2 | from pybind11_tests import eval_ as m 3 | 4 | 5 | def test_evals(capture): 6 | with capture: 7 | assert m.test_eval_statements() 8 | assert capture == "Hello World!" 9 | 10 | assert m.test_eval() 11 | assert m.test_eval_single_statement() 12 | 13 | filename = os.path.join(os.path.dirname(__file__), "test_eval_call.py") 14 | assert m.test_eval_file(filename) 15 | 16 | assert m.test_eval_failure() 17 | assert m.test_eval_file_failure() 18 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_eval_call.py: -------------------------------------------------------------------------------- 1 | # This file is called from 'test_eval.py' 2 | 3 | if 'call_test2' in locals(): 4 | call_test2(y) # noqa: F821 undefined name 5 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_pickling.py: -------------------------------------------------------------------------------- 1 | import pytest 2 | from pybind11_tests import pickling as m 3 | 4 | try: 5 | import cPickle as pickle # Use cPickle on Python 2.7 6 | except ImportError: 7 | import pickle 8 | 9 | 10 | @pytest.mark.parametrize("cls_name", ["Pickleable", "PickleableNew"]) 11 | def test_roundtrip(cls_name): 12 | cls = getattr(m, cls_name) 13 | p = cls("test_value") 14 | p.setExtra1(15) 15 | p.setExtra2(48) 16 | 17 | data = pickle.dumps(p, 2) # Must use pickle protocol >= 2 18 | p2 = pickle.loads(data) 19 | assert p2.value() == p.value() 20 | assert p2.extra1() == p.extra1() 21 | assert p2.extra2() == p.extra2() 22 | 23 | 24 | @pytest.unsupported_on_pypy 25 | @pytest.mark.parametrize("cls_name", ["PickleableWithDict", "PickleableWithDictNew"]) 26 | def test_roundtrip_with_dict(cls_name): 27 | cls = getattr(m, cls_name) 28 | p = cls("test_value") 29 | p.extra = 15 30 | p.dynamic = "Attribute" 31 | 32 | data = pickle.dumps(p, pickle.HIGHEST_PROTOCOL) 33 | p2 = pickle.loads(data) 34 | assert p2.value == p.value 35 | assert p2.extra == p.extra 36 | assert p2.dynamic == p.dynamic 37 | 38 | 39 | def test_enum_pickle(): 40 | from pybind11_tests import enums as e 41 | data = pickle.dumps(e.EOne, 2) 42 | assert e.EOne == pickle.loads(data) 43 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_tagbased_polymorphic.py: -------------------------------------------------------------------------------- 1 | from pybind11_tests import tagbased_polymorphic as m 2 | 3 | 4 | def test_downcast(): 5 | zoo = m.create_zoo() 6 | assert [type(animal) for animal in zoo] == [ 7 | m.Labrador, m.Dog, m.Chihuahua, m.Cat, m.Panther 8 | ] 9 | assert [animal.name for animal in zoo] == [ 10 | "Fido", "Ginger", "Hertzl", "Tiger", "Leo" 11 | ] 12 | zoo[1].sound = "woooooo" 13 | assert [dog.bark() for dog in zoo[:3]] == [ 14 | "Labrador Fido goes WOOF!", 15 | "Dog Ginger goes woooooo", 16 | "Chihuahua Hertzl goes iyiyiyiyiyi and runs in circles" 17 | ] 18 | assert [cat.purr() for cat in zoo[3:]] == ["mrowr", "mrrrRRRRRR"] 19 | zoo[0].excitement -= 1000 20 | assert zoo[0].excitement == 14000 21 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_union.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | tests/test_class.cpp -- test py::class_ definitions and basic functionality 3 | 4 | Copyright (c) 2019 Roland Dreier 5 | 6 | All rights reserved. Use of this source code is governed by a 7 | BSD-style license that can be found in the LICENSE file. 8 | */ 9 | 10 | #include "pybind11_tests.h" 11 | 12 | TEST_SUBMODULE(union_, m) { 13 | union TestUnion { 14 | int value_int; 15 | unsigned value_uint; 16 | }; 17 | 18 | py::class_(m, "TestUnion") 19 | .def(py::init<>()) 20 | .def_readonly("as_int", &TestUnion::value_int) 21 | .def_readwrite("as_uint", &TestUnion::value_uint); 22 | } 23 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tests/test_union.py: -------------------------------------------------------------------------------- 1 | from pybind11_tests import union_ as m 2 | 3 | 4 | def test_union(): 5 | instance = m.TestUnion() 6 | 7 | instance.as_uint = 10 8 | assert instance.as_int == 10 9 | -------------------------------------------------------------------------------- /deps/pybind11-2.5.0/tools/libsize.py: -------------------------------------------------------------------------------- 1 | from __future__ import print_function, division 2 | import os 3 | import sys 4 | 5 | # Internal build script for generating debugging test .so size. 6 | # Usage: 7 | # python libsize.py file.so save.txt -- displays the size of file.so and, if save.txt exists, compares it to the 8 | # size in it, then overwrites save.txt with the new size for future runs. 9 | 10 | if len(sys.argv) != 3: 11 | sys.exit("Invalid arguments: usage: python libsize.py file.so save.txt") 12 | 13 | lib = sys.argv[1] 14 | save = sys.argv[2] 15 | 16 | if not os.path.exists(lib): 17 | sys.exit("Error: requested file ({}) does not exist".format(lib)) 18 | 19 | libsize = os.path.getsize(lib) 20 | 21 | print("------", os.path.basename(lib), "file size:", libsize, end='') 22 | 23 | if os.path.exists(save): 24 | with open(save) as sf: 25 | oldsize = int(sf.readline()) 26 | 27 | if oldsize > 0: 28 | change = libsize - oldsize 29 | if change == 0: 30 | print(" (no change)") 31 | else: 32 | print(" (change of {:+} bytes = {:+.2%})".format(change, change / oldsize)) 33 | else: 34 | print() 35 | 36 | with open(save, 'w') as sf: 37 | sf.write(str(libsize)) 38 | 39 | -------------------------------------------------------------------------------- /deps/rapidjson-1.1.0/rapidjson/internal/swap.h: -------------------------------------------------------------------------------- 1 | // Tencent is pleased to support the open source community by making RapidJSON available. 2 | // 3 | // Copyright (C) 2015 THL A29 Limited, a Tencent company, and Milo Yip. All rights reserved. 4 | // 5 | // Licensed under the MIT License (the "License"); you may not use this file except 6 | // in compliance with the License. You may obtain a copy of the License at 7 | // 8 | // http://opensource.org/licenses/MIT 9 | // 10 | // Unless required by applicable law or agreed to in writing, software distributed 11 | // under the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 12 | // CONDITIONS OF ANY KIND, either express or implied. See the License for the 13 | // specific language governing permissions and limitations under the License. 14 | 15 | #ifndef RAPIDJSON_INTERNAL_SWAP_H_ 16 | #define RAPIDJSON_INTERNAL_SWAP_H_ 17 | 18 | #include "../rapidjson.h" 19 | 20 | #if defined(__clang__) 21 | RAPIDJSON_DIAG_PUSH 22 | RAPIDJSON_DIAG_OFF(c++98-compat) 23 | #endif 24 | 25 | RAPIDJSON_NAMESPACE_BEGIN 26 | namespace internal { 27 | 28 | //! Custom swap() to avoid dependency on C++ header 29 | /*! \tparam T Type of the arguments to swap, should be instantiated with primitive C++ types only. 30 | \note This has the same semantics as std::swap(). 31 | */ 32 | template 33 | inline void Swap(T& a, T& b) RAPIDJSON_NOEXCEPT { 34 | T tmp = a; 35 | a = b; 36 | b = tmp; 37 | } 38 | 39 | } // namespace internal 40 | RAPIDJSON_NAMESPACE_END 41 | 42 | #if defined(__clang__) 43 | RAPIDJSON_DIAG_POP 44 | #endif 45 | 46 | #endif // RAPIDJSON_INTERNAL_SWAP_H_ 47 | -------------------------------------------------------------------------------- /deps/tclap-1.2.2/tclap/IgnoreRestVisitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: IgnoreRestVisitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reserved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_IGNORE_REST_VISITOR_H 24 | #define TCLAP_IGNORE_REST_VISITOR_H 25 | 26 | #include 27 | #include 28 | 29 | namespace TCLAP { 30 | 31 | /** 32 | * A Visitor that tells the CmdLine to begin ignoring arguments after 33 | * this one is parsed. 34 | */ 35 | class IgnoreRestVisitor: public Visitor 36 | { 37 | public: 38 | 39 | /** 40 | * Constructor. 41 | */ 42 | IgnoreRestVisitor() : Visitor() {} 43 | 44 | /** 45 | * Sets Arg::_ignoreRest. 46 | */ 47 | void visit() { Arg::beginIgnoring(); } 48 | }; 49 | 50 | } 51 | 52 | #endif 53 | -------------------------------------------------------------------------------- /deps/tclap-1.2.2/tclap/Visitor.h: -------------------------------------------------------------------------------- 1 | 2 | /****************************************************************************** 3 | * 4 | * file: Visitor.h 5 | * 6 | * Copyright (c) 2003, Michael E. Smoot . 7 | * All rights reserved. 8 | * 9 | * See the file COPYING in the top directory of this distribution for 10 | * more information. 11 | * 12 | * THE SOFTWARE IS PROVIDED _AS IS_, WITHOUT WARRANTY OF ANY KIND, EXPRESS 13 | * OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 14 | * FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL 15 | * THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 16 | * LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 17 | * FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER 18 | * DEALINGS IN THE SOFTWARE. 19 | * 20 | *****************************************************************************/ 21 | 22 | 23 | #ifndef TCLAP_VISITOR_H 24 | #define TCLAP_VISITOR_H 25 | 26 | namespace TCLAP { 27 | 28 | /** 29 | * A base class that defines the interface for visitors. 30 | */ 31 | class Visitor 32 | { 33 | public: 34 | 35 | /** 36 | * Constructor. Does nothing. 37 | */ 38 | Visitor() { } 39 | 40 | /** 41 | * Destructor. Does nothing. 42 | */ 43 | virtual ~Visitor() { } 44 | 45 | /** 46 | * Does nothing. Should be overridden by child. 47 | */ 48 | virtual void visit() { } 49 | }; 50 | 51 | } 52 | 53 | #endif 54 | -------------------------------------------------------------------------------- /doc/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | if(BUILD_DOCUMENTATION) 2 | find_package(Doxygen) 3 | if (NOT DOXYGEN_FOUND) 4 | message( 5 | FATAL_ERROR 6 | "Doxygen is needed to build the documentation. Please install it correctly" 7 | ) 8 | endif() 9 | 10 | configure_file( 11 | opencc.doxy.in 12 | opencc.doxy 13 | @ONLY 14 | IMMEDIATE 15 | ) 16 | 17 | add_custom_target( 18 | apidoc 19 | ALL 20 | COMMENT 21 | "Building API Documentation" 22 | COMMAND 23 | doxygen ${PROJECT_BINARY_DIR}/doc/opencc.doxy 24 | SOURCES 25 | ${PROJECT_BINARY_DIR}/doc/opencc.doxy 26 | ) 27 | 28 | install( 29 | DIRECTORY 30 | ${CMAKE_BINARY_DIR}/doc/html 31 | DESTINATION 32 | ${DIR_SHARE_OPENCC}/doc 33 | ) 34 | 35 | set_directory_properties( 36 | PROPERTIES 37 | ADDITIONAL_MAKE_CLEAN_FILES 38 | "${CMAKE_BINARY_DIR}/doc/html" 39 | ) 40 | endif() 41 | -------------------------------------------------------------------------------- /doc/README.md: -------------------------------------------------------------------------------- 1 | # Document 2 | 3 | http://byvoid.github.io/OpenCC/ 4 | -------------------------------------------------------------------------------- /iOS/config/hk2s.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese (Hong Kong variant) to Simplified Chinese", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "TSPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "HKVariantsRevPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "HKVariantsRev.ocd2" 19 | }] 20 | } 21 | }, { 22 | "dict": { 23 | "type": "group", 24 | "dicts": [{ 25 | "type": "ocd2", 26 | "file": "TSPhrases.ocd2" 27 | }, { 28 | "type": "ocd2", 29 | "file": "TSCharacters.ocd2" 30 | }] 31 | } 32 | }] 33 | } 34 | -------------------------------------------------------------------------------- /iOS/config/hk2t.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese (Hong Kong variant) to Traditional Chinese", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "HKVariantsRevPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "HKVariantsRevPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "HKVariantsRev.ocd2" 19 | }] 20 | } 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /iOS/config/jp2t.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "New Japanese Kanji (Shinjitai) to Traditional Chinese Characters (Kyūjitai)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "JPShinjitaiPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "JPShinjitaiPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "JPShinjitaiCharacters.ocd2" 19 | }, { 20 | "type": "ocd2", 21 | "file": "JPVariantsRev.ocd2" 22 | }] 23 | } 24 | }] 25 | } 26 | -------------------------------------------------------------------------------- /iOS/config/s2hk.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Simplified Chinese to Traditional Chinese (Hong Kong variant)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "STPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "STPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "STCharacters.ocd2" 19 | }] 20 | } 21 | }, { 22 | "dict": { 23 | "type": "ocd2", 24 | "file": "HKVariants.ocd2" 25 | } 26 | }] 27 | } 28 | -------------------------------------------------------------------------------- /iOS/config/s2t.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Simplified Chinese to Traditional Chinese", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "STPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "STPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "STCharacters.ocd2" 19 | }] 20 | } 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /iOS/config/s2tw.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Simplified Chinese to Traditional Chinese (Taiwan standard)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "STPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "STPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "STCharacters.ocd2" 19 | }] 20 | } 21 | }, { 22 | "dict": { 23 | "type": "ocd2", 24 | "file": "TWVariants.ocd2" 25 | } 26 | }] 27 | } 28 | -------------------------------------------------------------------------------- /iOS/config/s2twp.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Simplified Chinese to Traditional Chinese (Taiwan standard, with phrases)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "STPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "STPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "STCharacters.ocd2" 19 | }] 20 | } 21 | }, { 22 | "dict": { 23 | "type": "ocd2", 24 | "file": "TWPhrases.ocd2" 25 | } 26 | }, { 27 | "dict": { 28 | "type": "ocd2", 29 | "file": "TWVariants.ocd2" 30 | } 31 | }] 32 | } 33 | -------------------------------------------------------------------------------- /iOS/config/t2hk.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese to Traditional Chinese (Hong Kong variant)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "HKVariants.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "ocd2", 13 | "file": "HKVariants.ocd2" 14 | } 15 | }] 16 | } 17 | -------------------------------------------------------------------------------- /iOS/config/t2jp.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese Characters (Kyūjitai) to New Japanese Kanji (Shinjitai)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "JPVariants.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "ocd2", 13 | "file": "JPVariants.ocd2" 14 | } 15 | }] 16 | } 17 | -------------------------------------------------------------------------------- /iOS/config/t2s.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese to Simplified Chinese", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "TSPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "TSPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "TSCharacters.ocd2" 19 | }] 20 | } 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /iOS/config/t2tw.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese to Traditional Chinese (Taiwan standard)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "TWVariants.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "ocd2", 13 | "file": "TWVariants.ocd2" 14 | } 15 | }] 16 | } 17 | -------------------------------------------------------------------------------- /iOS/config/tw2s.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese (Taiwan standard) to Simplified Chinese", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "TSPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "TWVariantsRevPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "TWVariantsRev.ocd2" 19 | }] 20 | } 21 | }, { 22 | "dict": { 23 | "type": "group", 24 | "dicts": [{ 25 | "type": "ocd2", 26 | "file": "TSPhrases.ocd2" 27 | }, { 28 | "type": "ocd2", 29 | "file": "TSCharacters.ocd2" 30 | }] 31 | } 32 | }] 33 | } 34 | -------------------------------------------------------------------------------- /iOS/config/tw2sp.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese (Taiwan standard) to Simplified Chinese (with phrases)", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "TSPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "TWPhrasesRev.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "TWVariantsRevPhrases.ocd2" 19 | }, { 20 | "type": "ocd2", 21 | "file": "TWVariantsRev.ocd2" 22 | }] 23 | } 24 | }, { 25 | "dict": { 26 | "type": "group", 27 | "dicts": [{ 28 | "type": "ocd2", 29 | "file": "TSPhrases.ocd2" 30 | }, { 31 | "type": "ocd2", 32 | "file": "TSCharacters.ocd2" 33 | }] 34 | } 35 | }] 36 | } 37 | -------------------------------------------------------------------------------- /iOS/config/tw2t.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Traditional Chinese (Taiwan standard) to Traditional Chinese", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "ocd2", 7 | "file": "TWVariantsRevPhrases.ocd2" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "ocd2", 15 | "file": "TWVariantsRevPhrases.ocd2" 16 | }, { 17 | "type": "ocd2", 18 | "file": "TWVariantsRev.ocd2" 19 | }] 20 | } 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /iOS/marisa/include/marisa/iostream.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_IOSTREAM_H_ 2 | #define MARISA_IOSTREAM_H_ 3 | 4 | #include 5 | 6 | namespace marisa { 7 | 8 | class Trie; 9 | 10 | std::istream &read(std::istream &stream, Trie *trie); 11 | std::ostream &write(std::ostream &stream, const Trie &trie); 12 | 13 | std::istream &operator>>(std::istream &stream, Trie &trie); 14 | std::ostream &operator<<(std::ostream &stream, const Trie &trie); 15 | 16 | } // namespace marisa 17 | 18 | #endif // MARISA_IOSTREAM_H_ 19 | -------------------------------------------------------------------------------- /iOS/marisa/include/marisa/scoped-array.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_SCOPED_ARRAY_H_ 2 | #define MARISA_SCOPED_ARRAY_H_ 3 | 4 | #include "marisa/base.h" 5 | 6 | namespace marisa { 7 | 8 | template 9 | class scoped_array { 10 | public: 11 | scoped_array() : array_(NULL) {} 12 | explicit scoped_array(T *array) : array_(array) {} 13 | 14 | ~scoped_array() { 15 | delete [] array_; 16 | } 17 | 18 | void reset(T *array = NULL) { 19 | MARISA_THROW_IF((array != NULL) && (array == array_), MARISA_RESET_ERROR); 20 | scoped_array(array).swap(*this); 21 | } 22 | 23 | T &operator[](std::size_t i) const { 24 | MARISA_DEBUG_IF(array_ == NULL, MARISA_STATE_ERROR); 25 | return array_[i]; 26 | } 27 | T *get() const { 28 | return array_; 29 | } 30 | 31 | void clear() { 32 | scoped_array().swap(*this); 33 | } 34 | void swap(scoped_array &rhs) { 35 | marisa::swap(array_, rhs.array_); 36 | } 37 | 38 | private: 39 | T *array_; 40 | 41 | // Disallows copy and assignment. 42 | scoped_array(const scoped_array &); 43 | scoped_array &operator=(const scoped_array &); 44 | }; 45 | 46 | } // namespace marisa 47 | 48 | #endif // MARISA_SCOPED_ARRAY_H_ 49 | -------------------------------------------------------------------------------- /iOS/marisa/include/marisa/scoped-ptr.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_SCOPED_PTR_H_ 2 | #define MARISA_SCOPED_PTR_H_ 3 | 4 | #include "marisa/base.h" 5 | 6 | namespace marisa { 7 | 8 | template 9 | class scoped_ptr { 10 | public: 11 | scoped_ptr() : ptr_(NULL) {} 12 | explicit scoped_ptr(T *ptr) : ptr_(ptr) {} 13 | 14 | ~scoped_ptr() { 15 | delete ptr_; 16 | } 17 | 18 | void reset(T *ptr = NULL) { 19 | MARISA_THROW_IF((ptr != NULL) && (ptr == ptr_), MARISA_RESET_ERROR); 20 | scoped_ptr(ptr).swap(*this); 21 | } 22 | 23 | T &operator*() const { 24 | MARISA_DEBUG_IF(ptr_ == NULL, MARISA_STATE_ERROR); 25 | return *ptr_; 26 | } 27 | T *operator->() const { 28 | MARISA_DEBUG_IF(ptr_ == NULL, MARISA_STATE_ERROR); 29 | return ptr_; 30 | } 31 | T *get() const { 32 | return ptr_; 33 | } 34 | 35 | void clear() { 36 | scoped_ptr().swap(*this); 37 | } 38 | void swap(scoped_ptr &rhs) { 39 | marisa::swap(ptr_, rhs.ptr_); 40 | } 41 | 42 | private: 43 | T *ptr_; 44 | 45 | // Disallows copy and assignment. 46 | scoped_ptr(const scoped_ptr &); 47 | scoped_ptr &operator=(const scoped_ptr &); 48 | }; 49 | 50 | } // namespace marisa 51 | 52 | #endif // MARISA_SCOPED_PTR_H_ 53 | -------------------------------------------------------------------------------- /iOS/marisa/include/marisa/stdio.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_MYSTDIO_H_ 2 | #define MARISA_MYSTDIO_H_ 3 | 4 | #include 5 | 6 | namespace marisa { 7 | 8 | class Trie; 9 | 10 | void fread(std::FILE *file, Trie *trie); 11 | void fwrite(std::FILE *file, const Trie &trie); 12 | 13 | } // namespace marisa 14 | 15 | #endif // MARISA_MYSTDIO_H_ 16 | -------------------------------------------------------------------------------- /iOS/marisa/include/marisa/trie.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_TRIE_H_ 2 | #define MARISA_TRIE_H_ 3 | 4 | #include "marisa/keyset.h" 5 | #include "marisa/agent.h" 6 | 7 | namespace marisa { 8 | namespace grimoire { 9 | namespace trie { 10 | 11 | class LoudsTrie; 12 | 13 | } // namespace trie 14 | } // namespace grimoire 15 | 16 | class Trie { 17 | friend class TrieIO; 18 | 19 | public: 20 | Trie(); 21 | ~Trie(); 22 | 23 | void build(Keyset &keyset, int config_flags = 0); 24 | 25 | void mmap(const char *filename); 26 | void map(const void *ptr, std::size_t size); 27 | 28 | void load(const char *filename); 29 | void read(int fd); 30 | 31 | void save(const char *filename) const; 32 | void write(int fd) const; 33 | 34 | bool lookup(Agent &agent) const; 35 | void reverse_lookup(Agent &agent) const; 36 | bool common_prefix_search(Agent &agent) const; 37 | bool predictive_search(Agent &agent) const; 38 | 39 | std::size_t num_tries() const; 40 | std::size_t num_keys() const; 41 | std::size_t num_nodes() const; 42 | 43 | TailMode tail_mode() const; 44 | NodeOrder node_order() const; 45 | 46 | bool empty() const; 47 | std::size_t size() const; 48 | std::size_t total_size() const; 49 | std::size_t io_size() const; 50 | 51 | void clear(); 52 | void swap(Trie &rhs); 53 | 54 | private: 55 | scoped_ptr trie_; 56 | 57 | // Disallows copy and assignment. 58 | Trie(const Trie &); 59 | Trie &operator=(const Trie &); 60 | }; 61 | 62 | } // namespace marisa 63 | 64 | #endif // MARISA_TRIE_H_ 65 | -------------------------------------------------------------------------------- /iOS/marisa/libmarisa.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/marisa/libmarisa.a -------------------------------------------------------------------------------- /iOS/marisa/marisa.h: -------------------------------------------------------------------------------- 1 | #ifndef MARISA_H_ 2 | #define MARISA_H_ 3 | 4 | // "marisa/stdio.h" includes for I/O using std::FILE. 5 | #include "marisa/stdio.h" 6 | 7 | // "marisa/iostream.h" includes for I/O using std::iostream. 8 | #include "marisa/iostream.h" 9 | 10 | // You can use instead of if you don't need the 11 | // above I/O interfaces and don't want to include the above I/O headers. 12 | #include "marisa/trie.h" 13 | 14 | #endif // MARISA_H_ 15 | -------------------------------------------------------------------------------- /iOS/ocd2/HKVariants.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/HKVariants.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/HKVariantsRev.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/HKVariantsRev.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/HKVariantsRevPhrases.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/HKVariantsRevPhrases.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/JPShinjitaiCharacters.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/JPShinjitaiCharacters.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/JPShinjitaiPhrases.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/JPShinjitaiPhrases.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/JPVariants.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/JPVariants.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/JPVariantsRev.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/JPVariantsRev.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/STCharacters.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/STCharacters.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/STPhrases.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/STPhrases.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/TSCharacters.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/TSCharacters.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/TSPhrases.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/TSPhrases.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/TWPhrases.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/TWPhrases.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/TWPhrasesRev.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/TWPhrasesRev.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/TWVariants.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/TWVariants.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/TWVariantsRev.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/TWVariantsRev.ocd2 -------------------------------------------------------------------------------- /iOS/ocd2/TWVariantsRevPhrases.ocd2: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/swiftdo/OpenCC/7a564f463e0fd6ca655ab8a2e39997b0eb1c0e85/iOS/ocd2/TWVariantsRevPhrases.ocd2 -------------------------------------------------------------------------------- /iOS/opencc_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2021 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #define OPENCC_ENABLE_DARTS 22 | -------------------------------------------------------------------------------- /node/configs.gypi: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [{ 3 | "target_name": "configs", 4 | "type": "none", 5 | "copies": [{ 6 | "destination": "<(PRODUCT_DIR)", 7 | "files": [ 8 | "../data/config/hk2s.json", 9 | "../data/config/hk2t.json", 10 | "../data/config/jp2t.json", 11 | "../data/config/s2hk.json", 12 | "../data/config/s2t.json", 13 | "../data/config/s2tw.json", 14 | "../data/config/s2twp.json", 15 | "../data/config/t2hk.json", 16 | "../data/config/t2jp.json", 17 | "../data/config/t2s.json", 18 | "../data/config/t2tw.json", 19 | "../data/config/tw2s.json", 20 | "../data/config/tw2sp.json", 21 | "../data/config/tw2t.json", 22 | ] 23 | }] 24 | }] 25 | } 26 | -------------------------------------------------------------------------------- /node/demo.js: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Example of Node.js API. 4 | * 5 | * @license 6 | * Open Chinese Convert 7 | * 8 | * Copyright 2010-2014 Carbo Kuo 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | /** 24 | * @example node/demo.js 25 | * This is an example of how to use the Node.js API. 26 | */ 27 | 28 | // In your project you should replace './opencc' with 'opencc' 29 | const OpenCC = require('./opencc'); 30 | 31 | console.log('OpenCC version', OpenCC.version); 32 | 33 | // Load the default Simplified to Traditional config 34 | const opencc = new OpenCC('s2t.json'); 35 | 36 | // Sync API 37 | const converted = opencc.convertSync("汉字"); 38 | console.log(converted); 39 | 40 | // Async API 41 | opencc.convert("汉字", (err, converted) => { 42 | console.log(err, converted); 43 | }); 44 | 45 | // Async API with Promise 46 | opencc.convertPromise("汉字").then(converted => { 47 | console.log(converted); 48 | }); 49 | -------------------------------------------------------------------------------- /node/dict.js: -------------------------------------------------------------------------------- 1 | const OpenCC = require('./opencc'); 2 | 3 | const input = process.argv[2]; 4 | const output = process.argv[3]; 5 | 6 | OpenCC.generateDict(input, output, "text", "ocd2"); 7 | -------------------------------------------------------------------------------- /node/global.gypi: -------------------------------------------------------------------------------- 1 | { 2 | "variables": { 3 | "opencc_version": "1.1.3" 4 | }, 5 | "target_defaults": { 6 | "defines": [ 7 | "VERSION=\"<(opencc_version)\"" 8 | ], 9 | "conditions": [ 10 | ["OS=='linux'", { 11 | "cflags": [ 12 | "-std=c++0x" 13 | ], 14 | "cflags!": ["-fno-exceptions"], 15 | "cflags_cc!": ["-fno-exceptions"], 16 | }], 17 | ["OS=='mac'", { 18 | 'xcode_settings': { 19 | 'GCC_ENABLE_CPP_EXCEPTIONS': 'YES', 20 | 'MACOSX_DEPLOYMENT_TARGET': '10.7', 21 | 'OTHER_CPLUSPLUSFLAGS': ["-std=c++14", "-stdlib=libc++"], 22 | 'OTHER_LDFLAGS': ["-stdlib=libc++"] 23 | } 24 | }], 25 | ["OS=='win'", { 26 | "defines": ["Opencc_BUILT_AS_STATIC"] 27 | }] 28 | ] 29 | } 30 | } 31 | -------------------------------------------------------------------------------- /node/marisa.cc: -------------------------------------------------------------------------------- 1 | // For faster build 2 | // Keep include order for VS compatibility. 3 | #include "marisa/trie.cc" 4 | // 1 5 | #include "marisa/agent.cc" 6 | // 2 7 | #include "marisa/grimoire/io/reader.cc" 8 | #include "marisa/grimoire/io/writer.cc" 9 | // 3 10 | #include "marisa/grimoire/io/mapper.cc" 11 | #include "marisa/grimoire/trie/louds-trie.cc" 12 | #include "marisa/grimoire/trie/tail.cc" 13 | #include "marisa/grimoire/vector/bit-vector.cc" 14 | #include "marisa/keyset.cc" 15 | -------------------------------------------------------------------------------- /node/node_opencc.gypi: -------------------------------------------------------------------------------- 1 | { 2 | "targets": [{ 3 | "target_name": "opencc", 4 | "sources": [ 5 | "../node/marisa.cc", 6 | "../node/opencc.cc", 7 | ], 8 | "include_dirs": [ 9 | "../node", 10 | "../src", 11 | "../deps/rapidjson-1.1.0", 12 | "../deps/marisa-0.2.6/include", 13 | "../deps/marisa-0.2.6/lib", 14 | " void): string; 6 | convertSync(input: string): string; 7 | convertPromise(input: string): Promise; 8 | } 9 | export { OpenCC }; 10 | -------------------------------------------------------------------------------- /node/opencc_config.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2021 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | /* #undef OPENCC_ENABLE_DARTS */ 22 | -------------------------------------------------------------------------------- /node/ts-demo.ts: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Example of Node.js API. 4 | * 5 | * @license 6 | * Open Chinese Convert 7 | * 8 | * Copyright 2010-2020 Carbo Kuo 9 | * 10 | * Licensed under the Apache License, Version 2.0 (the "License"); 11 | * you may not use this file except in compliance with the License. 12 | * You may obtain a copy of the License at 13 | * 14 | * http://www.apache.org/licenses/LICENSE-2.0 15 | * 16 | * Unless required by applicable law or agreed to in writing, software 17 | * distributed under the License is distributed on an "AS IS" BASIS, 18 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 19 | * See the License for the specific language governing permissions and 20 | * limitations under the License. 21 | */ 22 | 23 | import { OpenCC } from './opencc'; 24 | 25 | async function main() { 26 | const converter: OpenCC = new OpenCC('s2t.json'); 27 | const result: string = await converter.convertPromise('汉字'); 28 | console.log(result); 29 | } 30 | 31 | main(); 32 | -------------------------------------------------------------------------------- /opencc.pc.in: -------------------------------------------------------------------------------- 1 | prefix=@DIR_PREFIX@ 2 | exec_prefix=${prefix} 3 | libdir=@DIR_LIBRARY@ 4 | includedir=@DIR_INCLUDE@ 5 | 6 | Name: opencc 7 | Description: Open Chinese Convert 8 | Version: @OPENCC_VERSION@ 9 | Requires: 10 | Libs: -L${libdir} -lopencc 11 | Cflags: -I${includedir}/opencc 12 | -------------------------------------------------------------------------------- /package.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "opencc", 3 | "version": "1.1.3", 4 | "description": "Conversion between Traditional and Simplified Chinese", 5 | "author": "Carbo Kuo ", 6 | "license": "Apache-2.0", 7 | "main": "node/opencc.js", 8 | "types": "node/opencc.d.ts", 9 | "scripts": { 10 | "test": "mocha -R spec node/test.js", 11 | "deploy": "node-pre-gyp package && (node-pre-gyp-github publish --release || exit 0)", 12 | "install": "node-pre-gyp install --fallback-to-build || node-pre-gyp rebuild" 13 | }, 14 | "engines": { 15 | "node": ">= 8.0.0" 16 | }, 17 | "binary": { 18 | "module_name": "opencc", 19 | "module_path": "./build/Release/", 20 | "host": "https://github.com/BYVoid/OpenCC/releases/download/", 21 | "remote_path": "{version}" 22 | }, 23 | "repository": { 24 | "type": "git", 25 | "url": "git+https://github.com/BYVoid/OpenCC.git" 26 | }, 27 | "bugs": { 28 | "url": "https://github.com/BYVoid/OpenCC/issues" 29 | }, 30 | "homepage": "https://github.com/BYVoid/OpenCC#readme", 31 | "keywords": [ 32 | "opencc", 33 | "Chinese", 34 | "conversion", 35 | "unicode", 36 | "Simplified Chinese", 37 | "Traditional Chinese" 38 | ], 39 | "devDependencies": { 40 | "mocha": "^8.3.0", 41 | "node-pre-gyp-github": "^1.4.3" 42 | }, 43 | "dependencies": { 44 | "nan": "^2.14.2", 45 | "node-pre-gyp": "^0.14.0" 46 | } 47 | } 48 | -------------------------------------------------------------------------------- /python/opencc/.gitignore: -------------------------------------------------------------------------------- 1 | version.py 2 | clib/ 3 | -------------------------------------------------------------------------------- /python/opencc/__init__.py: -------------------------------------------------------------------------------- 1 | from __future__ import absolute_import, unicode_literals 2 | 3 | import os 4 | import sys 5 | 6 | from opencc.clib import opencc_clib 7 | 8 | __all__ = ['OpenCC', 'CONFIGS', '__version__'] 9 | 10 | __version__ = opencc_clib.__version__ 11 | _thisdir = os.path.dirname(os.path.abspath(__file__)) 12 | _opencc_share_dir = os.path.join(_thisdir, 'clib', 'share', 'opencc') 13 | 14 | if sys.version_info.major == 2: 15 | text_type = unicode # noqa 16 | else: 17 | text_type = str 18 | 19 | if os.path.isdir(_opencc_share_dir): 20 | CONFIGS = [f for f in os.listdir(_opencc_share_dir) if f.endswith('.json')] 21 | else: 22 | CONFIGS = [] 23 | 24 | 25 | def _append_path_to_env(name, path): 26 | value = os.environ.get(name, '') 27 | if path in value: # Path already exists 28 | return 29 | if value == '': 30 | value = path 31 | else: 32 | value += ':' + path 33 | os.environ[name] = value 34 | 35 | 36 | class OpenCC(opencc_clib._OpenCC): 37 | 38 | def __init__(self, config='t2s'): 39 | if not config.endswith('.json'): 40 | config += '.json' 41 | if not os.path.isfile(config): 42 | config = os.path.join(_opencc_share_dir, config) 43 | super(OpenCC, self).__init__(config) 44 | self.config = config 45 | 46 | def convert(self, text): 47 | if isinstance(text, text_type): 48 | text = text.encode('utf-8') 49 | return super(OpenCC, self).convert(text, len(text)) 50 | -------------------------------------------------------------------------------- /python/tests/test_opencc.py: -------------------------------------------------------------------------------- 1 | from __future__ import unicode_literals 2 | 3 | import os 4 | from glob import glob 5 | 6 | _this_dir = os.path.dirname(os.path.abspath(__file__)) 7 | _opencc_rootdir = os.path.abspath(os.path.join(_this_dir, '..', '..')) 8 | _test_assets_dir = os.path.join(_opencc_rootdir, 'test', 'testcases') 9 | 10 | 11 | def test_import(): 12 | import opencc # noqa 13 | 14 | 15 | def test_init_delete_converter(): 16 | import opencc 17 | 18 | for config in opencc.CONFIGS: 19 | converter = opencc.OpenCC(config) 20 | del converter 21 | 22 | 23 | def test_conversion(): 24 | import opencc 25 | 26 | for inpath in glob(os.path.join(_test_assets_dir, '*.in')): 27 | pref = os.path.splitext(inpath)[0] 28 | config = os.path.basename(pref) 29 | converter = opencc.OpenCC(config) 30 | anspath = '{}.{}'.format(pref, 'ans') 31 | assert os.path.isfile(anspath) 32 | 33 | with open(inpath, 'rb') as f: 34 | intexts = [l.strip().decode('utf-8') for l in f] 35 | with open(anspath, 'rb') as f: 36 | anstexts = [l.strip().decode('utf-8') for l in f] 37 | assert len(intexts) == len(anstexts) 38 | 39 | for text, ans in zip(intexts, anstexts): 40 | assert converter.convert(text) == ans, \ 41 | 'Failed to convert {} for {} -> {}'.format(pref, text, ans) 42 | -------------------------------------------------------------------------------- /release-pypi-linux.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | # Different to release-pypi-win.cmd and release-pypi-osx.sh, 5 | # this script has to be ran from a clean dockerfile 6 | 7 | # Random note: The reason why this script is being ran from within a container 8 | # is to ensure glibc compatibility. From what I've seen so far, it appears 9 | # that having multiple glibc versions is a somewhat convoluted process 10 | # and I don't trust myself to be able to manage them well. 11 | 12 | # Download dependenciess 13 | export DEBIAN_FRONTEND=noninteractive 14 | apt update 15 | apt upgrade -y 16 | apt install -y g++ make curl 17 | 18 | cd /opt/OpenCC 19 | 20 | # Download and init conda 21 | MINICONDA_FILENAME=Miniconda3-latest-Linux-x86_64.sh 22 | curl -L -o $MINICONDA_FILENAME \ 23 | "https://repo.continuum.io/miniconda/$MINICONDA_FILENAME" 24 | bash ${MINICONDA_FILENAME} -b -f -p $HOME/miniconda3 25 | export PATH=$HOME/miniconda3/bin:$PATH 26 | eval "$(conda shell.bash hook)" 27 | 28 | for VERSION in 3.5 3.6 3.7 3.8 3.9 3.10; do 29 | # Create and activate environment 30 | conda create -y -n py$VERSION python=$VERSION 31 | conda activate py$VERSION 32 | 33 | # Build and package 34 | pip install --no-cache-dir setuptools wheel cmake 35 | python setup.py build_ext bdist_wheel \ 36 | --plat-name manylinux1_x86_64 37 | 38 | # Cleanup 39 | conda deactivate 40 | rm -rf build python/opencc/clib OpenCC.egg-info 41 | done 42 | 43 | # Upload to PyPI 44 | conda activate py3.8 45 | python -m pip install twine 46 | python -m twine upload dist/* 47 | -------------------------------------------------------------------------------- /release-pypi-macos.sh: -------------------------------------------------------------------------------- 1 | #!/bin/sh 2 | set -e 3 | 4 | # Different to release-pypi-win.cmd and release-pypi-osx.sh, 5 | # this script has to be ran from a clean dockerfile 6 | 7 | # Download and init conda 8 | MINICONDA_FILENAME=Miniconda3-latest-MacOSX-x86_64.sh 9 | curl -L -o $MINICONDA_FILENAME \ 10 | "https://repo.continuum.io/miniconda/$MINICONDA_FILENAME" 11 | bash ${MINICONDA_FILENAME} -b -f -p $HOME/miniconda3 12 | export PATH=$HOME/miniconda3/bin:$PATH 13 | eval "$(conda shell.bash hook)" 14 | 15 | for VERSION in 3.5 3.6 3.7 3.8 3.9 3.10; do 16 | # Create and activate environment 17 | conda create -y -n py$VERSION python=$VERSION 18 | conda activate py$VERSION 19 | 20 | # Build and package 21 | pip install --no-cache-dir setuptools wheel 22 | python setup.py build_ext bdist_wheel 23 | 24 | # Cleanup 25 | conda deactivate 26 | rm -rf build python/opencc/clib OpenCC.egg-info 27 | done 28 | 29 | # Upload to PyPI 30 | conda activate py3.8 31 | python -m pip install twine 32 | python -m twine upload dist/* 33 | -------------------------------------------------------------------------------- /release-pypi-windows.cmd: -------------------------------------------------------------------------------- 1 | @echo off 2 | setlocal EnableDelayedExpansion 3 | 4 | SET VERSIONS=3.5 3.6 3.7 3.8 3.9 3.10 5 | SET SOURCEDIR=%cd% 6 | 7 | REM Build packages 8 | for %%v in (%VERSIONS%) do ( 9 | SET ENV_NAME=py%%v 10 | 11 | REM Create and activate environment 12 | cd %ROOT_DIR% 13 | CALL C:\Miniconda/condabin/conda.bat create -y -n py%%v python=%%v 14 | if !ERRORLEVEL! NEQ 0 (EXIT !ERRORLEVEL!) 15 | CALL C:\Miniconda/condabin/conda.bat activate py%%v 16 | if !ERRORLEVEL! NEQ 0 (EXIT !ERRORLEVEL!) 17 | pip install --no-cache-dir setuptools wheel pytest 18 | if !ERRORLEVEL! NEQ 0 (EXIT !ERRORLEVEL!) 19 | 20 | REM Build and package 21 | python setup.py build_ext bdist_wheel 22 | if !ERRORLEVEL! NEQ 0 (EXIT !ERRORLEVEL!) 23 | 24 | REM Cleanup 25 | CALL C:\Miniconda/condabin/conda.bat deactivate 26 | rmdir /S /Q build python\opencc\clib OpenCC.egg-info 27 | ) 28 | 29 | REM Upload to PyPI 30 | C:\Miniconda/condabin/conda.bat activate py3.8 31 | python -m pip install twine 32 | python -m twine upload dist/* 33 | -------------------------------------------------------------------------------- /src/Config.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2014 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "Common.hpp" 22 | 23 | namespace opencc { 24 | /** 25 | * Configuration loader 26 | * @ingroup opencc_cpp_api 27 | */ 28 | class OPENCC_EXPORT Config { 29 | public: 30 | Config(); 31 | 32 | virtual ~Config(); 33 | 34 | ConverterPtr NewFromString(const std::string& json, 35 | const std::string& configDirectory); 36 | 37 | ConverterPtr NewFromFile(const std::string& fileName); 38 | 39 | private: 40 | void* internal; 41 | }; 42 | } // namespace opencc 43 | -------------------------------------------------------------------------------- /src/ConfigTestBase.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2015 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "TestUtils.hpp" 22 | 23 | namespace opencc { 24 | 25 | class ConfigTestBase : public ::testing::Test { 26 | protected: 27 | ConfigTestBase() 28 | : CONFIG_TEST_PATH(CMAKE_SOURCE_DIR 29 | "/test/config_test/config_test.json") {} 30 | 31 | const std::string CONFIG_TEST_PATH; 32 | }; 33 | 34 | } // namespace opencc 35 | -------------------------------------------------------------------------------- /src/Conversion.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2014 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "Common.hpp" 22 | #include "Segmentation.hpp" 23 | 24 | namespace opencc { 25 | /** 26 | * Conversion interface 27 | * @ingroup opencc_cpp_api 28 | */ 29 | class OPENCC_EXPORT Conversion { 30 | public: 31 | Conversion(DictPtr _dict) : dict(_dict) {} 32 | 33 | // Convert single phrase 34 | std::string Convert(const std::string& phrase) const; 35 | 36 | // Convert single phrase 37 | std::string Convert(const char* phrase) const; 38 | 39 | // Convert segmented text 40 | SegmentsPtr Convert(const SegmentsPtr& input) const; 41 | 42 | const DictPtr GetDict() const { return dict; } 43 | 44 | private: 45 | const DictPtr dict; 46 | }; 47 | } // namespace opencc 48 | -------------------------------------------------------------------------------- /src/ConversionChain.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2014 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include 20 | 21 | #include "ConversionChain.hpp" 22 | #include "Segments.hpp" 23 | 24 | using namespace opencc; 25 | 26 | ConversionChain::ConversionChain(const std::list _conversions) 27 | : conversions(_conversions) {} 28 | 29 | SegmentsPtr ConversionChain::Convert(const SegmentsPtr& input) const { 30 | SegmentsPtr output = input; 31 | for (auto conversion : conversions) { 32 | output = conversion->Convert(output); 33 | } 34 | return output; 35 | } 36 | -------------------------------------------------------------------------------- /src/ConversionChain.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2014 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | #include "Common.hpp" 24 | #include "Conversion.hpp" 25 | 26 | namespace opencc { 27 | /** 28 | * Chain of conversions 29 | * Consists of a list of conversions. Converts input in sequence. 30 | * @ingroup opencc_cpp_api 31 | */ 32 | class OPENCC_EXPORT ConversionChain { 33 | public: 34 | ConversionChain(const std::list _conversions); 35 | 36 | SegmentsPtr Convert(const SegmentsPtr& input) const; 37 | 38 | const std::list GetConversions() const { return conversions; } 39 | 40 | private: 41 | const std::list conversions; 42 | }; 43 | } // namespace opencc 44 | -------------------------------------------------------------------------------- /src/ConversionTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2015 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "Conversion.hpp" 20 | #include "DictGroupTestBase.hpp" 21 | 22 | namespace opencc { 23 | 24 | class ConversionTest : public DictGroupTestBase { 25 | protected: 26 | ConversionTest() 27 | : input(utf8("太后的头发干燥")), expected(utf8("太后的頭髮乾燥")) {} 28 | 29 | virtual void SetUp() { 30 | dict = CreateDictGroupForConversion(); 31 | conversion = ConversionPtr(new Conversion(dict)); 32 | } 33 | 34 | DictPtr dict; 35 | ConversionPtr conversion; 36 | const std::string input; 37 | const std::string expected; 38 | }; 39 | 40 | TEST_F(ConversionTest, ConvertString) { 41 | const std::string converted = conversion->Convert(input); 42 | EXPECT_EQ(expected, converted); 43 | } 44 | 45 | TEST_F(ConversionTest, ConvertCString) { 46 | const std::string converted = conversion->Convert(input.c_str()); 47 | EXPECT_EQ(expected, converted); 48 | } 49 | 50 | } // namespace opencc 51 | -------------------------------------------------------------------------------- /src/Converter.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2014 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include 20 | 21 | #include "ConversionChain.hpp" 22 | #include "Converter.hpp" 23 | #include "Segments.hpp" 24 | 25 | using namespace opencc; 26 | 27 | std::string Converter::Convert(const std::string& text) const { 28 | const SegmentsPtr& segments = segmentation->Segment(text); 29 | const SegmentsPtr& converted = conversionChain->Convert(segments); 30 | return converted->ToString(); 31 | } 32 | 33 | size_t Converter::Convert(const char* input, char* output) const { 34 | const std::string& converted = Convert(input); 35 | strcpy(output, converted.c_str()); 36 | return converted.length(); 37 | } 38 | -------------------------------------------------------------------------------- /src/Converter.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2014 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "Common.hpp" 22 | #include "Segmentation.hpp" 23 | 24 | namespace opencc { 25 | /** 26 | * Controller of segmentation and conversion 27 | * @ingroup opencc_cpp_api 28 | */ 29 | class OPENCC_EXPORT Converter { 30 | public: 31 | Converter(const std::string& _name, SegmentationPtr _segmentation, 32 | ConversionChainPtr _conversionChain) 33 | : name(_name), segmentation(_segmentation), 34 | conversionChain(_conversionChain) {} 35 | 36 | std::string Convert(const std::string& text) const; 37 | 38 | size_t Convert(const char* input, char* output) const; 39 | 40 | const SegmentationPtr GetSegmentation() const { return segmentation; } 41 | 42 | const ConversionChainPtr GetConversionChain() const { 43 | return conversionChain; 44 | } 45 | 46 | private: 47 | const std::string name; 48 | const SegmentationPtr segmentation; 49 | const ConversionChainPtr conversionChain; 50 | }; 51 | } // namespace opencc 52 | -------------------------------------------------------------------------------- /src/DictConverter.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2017 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "Common.hpp" 22 | 23 | namespace opencc { 24 | /** 25 | * Converts a dictionary from a format to another. 26 | * @ingroup opencc_cpp_api 27 | */ 28 | OPENCC_EXPORT void ConvertDictionary(const std::string& inputFileName, 29 | const std::string& outputFileName, 30 | const std::string& formatFrom, 31 | const std::string& formatTo); 32 | } // namespace opencc 33 | -------------------------------------------------------------------------------- /src/DictEntry.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2020 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "DictEntry.hpp" 20 | 21 | using namespace opencc; 22 | 23 | std::string MultiValueDictEntry::ToString() const { 24 | // TODO escape space 25 | size_t i = 0; 26 | size_t length = Values().size(); 27 | std::ostringstream buffer; 28 | buffer << Key() << '\t'; 29 | for (const std::string& value : Values()) { 30 | buffer << value; 31 | if (i < length - 1) { 32 | buffer << ' '; 33 | } 34 | i++; 35 | } 36 | return buffer.str(); 37 | } -------------------------------------------------------------------------------- /src/DictGroupTestBase.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2015 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "DictGroup.hpp" 22 | #include "TextDictTestBase.hpp" 23 | 24 | namespace opencc { 25 | 26 | class DictGroupTestBase : public TextDictTestBase { 27 | protected: 28 | DictGroupPtr CreateDictGroupForConversion() const { 29 | DictPtr phrasesDict = CreateDictForPhrases(); 30 | DictPtr charactersDict = CreateDictForCharacters(); 31 | DictGroupPtr dictGroup( 32 | new DictGroup(std::list{phrasesDict, charactersDict})); 33 | return dictGroup; 34 | } 35 | }; 36 | 37 | } // namespace opencc 38 | -------------------------------------------------------------------------------- /src/Export.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2014 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #if defined(Opencc_BUILT_AS_STATIC) || !defined(_WIN32) 22 | #define OPENCC_EXPORT 23 | #define OPENCC_NO_EXPORT 24 | #else // if defined(Opencc_BUILT_AS_STATIC) || !defined(_WIN32) 25 | #ifndef OPENCC_EXPORT 26 | #ifdef libopencc_EXPORTS 27 | 28 | /* We are building this library */ 29 | #define OPENCC_EXPORT __declspec(dllexport) 30 | #else // ifdef libopencc_EXPORTS 31 | 32 | /* We are using this library */ 33 | #define OPENCC_EXPORT __declspec(dllimport) 34 | #endif // ifdef libopencc_EXPORTS 35 | #endif // ifndef OPENCC_EXPORT 36 | 37 | #ifndef OPENCC_NO_EXPORT 38 | #define OPENCC_NO_EXPORT 39 | #endif // ifndef OPENCC_NO_EXPORT 40 | #endif // if defined(Opencc_BUILT_AS_STATIC) || !defined(_WIN32) 41 | -------------------------------------------------------------------------------- /src/Lexicon.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2020 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include 20 | 21 | #include "Lexicon.hpp" 22 | namespace opencc { 23 | 24 | void Lexicon::Sort() { 25 | std::sort(entries.begin(), entries.end(), DictEntry::UPtrLessThan); 26 | } 27 | 28 | bool Lexicon::IsSorted() { 29 | return std::is_sorted(entries.begin(), entries.end(), 30 | DictEntry::UPtrLessThan); 31 | } 32 | 33 | bool Lexicon::IsUnique() { 34 | for (size_t i = 1; i < entries.size(); ++i) { 35 | if (entries[i - 1]->Key() == entries[i]->Key()) { 36 | return false; 37 | } 38 | } 39 | return true; 40 | } 41 | 42 | } // namespace opencc 43 | -------------------------------------------------------------------------------- /src/MaxMatchSegmentation.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2014 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "Common.hpp" 22 | #include "DictGroup.hpp" 23 | #include "Segmentation.hpp" 24 | 25 | namespace opencc { 26 | /** 27 | * Implementation of maximal match segmentation 28 | * @ingroup opencc_cpp_api 29 | */ 30 | class OPENCC_EXPORT MaxMatchSegmentation : public Segmentation { 31 | public: 32 | MaxMatchSegmentation(const DictPtr _dict) : dict(_dict) {} 33 | 34 | virtual ~MaxMatchSegmentation() {} 35 | 36 | virtual SegmentsPtr Segment(const std::string& text) const; 37 | 38 | const DictPtr GetDict() const { return dict; } 39 | 40 | private: 41 | const DictPtr dict; 42 | }; 43 | } // namespace opencc 44 | -------------------------------------------------------------------------------- /src/MaxMatchSegmentationTest.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2015 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "MaxMatchSegmentation.hpp" 20 | #include "DictGroupTestBase.hpp" 21 | 22 | namespace opencc { 23 | 24 | class MaxMatchSegmentationTest : public DictGroupTestBase { 25 | protected: 26 | MaxMatchSegmentationTest() {} 27 | 28 | virtual void SetUp() { 29 | dict = CreateDictGroupForConversion(); 30 | segmenter = SegmentationPtr(new MaxMatchSegmentation(dict)); 31 | } 32 | 33 | DictPtr dict; 34 | SegmentationPtr segmenter; 35 | }; 36 | 37 | TEST_F(MaxMatchSegmentationTest, Segment) { 38 | const auto& segments = segmenter->Segment(utf8("太后的头发干燥")); 39 | EXPECT_EQ(4, segments->Length()); 40 | EXPECT_EQ(utf8("太后"), std::string(segments->At(0))); 41 | EXPECT_EQ(utf8("的"), std::string(segments->At(1))); 42 | EXPECT_EQ(utf8("头发"), std::string(segments->At(2))); 43 | EXPECT_EQ(utf8("干燥"), std::string(segments->At(3))); 44 | } 45 | 46 | } // namespace opencc 47 | -------------------------------------------------------------------------------- /src/README.md: -------------------------------------------------------------------------------- 1 | # Source code 2 | 3 | ## Dictionary 4 | 5 | ### Interface 6 | 7 | * Dict: Declares `Match` and related functions. 8 | * SerializableDict: Declares dictionary serialization and deserialization functions. 9 | 10 | ### Implementations 11 | 12 | * TextDict: Tabular separated dictionary format. 13 | * BinaryDict: Stores keys and values in binary format. For serialization only. 14 | * DartsDict: Double-array trie (`.ocd`). 15 | * MarisaDict: Marisa trie (`.ocd2`). 16 | * DictGroup: A wrap of a group of dictionaries. Iterates one by one until a match. 17 | 18 | ## Conversion 19 | -------------------------------------------------------------------------------- /src/Segmentation.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2014 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | -------------------------------------------------------------------------------- /src/Segmentation.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2014 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "Common.hpp" 22 | 23 | namespace opencc { 24 | /** 25 | * Abstract segmentation 26 | * @ingroup opencc_cpp_api 27 | */ 28 | class OPENCC_EXPORT Segmentation { 29 | public: 30 | virtual SegmentsPtr Segment(const std::string& text) const = 0; 31 | }; 32 | } // namespace opencc 33 | -------------------------------------------------------------------------------- /src/SerializedValues.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2020 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "Common.hpp" 22 | #include "SerializableDict.hpp" 23 | 24 | namespace opencc { 25 | /** 26 | * Binary format for dictionary values serialization. 27 | * @ingroup opencc_cpp_api 28 | */ 29 | class OPENCC_EXPORT SerializedValues : public SerializableDict { 30 | public: 31 | SerializedValues(const LexiconPtr& _lexicon) : lexicon(_lexicon) {} 32 | 33 | virtual ~SerializedValues() {} 34 | 35 | virtual void SerializeToFile(FILE* fp) const; 36 | 37 | static std::shared_ptr NewFromFile(FILE* fp); 38 | 39 | const LexiconPtr& GetLexicon() const { return lexicon; } 40 | 41 | size_t KeyMaxLength() const; 42 | 43 | private: 44 | LexiconPtr lexicon; 45 | 46 | void ConstructBuffer(std::string* valueBuffer, 47 | std::vector* valueBytes, 48 | uint32_t* valueTotalLength) const; 49 | }; 50 | } // namespace opencc 51 | -------------------------------------------------------------------------------- /src/TestUtils.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2014 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include "gtest/gtest.h" 22 | #include 23 | 24 | namespace opencc { 25 | 26 | using std::string; 27 | 28 | #ifdef _MSC_VER 29 | #define __func__ __FUNCTION__ 30 | #endif // ifdef _MSC_VER 31 | 32 | #define EXPECT_VECTOR_EQ(expected, actual) \ 33 | { \ 34 | const auto& a1 = (expected); \ 35 | const auto& a2 = (actual); \ 36 | EXPECT_EQ(a1.size(), a2.size()); \ 37 | for (size_t i = 0; i < a1.size(); i++) { \ 38 | EXPECT_EQ(a1[i], a2[i]) << "Where i = " << i; \ 39 | } \ 40 | } 41 | 42 | } // namespace opencc 43 | -------------------------------------------------------------------------------- /src/TestUtilsUTF8.hpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2020 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #include 22 | 23 | namespace opencc { 24 | 25 | #define utf8(str) std::string(str) 26 | 27 | } // namespace opencc 28 | -------------------------------------------------------------------------------- /src/UTF8StringSlice.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2015 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "UTF8StringSlice.hpp" 20 | 21 | namespace opencc {} // namespace opencc 22 | -------------------------------------------------------------------------------- /src/UTF8Util.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2010-2014 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "UTF8Util.hpp" 20 | 21 | using namespace opencc; 22 | 23 | void UTF8Util::SkipUtf8Bom(FILE* fp) { 24 | /* UTF-8 BOM is EF BB BF */ 25 | if (fp == NULL) { 26 | return; 27 | } 28 | /* If we are not at beginning of file, return */ 29 | if (ftell(fp) != 0) { 30 | return; 31 | } 32 | 33 | /* Try to read first 3 bytes */ 34 | int bom[3]; 35 | int n; 36 | for (n = 0; n <= 2 && (bom[n] = getc(fp)) != EOF; n++) { 37 | } 38 | /* If we can only read <3 bytes, push them back */ 39 | /* Or if first 3 bytes is not BOM, push them back */ 40 | if ((n < 3) || (bom[0] != 0xEF) || (bom[1] != 0xBB) || (bom[2] != 0xBF)) { 41 | for (n--; n >= 0; n--) { 42 | ungetc(bom[n], fp); 43 | } 44 | } 45 | 46 | /* Otherwise, BOM is already skipped */ 47 | } 48 | -------------------------------------------------------------------------------- /src/benchmark/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | add_executable(performance Performance.cpp) 2 | target_link_libraries(performance benchmark libopencc) 3 | add_test(BenchmarkTest performance) 4 | 5 | if (WIN32) 6 | add_custom_target( 7 | copy_benchmark 8 | ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_BINARY_DIR} 9 | COMMENT "Copying benchmark to src/benchmark" 10 | ) 11 | add_custom_target( 12 | copy_libopencc 13 | ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_BINARY_DIR} 14 | COMMENT "Copying libopencc to src/benchmark" 15 | ) 16 | add_dependencies(performance copy_benchmark copy_libopencc) 17 | endif() 18 | -------------------------------------------------------------------------------- /src/opencc_config.h.in: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2021 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #pragma once 20 | 21 | #cmakedefine OPENCC_ENABLE_DARTS 22 | -------------------------------------------------------------------------------- /src/py_opencc.cpp: -------------------------------------------------------------------------------- 1 | /* 2 | * Open Chinese Convert 3 | * 4 | * Copyright 2020-2021 Carbo Kuo 5 | * 6 | * Licensed under the Apache License, Version 2.0 (the "License"); 7 | * you may not use this file except in compliance with the License. 8 | * You may obtain a copy of the License at 9 | * 10 | * http://www.apache.org/licenses/LICENSE-2.0 11 | * 12 | * Unless required by applicable law or agreed to in writing, software 13 | * distributed under the License is distributed on an "AS IS" BASIS, 14 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 15 | * See the License for the specific language governing permissions and 16 | * limitations under the License. 17 | */ 18 | 19 | #include "opencc.h" 20 | #include 21 | 22 | namespace py = pybind11; 23 | 24 | PYBIND11_MODULE(opencc_clib, m) { 25 | py::class_(m, "_OpenCC") 26 | .def(py::init()) 27 | .def("convert", py::overload_cast( 28 | &opencc::SimpleConverter::Convert, py::const_)); 29 | 30 | #ifdef VERSION 31 | m.attr("__version__") = VERSION; 32 | #else 33 | m.attr("__version__") = "dev"; 34 | #endif 35 | } 36 | -------------------------------------------------------------------------------- /src/tools/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # Executables 2 | 3 | ## opencc 4 | add_executable(opencc CommandLine.cpp) 5 | target_link_libraries(opencc libopencc) 6 | 7 | ## opencc_dict 8 | add_executable(opencc_dict DictConverter.cpp) 9 | target_link_libraries(opencc_dict libopencc) 10 | 11 | ## opencc_phrase_extract 12 | add_executable(opencc_phrase_extract PhraseExtract.cpp) 13 | target_link_libraries(opencc_phrase_extract libopencc) 14 | 15 | # Installation 16 | 17 | install( 18 | TARGETS opencc opencc_dict opencc_phrase_extract 19 | RUNTIME DESTINATION bin 20 | ) 21 | -------------------------------------------------------------------------------- /test.cmd: -------------------------------------------------------------------------------- 1 | cmake -S. -Bbuild -DCMAKE_INSTALL_PREFIX:PATH=. -DENABLE_GTEST:BOOL=ON -DCMAKE_BUILD_TYPE=Debug 2 | cmake --build build --config Debug --target install 3 | cd build 4 | ctest --verbose -C Debug 5 | -------------------------------------------------------------------------------- /test/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | include_directories("${PROJECT_BINARY_DIR}/src") 2 | include_directories("${PROJECT_SOURCE_DIR}/src") 3 | 4 | set(CONFIG_TEST 5 | config_test/config_test.json 6 | config_test/config_test_characters.txt 7 | config_test/config_test_phrases.txt 8 | ) 9 | 10 | set(CONFIG_TEST_TARGET_DIR ${PROJECT_BINARY_DIR}/test/config_test) 11 | make_directory(${CONFIG_TEST_TARGET_DIR}) 12 | foreach (CONFIG_TEST_FILE ${CONFIG_TEST}) 13 | configure_file(${CONFIG_TEST_FILE} ${CONFIG_TEST_TARGET_DIR} COPYONLY) 14 | endforeach (CONFIG_TEST_FILE) 15 | 16 | if (ENABLE_GTEST) 17 | if (WIN32) 18 | add_custom_target( 19 | copy_gtest_to_test 20 | ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_BINARY_DIR} 21 | COMMENT "Copying gtest to test" 22 | ) 23 | add_custom_target( 24 | copy_gtest_main_to_test 25 | ${CMAKE_COMMAND} -E copy $ ${CMAKE_CURRENT_BINARY_DIR} 26 | COMMENT "Copying gtest_main to test" 27 | ) 28 | endif() 29 | 30 | if(NOT USE_SYSTEM_GTEST) 31 | include_directories(../deps/gtest-1.7.0/include) 32 | endif() 33 | set(UNITTESTS 34 | CommandLineConvertTest 35 | ) 36 | foreach(UNITTEST ${UNITTESTS}) 37 | add_executable(${UNITTEST} ${UNITTEST}.cpp) 38 | target_link_libraries(${UNITTEST} gtest gtest_main libopencc) 39 | add_test(${UNITTEST} ${UNITTEST}) 40 | if (WIN32) 41 | add_dependencies(${UNITTEST} copy_gtest_to_test copy_gtest_main_to_test) 42 | endif() 43 | endforeach(UNITTEST) 44 | endif() 45 | -------------------------------------------------------------------------------- /test/config_test/config_test.json: -------------------------------------------------------------------------------- 1 | { 2 | "name": "Configuration Test", 3 | "segmentation": { 4 | "type": "mmseg", 5 | "dict": { 6 | "type": "text", 7 | "file": "config_test_phrases.txt" 8 | } 9 | }, 10 | "conversion_chain": [{ 11 | "dict": { 12 | "type": "group", 13 | "dicts": [{ 14 | "type": "text", 15 | "file": "config_test_phrases.txt" 16 | }, { 17 | "type": "text", 18 | "file": "config_test_characters.txt" 19 | }] 20 | } 21 | }] 22 | } 23 | -------------------------------------------------------------------------------- /test/config_test/config_test_characters.txt: -------------------------------------------------------------------------------- 1 | 于 於 2 | 远 遠 3 | -------------------------------------------------------------------------------- /test/config_test/config_test_phrases.txt: -------------------------------------------------------------------------------- 1 | 燕燕于飞 燕燕于飛 2 | 之子于归 之子于歸 3 | -------------------------------------------------------------------------------- /test/testcases/hk2s.ans: -------------------------------------------------------------------------------- 1 | 虚伪叹息 2 | 潮湿灶台 3 | 赞叹沙河涌汹涌的波浪 -------------------------------------------------------------------------------- /test/testcases/hk2s.in: -------------------------------------------------------------------------------- 1 | 虛偽歎息 2 | 潮濕灶台 3 | 讚歎沙河涌洶湧的波浪 -------------------------------------------------------------------------------- /test/testcases/hk2t.ans: -------------------------------------------------------------------------------- 1 | 爲賦新詞強說愁 2 | 想到自己一緊張就口吃,我就沒胃口喫飯 -------------------------------------------------------------------------------- /test/testcases/hk2t.in: -------------------------------------------------------------------------------- 1 | 為賦新詞強説愁 2 | 想到自己一緊張就口吃,我就沒胃口吃飯 -------------------------------------------------------------------------------- /test/testcases/jp2t.ans: -------------------------------------------------------------------------------- 1 | 舊字體歷史假名遣 新字體現代假名遣 2 | 橫濱 絲魚川 伊豫國 3 | 驛辨當 辨別 辯護士 瓣膜 4 | 藝術 缺航 欠缺 飲料罐 -------------------------------------------------------------------------------- /test/testcases/jp2t.in: -------------------------------------------------------------------------------- 1 | 旧字体歴史仮名遣 新字体現代仮名遣 2 | 横浜 糸魚川 伊予国 3 | 駅弁当 弁別 弁護士 弁膜 4 | 芸術 欠航 欠缺 飲料缶 -------------------------------------------------------------------------------- /test/testcases/s2hk.ans: -------------------------------------------------------------------------------- 1 | 虛偽嘆息 2 | 潮濕灶台 3 | 讚歎沙河涌洶湧的波浪 4 | 為了核實這説法 -------------------------------------------------------------------------------- /test/testcases/s2hk.in: -------------------------------------------------------------------------------- 1 | 虚伪叹息 2 | 潮湿灶台 3 | 赞叹沙河涌汹涌的波浪 4 | 为了核实这说法 -------------------------------------------------------------------------------- /test/testcases/s2t.ans: -------------------------------------------------------------------------------- 1 | 誇誇其談 夸父逐日 2 | 我幹什麼不干你事。 3 | 太后的頭髮很乾燥。 4 | 燕燕于飛,差池其羽。之子于歸,遠送於野。 5 | 請成相,世之殃,愚闇愚闇墮賢良。人主無賢,如瞽無相何倀倀!請布基,慎聖人,愚而自專事不治。主忌苟勝,羣臣莫諫必逢災。 6 | 曾經有一份真誠的愛情放在我面前,我沒有珍惜,等我失去的時候我才後悔莫及。人事間最痛苦的事莫過於此。如果上天能夠給我一個再來一次得機會,我會對那個女孩子說三個字,我愛你。如果非要在這份愛上加個期限,我希望是,一萬年。 7 | 新的理論被發現了。 8 | 金胄不是金色的甲冑。 9 | 經理發現後勸諭兩人 -------------------------------------------------------------------------------- /test/testcases/s2t.in: -------------------------------------------------------------------------------- 1 | 夸夸其谈 夸父逐日 2 | 我干什么不干你事。 3 | 太后的头发很干燥。 4 | 燕燕于飞,差池其羽。之子于归,远送于野。 5 | 请成相,世之殃,愚暗愚暗堕贤良。人主无贤,如瞽无相何伥伥!请布基,慎圣人,愚而自专事不治。主忌苟胜,群臣莫谏必逢灾。 6 | 曾经有一份真诚的爱情放在我面前,我没有珍惜,等我失去的时候我才后悔莫及。人事间最痛苦的事莫过于此。如果上天能够给我一个再来一次得机会,我会对那个女孩子说三个字,我爱你。如果非要在这份爱上加个期限,我希望是,一万年。 7 | 新的理论被发现了。 8 | 金胄不是金色的甲胄。 9 | 经理发现后劝谕两人 -------------------------------------------------------------------------------- /test/testcases/s2tw.ans: -------------------------------------------------------------------------------- 1 | 著裝汙染虛偽發洩稜柱群眾裡面 2 | 鯰魚和鯰魚是一種生物。 -------------------------------------------------------------------------------- /test/testcases/s2tw.in: -------------------------------------------------------------------------------- 1 | 着装污染虚伪发泄棱柱群众里面 2 | 鲶鱼和鲇鱼是一种生物。 -------------------------------------------------------------------------------- /test/testcases/s2twp.ans: -------------------------------------------------------------------------------- 1 | 滑鼠裡面的矽二極體壞了,導致游標解析度降低。 2 | 我們在寮國的伺服器的硬碟需要使用網際網路演算法軟體解決非同步的問題。 3 | 為什麼你在床裡面睡著? 4 | 海內存知己 -------------------------------------------------------------------------------- /test/testcases/s2twp.in: -------------------------------------------------------------------------------- 1 | 鼠标里面的硅二极管坏了,导致光标分辨率降低。 2 | 我们在老挝的服务器的硬盘需要使用互联网算法软件解决异步的问题。 3 | 为什么你在床里面睡着? 4 | 海内存知己 -------------------------------------------------------------------------------- /test/testcases/t2hk.ans: -------------------------------------------------------------------------------- 1 | 潮濕的露台 2 | 為了核實這説法 3 | 包粽子活動告一段落 -------------------------------------------------------------------------------- /test/testcases/t2hk.in: -------------------------------------------------------------------------------- 1 | 潮溼的露臺 2 | 爲了覈實這說法 3 | 包糉子活動告一段落 -------------------------------------------------------------------------------- /test/testcases/t2jp.ans: -------------------------------------------------------------------------------- 1 | 旧字体歴史仮名遣 新字体現代仮名遣 2 | 横浜 糸魚川 伊予国 3 | 駅弁当 弁別 弁護士 弁膜 4 | 芸術 欠航 飲料缶 -------------------------------------------------------------------------------- /test/testcases/t2jp.in: -------------------------------------------------------------------------------- 1 | 舊字體歷史假名遣 新字體現代假名遣 2 | 橫濱 絲魚川 伊豫國 3 | 驛辨當 辨別 辯護士 瓣膜 4 | 藝術 缺航 飲料罐 -------------------------------------------------------------------------------- /test/testcases/t2s.ans: -------------------------------------------------------------------------------- 1 | 曾经有一份真诚的爱情放在我面前,我没有珍惜,等我失去的时候我才后悔莫及。人事间最痛苦的事莫过于此。如果上天能够给我一个再来一次得机会,我会对那个女孩子说三个字,我爱你。如果非要在这份爱上加个期限,我希望是,一万年。 -------------------------------------------------------------------------------- /test/testcases/t2s.in: -------------------------------------------------------------------------------- 1 | 曾經有一份真誠的愛情放在我面前,我沒有珍惜,等我失去的時候我才後悔莫及。人事間最痛苦的事莫過於此。如果上天能夠給我一個再來一次得機會,我會對那個女孩子說三個字,我愛你。如果非要在這份愛上加個期限,我希望是,一萬年。 -------------------------------------------------------------------------------- /test/testcases/tw2s.ans: -------------------------------------------------------------------------------- 1 | 着装著作污染虚伪发泄棱柱群众里面 -------------------------------------------------------------------------------- /test/testcases/tw2s.in: -------------------------------------------------------------------------------- 1 | 著裝著作汙染虛偽發洩稜柱群眾裡面 -------------------------------------------------------------------------------- /test/testcases/tw2sp.ans: -------------------------------------------------------------------------------- 1 | 鼠标里面的硅二极管坏了,导致光标分辨率降低。 2 | 我们在老挝的服务器的硬盘需要使用互联网算法软件解决异步的问题。 3 | 为什么你在床里面睡着? 4 | 用鼠标点击正则表达式 5 | KB大桥也被视为帕劳人的后花园 -------------------------------------------------------------------------------- /test/testcases/tw2sp.in: -------------------------------------------------------------------------------- 1 | 滑鼠裡面的矽二極體壞了,導致游標解析度降低。 2 | 我們在寮國的伺服器的硬碟需要使用網際網路演算法軟體解決非同步的問題。 3 | 為什麼你在床裡面睡著? 4 | 用滑鼠點選正規表示式 5 | KB大橋也被視為帛琉人的後花園 -------------------------------------------------------------------------------- /test/testcases/tw2t.ans: -------------------------------------------------------------------------------- 1 | 爲了衆人化妝牀頭裏面衛生,醞釀羣峯鐵鉤嘆氣事件 2 | 在廚房裏做手擀麪 3 | 想到自己一緊張就口吃,我就沒胃口喫飯 -------------------------------------------------------------------------------- /test/testcases/tw2t.in: -------------------------------------------------------------------------------- 1 | 為了眾人化妝床頭裡面衛生,醞釀群峰鐵鉤嘆氣事件 2 | 在廚房裡做手擀麵 3 | 想到自己一緊張就口吃,我就沒胃口吃飯 --------------------------------------------------------------------------------