text_ux 0.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (147) hide show
  1. checksums.yaml +7 -0
  2. data/.gitignore +25 -0
  3. data/.rspec +2 -0
  4. data/Gemfile +4 -0
  5. data/LICENSE.txt +22 -0
  6. data/README.md +51 -0
  7. data/Rakefile +18 -0
  8. data/ext/text_ux/extconf.rb +5 -0
  9. data/ext/text_ux/text_ux.cpp +252 -0
  10. data/lib/text_ux.rb +5 -0
  11. data/lib/text_ux/version.rb +3 -0
  12. data/spec/fixtures/test.ux +0 -0
  13. data/spec/spec_helper.rb +19 -0
  14. data/spec/text_ux_spec.rb +137 -0
  15. data/text_ux.gemspec +26 -0
  16. data/vendor/ux-trie/ux-0.1.9/.lock-waf_darwin_build +8 -0
  17. data/vendor/ux-trie/ux-0.1.9/.unittest-gtest/gtest-1.6.0/fused-src/gtest/gtest-all.cc +9118 -0
  18. data/vendor/ux-trie/ux-0.1.9/.unittest-gtest/gtest-1.6.0/fused-src/gtest/gtest.h +19537 -0
  19. data/vendor/ux-trie/ux-0.1.9/.unittest-gtest/gtest-1.6.0/fused-src/gtest/gtest_main.cc +39 -0
  20. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Build.py +733 -0
  21. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Build.pyc +0 -0
  22. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/ConfigSet.py +147 -0
  23. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/ConfigSet.pyc +0 -0
  24. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Configure.py +314 -0
  25. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Configure.pyc +0 -0
  26. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Context.py +298 -0
  27. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Context.pyc +0 -0
  28. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Errors.py +37 -0
  29. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Errors.pyc +0 -0
  30. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Logs.py +149 -0
  31. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Logs.pyc +0 -0
  32. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Node.py +500 -0
  33. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Node.pyc +0 -0
  34. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Options.py +130 -0
  35. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Options.pyc +0 -0
  36. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Runner.py +191 -0
  37. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Runner.pyc +0 -0
  38. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Scripting.py +358 -0
  39. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Scripting.pyc +0 -0
  40. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Task.py +669 -0
  41. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Task.pyc +0 -0
  42. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/TaskGen.py +341 -0
  43. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/TaskGen.pyc +0 -0
  44. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/__init__.py +4 -0
  45. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/__init__.pyc +0 -0
  46. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/ar.py +12 -0
  47. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/ar.pyc +0 -0
  48. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/asm.py +25 -0
  49. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/bison.py +29 -0
  50. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/c.py +27 -0
  51. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/c_aliases.py +56 -0
  52. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/c_aliases.pyc +0 -0
  53. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/c_config.py +708 -0
  54. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/c_config.pyc +0 -0
  55. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/c_osx.py +121 -0
  56. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/c_osx.pyc +0 -0
  57. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/c_preproc.py +606 -0
  58. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/c_preproc.pyc +0 -0
  59. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/c_tests.py +110 -0
  60. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/c_tests.pyc +0 -0
  61. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/ccroot.py +372 -0
  62. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/ccroot.pyc +0 -0
  63. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/compiler_c.py +39 -0
  64. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/compiler_cxx.py +39 -0
  65. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/compiler_cxx.pyc +0 -0
  66. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/compiler_d.py +30 -0
  67. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/compiler_fc.py +45 -0
  68. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/cs.py +98 -0
  69. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/cxx.py +27 -0
  70. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/cxx.pyc +0 -0
  71. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/d.py +51 -0
  72. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/d_config.py +47 -0
  73. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/d_scan.py +133 -0
  74. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/dbus.py +30 -0
  75. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/dmd.py +43 -0
  76. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/errcheck.py +153 -0
  77. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/fc.py +123 -0
  78. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/fc_config.py +271 -0
  79. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/fc_scan.py +68 -0
  80. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/flex.py +27 -0
  81. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/g95.py +55 -0
  82. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/gas.py +10 -0
  83. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/gcc.py +98 -0
  84. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/gdc.py +34 -0
  85. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/gfortran.py +69 -0
  86. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/glib2.py +174 -0
  87. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/gnu_dirs.py +65 -0
  88. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/gxx.py +98 -0
  89. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/gxx.pyc +0 -0
  90. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/icc.py +31 -0
  91. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/icpc.py +30 -0
  92. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/ifort.py +42 -0
  93. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/intltool.py +78 -0
  94. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/irixcc.py +49 -0
  95. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/javaw.py +272 -0
  96. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/kde4.py +49 -0
  97. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/lua.py +19 -0
  98. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/msvc.py +650 -0
  99. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/nasm.py +13 -0
  100. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/perl.py +78 -0
  101. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/python.py +303 -0
  102. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/qt4.py +424 -0
  103. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/ruby.py +104 -0
  104. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/suncc.py +54 -0
  105. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/suncxx.py +55 -0
  106. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/tex.py +222 -0
  107. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/vala.py +215 -0
  108. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/waf_unit_test.py +79 -0
  109. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/winres.py +34 -0
  110. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/xlc.py +46 -0
  111. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Tools/xlcxx.py +46 -0
  112. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Utils.py +334 -0
  113. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/Utils.pyc +0 -0
  114. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/__init__.py +4 -0
  115. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/__init__.pyc +0 -0
  116. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/ansiterm.py +173 -0
  117. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/ansiterm.pyc +0 -0
  118. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/extras/__init__.py +4 -0
  119. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/extras/__init__.pyc +0 -0
  120. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/extras/compat15.py +223 -0
  121. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/extras/compat15.pyc +0 -0
  122. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/fixpy2.py +50 -0
  123. data/vendor/ux-trie/ux-0.1.9/.waf-1.6.8-3e3391c5f23fbabad81e6d17c63a1b1e/waflib/fixpy2.pyc +0 -0
  124. data/vendor/ux-trie/ux-0.1.9/src/bitVec.cpp +119 -0
  125. data/vendor/ux-trie/ux-0.1.9/src/bitVec.hpp +64 -0
  126. data/vendor/ux-trie/ux-0.1.9/src/bitVecTest.cpp +143 -0
  127. data/vendor/ux-trie/ux-0.1.9/src/cmdline.h +809 -0
  128. data/vendor/ux-trie/ux-0.1.9/src/rsDic.cpp +121 -0
  129. data/vendor/ux-trie/ux-0.1.9/src/rsDic.hpp +57 -0
  130. data/vendor/ux-trie/ux-0.1.9/src/ux.hpp +26 -0
  131. data/vendor/ux-trie/ux-0.1.9/src/uxMain.cpp +206 -0
  132. data/vendor/ux-trie/ux-0.1.9/src/uxMap.cpp +0 -0
  133. data/vendor/ux-trie/ux-0.1.9/src/uxMap.hpp +248 -0
  134. data/vendor/ux-trie/ux-0.1.9/src/uxMapTest.cpp +139 -0
  135. data/vendor/ux-trie/ux-0.1.9/src/uxTest.cpp +229 -0
  136. data/vendor/ux-trie/ux-0.1.9/src/uxTrie.cpp +529 -0
  137. data/vendor/ux-trie/ux-0.1.9/src/uxTrie.hpp +220 -0
  138. data/vendor/ux-trie/ux-0.1.9/src/uxUtil.cpp +92 -0
  139. data/vendor/ux-trie/ux-0.1.9/src/uxUtil.hpp +35 -0
  140. data/vendor/ux-trie/ux-0.1.9/src/wscript +43 -0
  141. data/vendor/ux-trie/ux-0.1.9/unittest_gtest.py +0 -0
  142. data/vendor/ux-trie/ux-0.1.9/unittest_gtest.pyc +0 -0
  143. data/vendor/ux-trie/ux-0.1.9/unittestt.py +166 -0
  144. data/vendor/ux-trie/ux-0.1.9/ux.pc.in +10 -0
  145. data/vendor/ux-trie/ux-0.1.9/waf +0 -0
  146. data/vendor/ux-trie/ux-0.1.9/wscript +32 -0
  147. metadata +249 -0
checksums.yaml ADDED
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: 2e58920ebfec9f72c3303f6e09b5ea99949bfbac
4
+ data.tar.gz: fdcf6ac599b7d6305c33e1370d2deb2d1e43a989
5
+ SHA512:
6
+ metadata.gz: fa023fe5a5bdc94354109873583e1b4566d78c955354e245741e3d4dde21a3853d37dd8c06aa27bc747a954d57646418e0b3d804848d6364e47e6a9328d7819e
7
+ data.tar.gz: 6bba44307fbfde6a8772d366547f8a80c578d1fe5d7cfdff033a1852b189533e7875b3c46877328ca5fa2603fd396cd4754bafd6506b183c5cc021a7280d3b67
data/.gitignore ADDED
@@ -0,0 +1,25 @@
1
+ *.gem
2
+ *.rbc
3
+ .bundle
4
+ .config
5
+ .yardoc
6
+ Gemfile.lock
7
+ InstalledFiles
8
+ _yardoc
9
+ coverage
10
+ doc/
11
+ lib/bundler/man
12
+ pkg
13
+ rdoc
14
+ spec/reports
15
+ test/tmp
16
+ test/version_tmp
17
+ tmp
18
+ *.bundle
19
+ *.so
20
+ *.o
21
+ *.a
22
+ mkmf.log
23
+
24
+ vendor/bundle
25
+ sample
data/.rspec ADDED
@@ -0,0 +1,2 @@
1
+ --color
2
+ --format progress
data/Gemfile ADDED
@@ -0,0 +1,4 @@
1
+ source 'https://rubygems.org'
2
+
3
+ # Specify your gem's dependencies in text_ux.gemspec
4
+ gemspec
data/LICENSE.txt ADDED
@@ -0,0 +1,22 @@
1
+ Copyright (c) 2014 yagince
2
+
3
+ MIT License
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining
6
+ a copy of this software and associated documentation files (the
7
+ "Software"), to deal in the Software without restriction, including
8
+ without limitation the rights to use, copy, modify, merge, publish,
9
+ distribute, sublicense, and/or sell copies of the Software, and to
10
+ permit persons to whom the Software is furnished to do so, subject to
11
+ the following conditions:
12
+
13
+ The above copyright notice and this permission notice shall be
14
+ included in all copies or substantial portions of the Software.
15
+
16
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND,
17
+ EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
18
+ MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND
19
+ NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE
20
+ LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION
21
+ OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
22
+ WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
data/README.md ADDED
@@ -0,0 +1,51 @@
1
+ # TextUx
2
+
3
+ More Succinct Trie Data structure (binding for ux-trie)
4
+ https://code.google.com/p/ux-trie/wiki/Tutorial_Japanese
5
+
6
+ ## Installation
7
+
8
+ Add this line to your application's Gemfile:
9
+
10
+ gem 'text_ux'
11
+
12
+ And then execute:
13
+
14
+ $ bundle
15
+
16
+ Or install it yourself as:
17
+
18
+ $ gem install text_ux
19
+
20
+ ## Usage
21
+
22
+ ```ruby
23
+ require "text_ux"
24
+
25
+ ux = TextUx.new
26
+ ux.build(%w( hoge foo bar baz footprint ), true)
27
+ ux.save("path/to/index")
28
+
29
+ # ux.load("path/to/index")
30
+
31
+ ux.prefix_search("hoge---foo") # => hoge
32
+ ux.prefix_search("xxx") # => nil
33
+
34
+ ux.common_prefix_search("footprint") # => ["foo", "footprint"]
35
+ ux.common_prefix_search("xxx") # => []
36
+
37
+ ux.predictive_search("fo") # => ["foo", "footprint"]
38
+ ux.predictive_search("xxx") # => []
39
+
40
+ ux.decode_key(0) # => "hoge"
41
+ ux.decode_key(10000) # => nil
42
+
43
+ ```
44
+
45
+ ## Contributing
46
+
47
+ 1. Fork it ( https://github.com/[my-github-username]/text_ux/fork )
48
+ 2. Create your feature branch (`git checkout -b my-new-feature`)
49
+ 3. Commit your changes (`git commit -am 'Add some feature'`)
50
+ 4. Push to the branch (`git push origin my-new-feature`)
51
+ 5. Create a new Pull Request
data/Rakefile ADDED
@@ -0,0 +1,18 @@
1
+ require "bundler/gem_tasks"
2
+ require "rake/extensiontask"
3
+
4
+ Rake::ExtensionTask.new "text_ux" do |ext|
5
+ ext.lib_dir = "lib/text_ux"
6
+ end
7
+
8
+ require 'rspec/core/rake_task'
9
+ RSpec::Core::RakeTask.new(:spec) do |spec|
10
+ spec.pattern = 'spec/**/*_spec.rb'
11
+ spec.rspec_opts = ['-cfs']
12
+ end
13
+
14
+ task :test do
15
+ Rake::Task["clobber"].invoke
16
+ Rake::Task["compile"].invoke
17
+ Rake::Task["spec"].invoke
18
+ end
@@ -0,0 +1,5 @@
1
+ require 'mkmf'
2
+
3
+ if have_library('ux')
4
+ create_makefile("text_ux/text_ux")
5
+ end
@@ -0,0 +1,252 @@
1
+ #include <new>
2
+ #include <ruby.h>
3
+ #include <ux/ux.hpp>
4
+ #include <vector>
5
+ #include <string>
6
+ #include <sstream>
7
+
8
+ VALUE rb_cTextUx;
9
+
10
+ static void ux_free(ux::Trie* ptr);
11
+ static VALUE ux_alloc(VALUE klass);
12
+ static VALUE ux_initialize(VALUE self);
13
+ static VALUE ux_build(int argc, VALUE *argv, VALUE self);
14
+ static VALUE ux_save(VALUE self, VALUE file_name);
15
+ static VALUE ux_load(VALUE self, VALUE file_name);
16
+
17
+ static VALUE ux_prefix_search(VALUE self, VALUE word);
18
+ static VALUE ux_common_prefix_search(int argc, VALUE *argv, VALUE self);
19
+ static VALUE ux_predictive_search(int argc, VALUE *argv, VALUE self);
20
+ static VALUE ux_decode_key(VALUE self, VALUE index);
21
+
22
+ static VALUE ux_size(VALUE self);
23
+ static VALUE ux_clear(VALUE self);
24
+ static VALUE ux_alloc_size(VALUE self);
25
+ static VALUE ux_alloc_stat(VALUE self);
26
+
27
+ extern "C" void Init_text_ux(void) {
28
+ rb_cTextUx = rb_define_class("TextUx", rb_cObject);
29
+ rb_define_alloc_func(rb_cTextUx, ux_alloc);
30
+ rb_define_private_method(rb_cTextUx, "initialize", RUBY_METHOD_FUNC(ux_initialize), 0);
31
+ rb_define_method(rb_cTextUx, "build", RUBY_METHOD_FUNC(ux_build), -1);
32
+ rb_define_method(rb_cTextUx, "save", RUBY_METHOD_FUNC(ux_save), 1);
33
+ rb_define_method(rb_cTextUx, "load", RUBY_METHOD_FUNC(ux_load), 1);
34
+
35
+ rb_define_method(rb_cTextUx, "prefix_search", RUBY_METHOD_FUNC(ux_prefix_search), 1);
36
+ rb_define_method(rb_cTextUx, "common_prefix_search", RUBY_METHOD_FUNC(ux_common_prefix_search), -1);
37
+ rb_define_method(rb_cTextUx, "predictive_search", RUBY_METHOD_FUNC(ux_predictive_search), -1);
38
+ rb_define_method(rb_cTextUx, "decode_key", RUBY_METHOD_FUNC(ux_decode_key), 1);
39
+
40
+ rb_define_method(rb_cTextUx, "size", RUBY_METHOD_FUNC(ux_size), 0);
41
+ rb_define_method(rb_cTextUx, "clear", RUBY_METHOD_FUNC(ux_clear), 0);
42
+ rb_define_method(rb_cTextUx, "alloc_size", RUBY_METHOD_FUNC(ux_alloc_size), 0);
43
+ rb_define_method(rb_cTextUx, "alloc_stat", RUBY_METHOD_FUNC(ux_alloc_stat), 0);
44
+
45
+ rb_define_const(rb_cTextUx, "DEFAULT_LIMIT", ux::LIMIT_DEFAULT);
46
+ }
47
+
48
+ static ux::Trie* getTrie(VALUE self) {
49
+ ux::Trie* p;
50
+ Data_Get_Struct(self, ux::Trie, p);
51
+ return p;
52
+ }
53
+
54
+ static void
55
+ ux_free(ux::Trie* ptr)
56
+ {
57
+ ptr->~Trie();
58
+ ruby_xfree(ptr);
59
+ }
60
+
61
+ static VALUE
62
+ ux_alloc(VALUE klass)
63
+ {
64
+ ux::Trie *ptr = new ux::Trie();
65
+ return Data_Wrap_Struct(klass, NULL, ux_free, ptr);
66
+ }
67
+
68
+ static VALUE
69
+ ux_initialize(VALUE self)
70
+ {
71
+ // TODO: 配列で辞書データを受け取る
72
+ return Qnil;
73
+ }
74
+
75
+ static VALUE
76
+ // ux_build(VALUE self, VALUE words, VALUE is_tail_ux)
77
+ ux_build(int argc, VALUE *argv, VALUE self)
78
+ {
79
+ VALUE words, is_tail_ux;
80
+
81
+ rb_scan_args(argc, argv, "11", &words, &is_tail_ux);
82
+
83
+ Check_Type(words, T_ARRAY);
84
+ if ( is_tail_ux == Qnil ) {
85
+ is_tail_ux = Qtrue;
86
+ }
87
+
88
+ std::vector<std::string> keyList;
89
+ long len = RARRAY_LEN(words);
90
+ for (long i = 0; i < len; i++) {
91
+ VALUE rb_word = rb_ary_entry(words, i);
92
+ std::string word = StringValuePtr(rb_word);
93
+ keyList.push_back(std::string(word));
94
+ }
95
+
96
+ ux::Trie* trie = getTrie(self);
97
+ trie->build(keyList, RTEST(is_tail_ux));
98
+
99
+ return self;
100
+ }
101
+
102
+ static VALUE
103
+ ux_save(VALUE self, VALUE file_name)
104
+ {
105
+ Check_Type(file_name, T_STRING);
106
+
107
+ std::string f = StringValuePtr(file_name);
108
+ ux::Trie* trie = getTrie(self);
109
+ if (trie->save(f.c_str()) != ux::Trie::SUCCESS ) {
110
+ rb_exc_raise(rb_str_new2("Save Error"));
111
+ }
112
+ return self;
113
+ }
114
+
115
+ static VALUE
116
+ ux_load(VALUE self, VALUE file_name)
117
+ {
118
+ Check_Type(file_name, T_STRING);
119
+
120
+ std::string f = StringValuePtr(file_name);
121
+ ux::Trie* trie = getTrie(self);
122
+ if (trie->load(f.c_str()) != ux::Trie::SUCCESS ) {
123
+ rb_exc_raise(rb_str_new2("Load Error"));
124
+ }
125
+ return self;
126
+ }
127
+
128
+ static VALUE
129
+ ux_prefix_search(VALUE self, VALUE word)
130
+ {
131
+ Check_Type(word, T_STRING);
132
+
133
+ std::string w = StringValuePtr(word);
134
+
135
+ ux::Trie* trie = getTrie(self);
136
+ size_t ret_len;
137
+ ux::id_t id = trie->prefixSearch(w.c_str(), w.size(), ret_len);
138
+ if ( id == ux::NOTFOUND ) {
139
+ return Qnil;
140
+ } else {
141
+ std::string key = trie->decodeKey(id);
142
+ return rb_str_new2(key.c_str());
143
+ }
144
+ }
145
+
146
+ static VALUE
147
+ ux_common_prefix_search(int argc, VALUE *argv, VALUE self)
148
+ {
149
+ VALUE word, _limit;
150
+
151
+ rb_scan_args(argc, argv, "11", &word, &_limit);
152
+
153
+ Check_Type(word, T_STRING);
154
+ std::string w = StringValuePtr(word);
155
+
156
+ size_t limit;
157
+ if (_limit == Qnil) {
158
+ limit = ux::LIMIT_DEFAULT;
159
+ } else {
160
+ limit = NUM2INT(_limit);
161
+ }
162
+
163
+ ux::Trie* trie = getTrie(self);
164
+ std::vector<ux::id_t> ret_ids;
165
+ size_t keys_size = trie->commonPrefixSearch(w.c_str(), w.size(), ret_ids, limit);
166
+ VALUE ary = rb_ary_new();
167
+ if (keys_size == 0) {
168
+ return ary;
169
+ }
170
+ for (size_t i = 0; i < keys_size; i++) {
171
+ std::string key = trie->decodeKey(ret_ids[i]);
172
+ rb_ary_push(ary, rb_str_new2(key.c_str()));
173
+ }
174
+ return ary;
175
+ }
176
+
177
+ static VALUE
178
+ ux_predictive_search(int argc, VALUE *argv, VALUE self)
179
+ {
180
+ VALUE word, _limit;
181
+
182
+ rb_scan_args(argc, argv, "11", &word, &_limit);
183
+
184
+ Check_Type(word, T_STRING);
185
+ std::string w = StringValuePtr(word);
186
+
187
+ size_t limit;
188
+ if (_limit == Qnil) {
189
+ limit = ux::LIMIT_DEFAULT;
190
+ } else {
191
+ limit = NUM2INT(_limit);
192
+ }
193
+
194
+ ux::Trie* trie = getTrie(self);
195
+ std::vector<ux::id_t> ret_ids;
196
+ size_t keys_size = trie->predictiveSearch(w.c_str(), w.size(), ret_ids, limit);
197
+ VALUE ary = rb_ary_new();
198
+ if (keys_size == 0) {
199
+ return ary;
200
+ }
201
+ for (size_t i = 0; i < keys_size; i++) {
202
+ std::string key = trie->decodeKey(ret_ids[i]);
203
+ rb_ary_push(ary, rb_str_new2(key.c_str()));
204
+ }
205
+ return ary;
206
+ }
207
+
208
+ static VALUE
209
+ ux_decode_key(VALUE self, VALUE index)
210
+ {
211
+
212
+ ux::id_t idx = NUM2INT(index);
213
+ ux::Trie* trie = getTrie(self);
214
+
215
+ if (trie->size() <= idx) {
216
+ return Qnil;
217
+ }
218
+
219
+ std::string key = trie->decodeKey(idx);
220
+ return key.empty() ? Qnil : rb_str_new2(key.c_str());
221
+ }
222
+
223
+ static VALUE
224
+ ux_size(VALUE self)
225
+ {
226
+ ux::Trie* trie = getTrie(self);
227
+ size_t size = trie->size();
228
+ return INT2NUM(size);
229
+ }
230
+ static VALUE
231
+ ux_clear(VALUE self)
232
+ {
233
+ ux::Trie* trie = getTrie(self);
234
+ trie->clear();
235
+ return Qtrue;
236
+ }
237
+ static VALUE
238
+ ux_alloc_size(VALUE self)
239
+ {
240
+ ux::Trie* trie = getTrie(self);
241
+ size_t size = trie->getAllocSize();
242
+ return INT2FIX(size);
243
+ }
244
+ static VALUE
245
+ ux_alloc_stat(VALUE self)
246
+ {
247
+ ux::Trie* trie = getTrie(self);
248
+ std::ostringstream os;
249
+ trie->stat(os);
250
+
251
+ return rb_str_new2(os.str().c_str());
252
+ }
data/lib/text_ux.rb ADDED
@@ -0,0 +1,5 @@
1
+ require "text_ux/version"
2
+ require "text_ux/text_ux"
3
+
4
+ class TextUx
5
+ end
@@ -0,0 +1,3 @@
1
+ class TextUx
2
+ VERSION = "0.0.1"
3
+ end
Binary file
@@ -0,0 +1,19 @@
1
+ require 'text_ux'
2
+
3
+ # This file was generated by the `rspec --init` command. Conventionally, all
4
+ # specs live under a `spec` directory, which RSpec adds to the `$LOAD_PATH`.
5
+ # Require this file using `require "spec_helper"` to ensure that it is only
6
+ # loaded once.
7
+ #
8
+ # See http://rubydoc.info/gems/rspec-core/RSpec/Core/Configuration
9
+ RSpec.configure do |config|
10
+ config.treat_symbols_as_metadata_keys_with_true_values = true
11
+ config.run_all_when_everything_filtered = true
12
+ config.filter_run :focus
13
+
14
+ # Run specs in random order to surface order dependencies. If you find an
15
+ # order dependency and want to debug it, you can fix the order by providing
16
+ # the seed, which is printed after each run.
17
+ # --seed 1234
18
+ config.order = 'random'
19
+ end
@@ -0,0 +1,137 @@
1
+ # -*- coding: utf-8 -*-
2
+ require 'spec_helper'
3
+
4
+ describe TextUx do
5
+ let(:ux) { TextUx.new }
6
+ let(:builded) { ux.build(%w(hoge foo bar baz footprint), true) }
7
+
8
+ describe :build do
9
+ context "配列を渡した場合" do
10
+ it { expect{ ux.build(%w(hoge foo bar), true) }.to_not raise_error }
11
+ end
12
+
13
+ context "配列以外を渡した場合" do
14
+ it { expect{ ux.build( :hoge, true ) }.to raise_error }
15
+ end
16
+
17
+ it "is_tail_uxは省略可能" do
18
+ expect{ ux.build(%w(hoge foo bar)) }.to_not raise_error
19
+ end
20
+ end
21
+
22
+ describe :save do
23
+ let(:name) { "test.ux" }
24
+
25
+ subject { builded.save(name) }
26
+
27
+ after do
28
+ File.exist?(name) and File.delete(name)
29
+ end
30
+
31
+ it "ファイルに保存される" do
32
+ expect(subject).to be builded
33
+ expect(File.exist?(name)).to be true
34
+ end
35
+ end
36
+
37
+ describe :load do
38
+ let(:name) { "spec/fixtures/test.ux" }
39
+
40
+ subject { ux.load(name) }
41
+
42
+ it { expect(subject.prefix_search("hoge----foo")).to eq("hoge") }
43
+
44
+ context "loadに失敗した場合" do
45
+ it "例外がraiseされる" do
46
+ expect{ ux.load("hoge") }.to raise_error
47
+ end
48
+ end
49
+ end
50
+
51
+ describe :prefix_search do
52
+
53
+ context "結果がある場合" do
54
+ it "一致するキーが取得できる" do
55
+ expect(builded.prefix_search("hogeはfoo")).to eq("hoge")
56
+ end
57
+ end
58
+
59
+ context "結果がない場合" do
60
+ it { expect(builded.prefix_search("XXX")).to be_nil }
61
+ end
62
+ end
63
+
64
+
65
+ describe :common_prefix_search do
66
+
67
+ context "結果がある場合" do
68
+ it "一致するキーが全て取得できる" do
69
+ expect(builded.common_prefix_search("footprint")).to match_array(%w(foo footprint))
70
+ end
71
+ end
72
+
73
+ context "結果がない場合" do
74
+ it { expect(builded.common_prefix_search("XXX")).to be_empty }
75
+ end
76
+
77
+ context "limitを指定した場合" do
78
+ it "一致した結果からlimit以内の数だけ取得できる" do
79
+ expect(builded.common_prefix_search("footprint", 1)).to match_array(%w(foo))
80
+ end
81
+ end
82
+ end
83
+
84
+ describe :predictive_search do
85
+
86
+ context "結果がある場合" do
87
+ it "一致するキーが全て取得できる" do
88
+ expect(builded.predictive_search("fo")).to match_array(%w(foo footprint))
89
+ end
90
+ end
91
+
92
+ context "結果がない場合" do
93
+ it { expect(builded.predictive_search("XXX")).to be_empty }
94
+ end
95
+
96
+ context "limitを指定した場合" do
97
+ it "一致した結果からlimit以内の数だけ取得できる" do
98
+ expect(builded.predictive_search("fo", 1)).to match_array(%w(foo))
99
+ end
100
+ end
101
+ end
102
+
103
+ describe :decode_key do
104
+ context "結果がある場合" do
105
+ it "一致するキーが取得できる" do
106
+ expect(builded.decode_key(0)).to eq("hoge")
107
+ end
108
+ end
109
+
110
+ context "結果がない場合" do
111
+ it { expect(builded.decode_key(100000)).to be nil }
112
+ end
113
+ end
114
+
115
+ describe :size do
116
+ it { expect(builded.size).to eq(5) }
117
+ end
118
+ describe :clear do
119
+ it "空になる" do
120
+ expect(builded.clear).to be true
121
+ expect(builded.size).to eq(0)
122
+ end
123
+ end
124
+ describe :alloc_size do
125
+ it { expect(builded.alloc_size).to be >= 0 }
126
+ end
127
+ describe :alloc_stat do
128
+ it { expect(builded.alloc_stat).to_not be_empty }
129
+ end
130
+
131
+ describe :constants do
132
+ describe "DEFAULT_LIMIT" do
133
+ it { expect(TextUx::DEFAULT_LIMIT).to be_a Numeric }
134
+ end
135
+ end
136
+ end
137
+