cppjieba_rb 0.4.1 → 0.4.4
Sign up to get free protection for your applications and to get access to all the features.
- checksums.yaml +4 -4
- data/.editorconfig +21 -0
- data/.github/workflows/linting.yml +30 -0
- data/.github/workflows/release.yml +42 -0
- data/.github/workflows/tests.yml +47 -0
- data/.gitignore +1 -0
- data/.rubocop.yml +45 -0
- data/.ruby-version +1 -0
- data/.yamllint +35 -0
- data/CHANGELOG.md +17 -0
- data/Gemfile +11 -0
- data/README.md +5 -5
- data/Rakefile +16 -7
- data/cppjieba_rb.gemspec +46 -33
- data/ext/cppjieba/.github/workflows/cmake.yml +52 -0
- data/ext/cppjieba/.github/workflows/stale-issues.yml +24 -0
- data/ext/cppjieba/.gitmodules +3 -0
- data/ext/cppjieba/{ChangeLog.md → CHANGELOG.md} +50 -1
- data/ext/cppjieba/CMakeLists.txt +11 -14
- data/ext/cppjieba/LICENSE +20 -0
- data/ext/cppjieba/README.md +9 -18
- data/ext/cppjieba/deps/limonp/.github/workflows/cmake.yml +43 -0
- data/ext/cppjieba/deps/limonp/.gitignore +9 -0
- data/ext/cppjieba/deps/limonp/CHANGELOG.md +160 -0
- data/ext/cppjieba/deps/limonp/CMakeLists.txt +61 -0
- data/ext/cppjieba/deps/limonp/LICENSE +20 -0
- data/ext/cppjieba/deps/limonp/README.md +38 -0
- data/ext/cppjieba/deps/limonp/{LocalVector.hpp → include/limonp/LocalVector.hpp} +3 -3
- data/ext/cppjieba/deps/limonp/{Logging.hpp → include/limonp/Logging.hpp} +17 -3
- data/ext/cppjieba/deps/limonp/{StringUtil.hpp → include/limonp/StringUtil.hpp} +31 -10
- data/ext/cppjieba/deps/limonp/test/CMakeLists.txt +8 -0
- data/ext/cppjieba/deps/limonp/test/demo.cpp +40 -0
- data/ext/cppjieba/deps/limonp/test/testdata/1.conf +5 -0
- data/ext/cppjieba/deps/limonp/test/testdata/StdExtension.data +3 -0
- data/ext/cppjieba/deps/limonp/test/testdata/dict.gbk +50 -0
- data/ext/cppjieba/deps/limonp/test/testdata/dict.utf8 +50 -0
- data/ext/cppjieba/deps/limonp/test/testdata/io_testfile +2 -0
- data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.0.1.utf8 +93 -0
- data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.0.utf8 +93 -0
- data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.1.utf8 +67 -0
- data/ext/cppjieba/deps/limonp/test/testdata/jieba.dict.2.utf8 +64 -0
- data/ext/cppjieba/deps/limonp/test/unittest/CMakeLists.txt +30 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TArgvContext.cpp +16 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TCastFloat.cpp +19 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TClosure.cpp +85 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TColorPrint.cpp +20 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TConfig.cpp +17 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TLocalVector.cpp +41 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TLogging.cpp +12 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TStdExtension.cpp +95 -0
- data/ext/cppjieba/deps/limonp/test/unittest/TStringUtil.cpp +183 -0
- data/ext/cppjieba/include/cppjieba/DictTrie.hpp +9 -0
- data/ext/cppjieba/include/cppjieba/Jieba.hpp +4 -0
- data/ext/cppjieba/include/cppjieba/Trie.hpp +27 -1
- data/ext/cppjieba/test/CMakeLists.txt +4 -3
- data/ext/cppjieba/test/unittest/CMakeLists.txt +16 -7
- data/ext/cppjieba_rb/extconf.rb +11 -6
- data/ext/cppjieba_rb/internal.cc +1 -1
- data/lib/cppjieba_rb/segment.rb +4 -1
- data/lib/cppjieba_rb/version.rb +3 -1
- data/lib/cppjieba_rb.rb +12 -5
- data/test/test_keyword.rb +8 -8
- data/test/test_segment.rb +14 -10
- data/test/test_stop_word_filter.rb +5 -3
- data/test/test_tagging.rb +5 -2
- metadata +63 -140
- data/.travis.yml +0 -30
- data/ext/cppjieba/.travis.yml +0 -21
- data/ext/cppjieba/README_EN.md +0 -115
- data/ext/cppjieba/appveyor.yml +0 -32
- data/ext/cppjieba/deps/CMakeLists.txt +0 -1
- data/ext/cppjieba/deps/gtest/CMakeLists.txt +0 -5
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-death-test.h +0 -283
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-message.h +0 -230
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h +0 -1421
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-param-test.h.pump +0 -487
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-printers.h +0 -796
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-spi.h +0 -232
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-test-part.h +0 -176
- data/ext/cppjieba/deps/gtest/include/gtest/gtest-typed-test.h +0 -259
- data/ext/cppjieba/deps/gtest/include/gtest/gtest.h +0 -2155
- data/ext/cppjieba/deps/gtest/include/gtest/gtest_pred_impl.h +0 -358
- data/ext/cppjieba/deps/gtest/include/gtest/gtest_prod.h +0 -58
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-death-test-internal.h +0 -308
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-filepath.h +0 -210
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-internal.h +0 -1226
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-linked_ptr.h +0 -233
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h +0 -4822
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util-generated.h.pump +0 -301
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-param-util.h +0 -619
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-port.h +0 -1788
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-string.h +0 -350
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h +0 -968
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-tuple.h.pump +0 -336
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h +0 -3330
- data/ext/cppjieba/deps/gtest/include/gtest/internal/gtest-type-util.h.pump +0 -296
- data/ext/cppjieba/deps/gtest/src/.deps/gtest-all.Plo +0 -681
- data/ext/cppjieba/deps/gtest/src/.deps/gtest_main.Plo +0 -509
- data/ext/cppjieba/deps/gtest/src/.dirstamp +0 -0
- data/ext/cppjieba/deps/gtest/src/gtest-all.cc +0 -48
- data/ext/cppjieba/deps/gtest/src/gtest-death-test.cc +0 -1234
- data/ext/cppjieba/deps/gtest/src/gtest-filepath.cc +0 -380
- data/ext/cppjieba/deps/gtest/src/gtest-internal-inl.h +0 -1038
- data/ext/cppjieba/deps/gtest/src/gtest-port.cc +0 -746
- data/ext/cppjieba/deps/gtest/src/gtest-printers.cc +0 -356
- data/ext/cppjieba/deps/gtest/src/gtest-test-part.cc +0 -110
- data/ext/cppjieba/deps/gtest/src/gtest-typed-test.cc +0 -110
- data/ext/cppjieba/deps/gtest/src/gtest.cc +0 -4898
- data/ext/cppjieba/deps/limonp/BlockingQueue.hpp +0 -49
- data/ext/cppjieba/deps/limonp/BoundedBlockingQueue.hpp +0 -67
- data/ext/cppjieba/deps/limonp/BoundedQueue.hpp +0 -65
- data/ext/cppjieba/deps/limonp/FileLock.hpp +0 -74
- data/ext/cppjieba/deps/limonp/Md5.hpp +0 -411
- data/ext/cppjieba/deps/limonp/MutexLock.hpp +0 -51
- data/ext/cppjieba/deps/limonp/Thread.hpp +0 -44
- data/ext/cppjieba/deps/limonp/ThreadPool.hpp +0 -86
- data/ext/cppjieba/test/demo.cpp +0 -80
- /data/ext/cppjieba/deps/{gtest/src/.deps/.dirstamp → limonp/.gitmodules} +0 -0
- /data/ext/cppjieba/deps/limonp/{ArgvContext.hpp → include/limonp/ArgvContext.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{Closure.hpp → include/limonp/Closure.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{Colors.hpp → include/limonp/Colors.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{Condition.hpp → include/limonp/Condition.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{Config.hpp → include/limonp/Config.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{ForcePublic.hpp → include/limonp/ForcePublic.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{NonCopyable.hpp → include/limonp/NonCopyable.hpp} +0 -0
- /data/ext/cppjieba/deps/limonp/{StdExtension.hpp → include/limonp/StdExtension.hpp} +0 -0
- /data/ext/cppjieba/deps/{gtest/src/gtest_main.cc → limonp/test/unittest/gtest_main.cpp} +0 -0
checksums.yaml
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
---
|
2
2
|
SHA256:
|
3
|
-
metadata.gz:
|
4
|
-
data.tar.gz:
|
3
|
+
metadata.gz: c764f86e12cb63776f9dd2b2ce8b0704de2a766dbb43a361808aec12425c20a9
|
4
|
+
data.tar.gz: f0d87212f847cba89b41dfbaa44f82acc61b34cae18b65ef2e44b8baa2c4462b
|
5
5
|
SHA512:
|
6
|
-
metadata.gz:
|
7
|
-
data.tar.gz:
|
6
|
+
metadata.gz: f2ce849f65fd618b3cb62833de4c43f0771985f2282df99dc10ae61261c92ba13391b7725ce452a1e5a5519cc4477e349e38e5f443d52bd17bc17a278acbcf21
|
7
|
+
data.tar.gz: 56660f21c9981bdd7180337674435b9c56d0238187c445ffd2b8146c750da6d319b94d8834ab47c5230d9b8726aac907409ceaeaf870302921cd5ada78331b50
|
data/.editorconfig
ADDED
@@ -0,0 +1,21 @@
|
|
1
|
+
# Top-level setting to indicate this is the root .editorconfig file
|
2
|
+
root = true
|
3
|
+
|
4
|
+
# Default settings for all files
|
5
|
+
[*]
|
6
|
+
# Enforce LF (\n) as the line ending across all files for consistency
|
7
|
+
end_of_line = lf
|
8
|
+
# Ensure every file ends with a newline
|
9
|
+
insert_final_newline = true
|
10
|
+
charset = utf-8
|
11
|
+
# Use spaces for indentation (as opposed to tabs)
|
12
|
+
indent_style = space
|
13
|
+
# Set the width of a single indentation level to 2 spaces
|
14
|
+
indent_size = 2
|
15
|
+
trim_trailing_whitespace = true
|
16
|
+
|
17
|
+
# Specific settings for Markdown files
|
18
|
+
[*.md]
|
19
|
+
# Disable trimming of trailing whitespace in Markdown files,
|
20
|
+
# important for Markdown syntax where trailing spaces can be meaningful
|
21
|
+
trim_trailing_whitespace = false
|
@@ -0,0 +1,30 @@
|
|
1
|
+
name: Linting
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
linting:
|
14
|
+
runs-on: ubuntu-latest
|
15
|
+
|
16
|
+
steps:
|
17
|
+
- name: Checkout repository
|
18
|
+
uses: actions/checkout@v4
|
19
|
+
|
20
|
+
- name: Lint YAML
|
21
|
+
run: yamllint .
|
22
|
+
|
23
|
+
- name: Set up Ruby and install dependencies
|
24
|
+
uses: ruby/setup-ruby@v1
|
25
|
+
with:
|
26
|
+
# uses .ruby-version implicitly
|
27
|
+
bundler-cache: true
|
28
|
+
|
29
|
+
- name: Lint Ruby code
|
30
|
+
run: bundle exec rubocop
|
@@ -0,0 +1,42 @@
|
|
1
|
+
name: Release
|
2
|
+
|
3
|
+
on:
|
4
|
+
workflow_dispatch: # allow repo collaborators to publish gem
|
5
|
+
|
6
|
+
permissions:
|
7
|
+
contents: write # required for `rake release` to push the release tag
|
8
|
+
id-token: write # required for workflow to publish gem
|
9
|
+
|
10
|
+
jobs:
|
11
|
+
release:
|
12
|
+
if: github.ref == 'refs/heads/master'
|
13
|
+
runs-on: ubuntu-latest
|
14
|
+
|
15
|
+
steps:
|
16
|
+
- name: Checkout repository
|
17
|
+
uses: actions/checkout@v4
|
18
|
+
with:
|
19
|
+
submodules: recursive # cppjieba requires a vendor library in a submodule
|
20
|
+
|
21
|
+
# required to run `rake release`.
|
22
|
+
- name: Setup Ruby and install dependencies
|
23
|
+
uses: ruby/setup-ruby@v1
|
24
|
+
with:
|
25
|
+
# setup-ruby implicitly uses .ruby-version
|
26
|
+
bundler-cache: true
|
27
|
+
|
28
|
+
# Run `rake release` to create git tag and push to repository based on `lib/cppjieba_rb/version.rb`.
|
29
|
+
# Then publish the new gem via trusted publishing
|
30
|
+
# Read more on https://guides.rubygems.org/trusted-publishing/releasing-gems/
|
31
|
+
- name: Publish gem
|
32
|
+
uses: rubygems/release-gem@v1
|
33
|
+
|
34
|
+
- name: Create GitHub Release
|
35
|
+
run: |
|
36
|
+
VERSION="v$(bundle exec rake version)"
|
37
|
+
|
38
|
+
gh release create \
|
39
|
+
$VERSION \
|
40
|
+
--verify-tag \
|
41
|
+
--generate-notes \
|
42
|
+
--latest
|
@@ -0,0 +1,47 @@
|
|
1
|
+
name: Tests
|
2
|
+
|
3
|
+
on:
|
4
|
+
pull_request:
|
5
|
+
push:
|
6
|
+
branches:
|
7
|
+
- master
|
8
|
+
|
9
|
+
permissions:
|
10
|
+
contents: read
|
11
|
+
|
12
|
+
jobs:
|
13
|
+
tests:
|
14
|
+
strategy:
|
15
|
+
matrix:
|
16
|
+
# Tests a range of Ruby to ensure the gem works.
|
17
|
+
# Keeps 2.7 for a while but support EOL Ruby for a year in general
|
18
|
+
# Read more about Ruby EOL date on https://endoflife.date/ruby
|
19
|
+
ruby-version:
|
20
|
+
- '2.7'
|
21
|
+
- '3.0'
|
22
|
+
- '3.1'
|
23
|
+
- '3.2'
|
24
|
+
- '3.3'
|
25
|
+
- head
|
26
|
+
# test distributions up to 4 years
|
27
|
+
runner:
|
28
|
+
- ubuntu-latest
|
29
|
+
- ubuntu-20.04
|
30
|
+
fail-fast: false # allow contributors understand failure builds
|
31
|
+
|
32
|
+
runs-on: ${{ matrix.runner }}
|
33
|
+
|
34
|
+
steps:
|
35
|
+
- name: Checkout repository
|
36
|
+
uses: actions/checkout@v4
|
37
|
+
with:
|
38
|
+
submodules: recursive # cppjieba requires a vendor library in a submodule
|
39
|
+
|
40
|
+
- name: Set up Ruby and install dependencies
|
41
|
+
uses: ruby/setup-ruby@v1
|
42
|
+
with:
|
43
|
+
ruby-version: ${{ matrix.ruby-version }}
|
44
|
+
bundler-cache: true
|
45
|
+
|
46
|
+
- name: Run tests
|
47
|
+
run: bundle exec rake test
|
data/.gitignore
CHANGED
data/.rubocop.yml
ADDED
@@ -0,0 +1,45 @@
|
|
1
|
+
# merge the default 'Exclude' key with ours
|
2
|
+
inherit_mode:
|
3
|
+
merge:
|
4
|
+
- Exclude
|
5
|
+
|
6
|
+
require:
|
7
|
+
- rubocop-minitest
|
8
|
+
- rubocop-performance
|
9
|
+
- rubocop-rake
|
10
|
+
|
11
|
+
AllCops:
|
12
|
+
NewCops: enable
|
13
|
+
StyleGuideBaseURL: https://rubystyle.guide
|
14
|
+
TargetRubyVersion: 2.7
|
15
|
+
SuggestExtensions: false
|
16
|
+
|
17
|
+
Exclude:
|
18
|
+
- bin/**/*
|
19
|
+
- tmp/**/*
|
20
|
+
|
21
|
+
Bundler/OrderedGems:
|
22
|
+
Include:
|
23
|
+
- '*.gemspec'
|
24
|
+
|
25
|
+
|
26
|
+
# Enforce single quotes in the gem
|
27
|
+
Style/StringLiterals:
|
28
|
+
Enabled: true
|
29
|
+
EnforcedStyle: single_quotes
|
30
|
+
|
31
|
+
Style/HashSyntax:
|
32
|
+
EnforcedStyle: no_mixed_keys # consistent hash syntax
|
33
|
+
EnforcedShorthandSyntax: consistent # enforce explicit hash syntax
|
34
|
+
|
35
|
+
# Project maximum code line length
|
36
|
+
Layout/LineLength:
|
37
|
+
Max: 120
|
38
|
+
|
39
|
+
# Exclude test files from BlockComments check
|
40
|
+
Style/BlockComments:
|
41
|
+
Exclude:
|
42
|
+
- 'test/**/*'
|
43
|
+
|
44
|
+
Metrics/MethodLength:
|
45
|
+
Max: 100
|
data/.ruby-version
ADDED
@@ -0,0 +1 @@
|
|
1
|
+
3.3
|
data/.yamllint
ADDED
@@ -0,0 +1,35 @@
|
|
1
|
+
extends: default
|
2
|
+
|
3
|
+
locale: en_US.UTF-8
|
4
|
+
|
5
|
+
# ignored directories
|
6
|
+
ignore: |
|
7
|
+
.git/
|
8
|
+
|
9
|
+
rules:
|
10
|
+
octal-values: enable
|
11
|
+
|
12
|
+
document-start: disable
|
13
|
+
document-end: disable
|
14
|
+
|
15
|
+
# allow 120 characters in a line
|
16
|
+
line-length:
|
17
|
+
max: 120
|
18
|
+
level: error
|
19
|
+
|
20
|
+
indentation:
|
21
|
+
spaces: 2
|
22
|
+
indent-sequences: true
|
23
|
+
|
24
|
+
# allow one space indent
|
25
|
+
comments:
|
26
|
+
level: error
|
27
|
+
min-spaces-from-content: 1
|
28
|
+
|
29
|
+
# disallow boolean values to avoid surprise
|
30
|
+
truthy:
|
31
|
+
level: error
|
32
|
+
|
33
|
+
# github workflows uses `on` as trigger
|
34
|
+
ignore: |
|
35
|
+
.github/workflows/*.yml
|
data/CHANGELOG.md
ADDED
@@ -0,0 +1,17 @@
|
|
1
|
+
## [0.4.3](https://github.com/erickguan/cppjieba_rb/compare/v0.4.2...v0.4.4) ##
|
2
|
+
|
3
|
+
### Added
|
4
|
+
|
5
|
+
- Linting with rubocop.
|
6
|
+
|
7
|
+
### Changed
|
8
|
+
|
9
|
+
- Requires Ruby 2.7.
|
10
|
+
- Update `cppjieba` to `v5.3.2`. `cppejieba` supports more compliers. But no functions changes.
|
11
|
+
- Testing with GitHub Action.
|
12
|
+
- Releases and publishes the gem with Trust Publishing on GitHub Action.
|
13
|
+
|
14
|
+
### Fixed
|
15
|
+
|
16
|
+
|
17
|
+
### Removed
|
data/Gemfile
CHANGED
@@ -1,3 +1,14 @@
|
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
1
3
|
source 'https://rubygems.org'
|
2
4
|
|
3
5
|
gemspec
|
6
|
+
|
7
|
+
gem 'rubocop', '~> 1.66.1', require: false
|
8
|
+
gem 'rubocop-minitest', '~> 0.36.0', require: false
|
9
|
+
gem 'rubocop-performance', '~> 1.22.1', require: false
|
10
|
+
gem 'rubocop-rake', '~> 0.6.0', require: false
|
11
|
+
|
12
|
+
gem 'minitest', '~> 5.14'
|
13
|
+
gem 'rake', '~> 13'
|
14
|
+
gem 'rake-compiler', '~> 1.1'
|
data/README.md
CHANGED
@@ -2,10 +2,6 @@
|
|
2
2
|
|
3
3
|
[![Gem Version](https://badge.fury.io/rb/cppjieba_rb.svg)](http://badge.fury.io/rb/cppjieba_rb)
|
4
4
|
|
5
|
-
[![Build Status](https://travis-ci.com/erickguan/cppjieba_rb.svg?branch=master)](https://travis-ci.com/erickguan/cppjieba_rb)
|
6
|
-
|
7
|
-
[![Patreon](https://img.shields.io/badge/back_on-patreon-red.svg)](https://www.patreon.com/fantasticfears)
|
8
|
-
|
9
5
|
Ruby bindings for [Cppjieba](https://github.com/yanyiwu/cppjieba). C++11 required. (gcc 4.8+)
|
10
6
|
|
11
7
|
The TRIE tree has high memory usage. For default dict, it uses ~120 MB memory.
|
@@ -14,7 +10,11 @@ The TRIE tree has high memory usage. For default dict, it uses ~120 MB memory.
|
|
14
10
|
|
15
11
|
Add this line to your application's Gemfile:
|
16
12
|
|
17
|
-
gem 'cppjieba_rb'
|
13
|
+
gem 'cppjieba_rb', require: false
|
14
|
+
|
15
|
+
Or pin a version:
|
16
|
+
|
17
|
+
gem 'cppjieba_rb', '~> 0.4.2', require: false
|
18
18
|
|
19
19
|
Or install it as:
|
20
20
|
|
data/Rakefile
CHANGED
@@ -1,9 +1,11 @@
|
|
1
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
require 'bundler/gem_tasks'
|
2
4
|
require 'rake/testtask'
|
3
5
|
require 'rake/extensiontask'
|
4
6
|
|
5
|
-
gem = Gem::Specification.load(File.dirname(__FILE__)
|
6
|
-
Rake::ExtensionTask.new(
|
7
|
+
gem = Gem::Specification.load("#{File.dirname(__FILE__)}/cppjieba_rb.gemspec")
|
8
|
+
Rake::ExtensionTask.new('cppjieba_rb', gem) do |ext|
|
7
9
|
ext.lib_dir = File.join('lib', 'cppjieba_rb')
|
8
10
|
end
|
9
11
|
|
@@ -12,9 +14,16 @@ Rake::Task[:test].prerequisites << :compile
|
|
12
14
|
Rake::TestTask.new do |t|
|
13
15
|
t.libs << 'test'
|
14
16
|
end
|
15
|
-
|
17
|
+
|
18
|
+
desc 'clean compile files'
|
16
19
|
task :clean_compile do
|
17
|
-
system
|
18
|
-
system
|
20
|
+
system 'rm -r tmp'
|
21
|
+
system 'rm lib/*.bundle'
|
22
|
+
end
|
23
|
+
|
24
|
+
task default: :test
|
25
|
+
|
26
|
+
desc 'report gem version'
|
27
|
+
task :version do
|
28
|
+
print CppjiebaRb::VERSION
|
19
29
|
end
|
20
|
-
task :default => :test
|
data/cppjieba_rb.gemspec
CHANGED
@@ -1,50 +1,63 @@
|
|
1
|
-
#
|
2
|
-
|
1
|
+
# frozen_string_literal: true
|
2
|
+
|
3
|
+
lib = File.expand_path('lib', __dir__)
|
3
4
|
$LOAD_PATH.unshift(lib) unless $LOAD_PATH.include?(lib)
|
4
5
|
require 'cppjieba_rb/version'
|
5
6
|
|
7
|
+
# Recursive function to handle submodules and their submodules
|
8
|
+
def collect_submodule_files(spec, relative_path, submodule_dir)
|
9
|
+
Dir.chdir(submodule_dir) do
|
10
|
+
submodule_relative_path = submodule_dir.gsub(relative_path, '')
|
11
|
+
|
12
|
+
# Get all files in the current submodule
|
13
|
+
submodule_files = `git ls-files -z`.split("\x0")
|
14
|
+
submodule_files.each do |file|
|
15
|
+
# Add the relative submodule path to each file
|
16
|
+
spec.files << File.join(submodule_relative_path, file)
|
17
|
+
end
|
18
|
+
|
19
|
+
# Recurse into any submodules of the current submodule
|
20
|
+
nested_submodules = `git submodule foreach --quiet pwd`.split("\n")
|
21
|
+
nested_submodules.each do |nested_submodule_path|
|
22
|
+
if (ENV['OS'] == 'Windows_NT') && nested_submodule_path.start_with?('/')
|
23
|
+
# Handle cygwin-style paths on Windows
|
24
|
+
nested_submodule_path = nested_submodule_path[1..] # Remove leading slash
|
25
|
+
nested_submodule_path.insert(1, ':') # Add drive letter (e.g., C:)
|
26
|
+
end
|
27
|
+
collect_submodule_files(spec, relative_path, nested_submodule_path)
|
28
|
+
end
|
29
|
+
end
|
30
|
+
end
|
31
|
+
|
6
32
|
Gem::Specification.new do |spec|
|
7
33
|
spec.name = 'cppjieba_rb'
|
8
34
|
spec.version = CppjiebaRb::VERSION
|
9
35
|
spec.authors = ['Erick Guan']
|
10
|
-
spec.email = ['
|
36
|
+
spec.email = ['erickguanst@gmail.com']
|
11
37
|
spec.summary = 'cppjieba binding for ruby'
|
12
38
|
spec.description = 'cppjieba binding for ruby. Mainly used by Discourse.'
|
13
|
-
spec.homepage = 'https://github.com/
|
14
|
-
spec.required_ruby_version = '>=2.
|
15
|
-
spec.license
|
39
|
+
spec.homepage = 'https://github.com/erickguan/cppjieba_rb'
|
40
|
+
spec.required_ruby_version = '>=2.7.0'
|
41
|
+
spec.license = 'MIT'
|
16
42
|
spec.extensions = ['ext/cppjieba_rb/extconf.rb']
|
17
43
|
|
18
|
-
spec.files
|
19
|
-
relative_path = File.expand_path(
|
20
|
-
|
21
|
-
|
22
|
-
|
23
|
-
|
24
|
-
|
25
|
-
|
26
|
-
|
27
|
-
|
28
|
-
# Make the submodule path relative
|
29
|
-
submodule_path = submodule_path.gsub(/#{relative_path}/i, '')
|
30
|
-
# issue git ls-files in submodule's directory
|
31
|
-
submodule_files = `git ls-files -z`.split("\x0")
|
32
|
-
|
33
|
-
# prepend the submodule path to create relative file paths
|
34
|
-
submodule_files_paths = submodule_files.map do |filename|
|
35
|
-
File.join(submodule_path, filename)
|
36
|
-
end
|
37
|
-
# add relative paths to gem.files
|
38
|
-
spec.files += submodule_files_paths
|
44
|
+
spec.files = `git ls-files -z`.split("\x0")
|
45
|
+
relative_path = "#{File.expand_path(__dir__)}/"
|
46
|
+
|
47
|
+
# Collect files from all submodules recursively
|
48
|
+
submodules = `git submodule foreach --quiet pwd`.split("\n")
|
49
|
+
submodules.each do |submodule_path|
|
50
|
+
if (ENV['OS'] == 'Windows_NT') && submodule_path.start_with?('/')
|
51
|
+
# Handle cygwin-style paths on Windows
|
52
|
+
submodule_path = submodule_path[1..] # Remove leading slash
|
53
|
+
submodule_path.insert(1, ':') # Add drive letter (e.g., C:)
|
39
54
|
end
|
55
|
+
|
56
|
+
collect_submodule_files(spec, relative_path, submodule_path)
|
40
57
|
end
|
41
58
|
|
42
59
|
spec.executables = spec.files.grep(%r{^bin/}) { |f| File.basename(f) }
|
43
|
-
spec.
|
44
|
-
spec.require_paths = ['lib']
|
60
|
+
spec.require_paths = ['lib'] # to pick up the compiled shared library.
|
45
61
|
|
46
|
-
spec.
|
47
|
-
spec.add_development_dependency 'rake', '~> 13'
|
48
|
-
spec.add_development_dependency 'rake-compiler', '~> 1.1'
|
49
|
-
spec.add_development_dependency 'minitest', '~> 5.14'
|
62
|
+
spec.metadata['rubygems_mfa_required'] = 'true'
|
50
63
|
end
|
@@ -0,0 +1,52 @@
|
|
1
|
+
name: CMake
|
2
|
+
|
3
|
+
on:
|
4
|
+
push:
|
5
|
+
pull_request:
|
6
|
+
|
7
|
+
env:
|
8
|
+
# Customize the CMake build type here (Release, Debug, RelWithDebInfo, etc.)
|
9
|
+
BUILD_TYPE: Release
|
10
|
+
|
11
|
+
jobs:
|
12
|
+
build:
|
13
|
+
# The CMake configure and build commands are platform agnostic and should work equally well on Windows or Mac.
|
14
|
+
# You can convert this to a matrix build if you need cross-platform coverage.
|
15
|
+
# See: https://docs.github.com/en/free-pro-team@latest/actions/learn-github-actions/managing-complex-workflows#using-a-build-matrix
|
16
|
+
runs-on: ${{ matrix.os }}
|
17
|
+
strategy:
|
18
|
+
matrix:
|
19
|
+
os: [
|
20
|
+
ubuntu-20.04,
|
21
|
+
ubuntu-22.04,
|
22
|
+
macos-12,
|
23
|
+
macos-13,
|
24
|
+
macos-14,
|
25
|
+
windows-2019,
|
26
|
+
windows-2022,
|
27
|
+
]
|
28
|
+
cpp_version: [11, 14, 17, 20]
|
29
|
+
|
30
|
+
steps:
|
31
|
+
- name: Check out repository code
|
32
|
+
uses: actions/checkout@v2
|
33
|
+
with:
|
34
|
+
submodules: recursive
|
35
|
+
|
36
|
+
- name: Configure CMake
|
37
|
+
# Configure CMake in a 'build' subdirectory. `CMAKE_BUILD_TYPE` is only required if you are using a single-configuration generator such as make.
|
38
|
+
# See https://cmake.org/cmake/help/latest/variable/CMAKE_BUILD_TYPE.html?highlight=cmake_build_type
|
39
|
+
# run: cmake -B ${{github.workspace}}/build -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
40
|
+
run: cmake -B ${{github.workspace}}/build -DBUILD_TESTING=ON -DCMAKE_CXX_STANDARD=${{matrix.cpp_version}} -DCMAKE_BUILD_TYPE=${{env.BUILD_TYPE}}
|
41
|
+
|
42
|
+
- name: Build
|
43
|
+
# Build your program with the given configuration
|
44
|
+
# run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
45
|
+
run: cmake --build ${{github.workspace}}/build --config ${{env.BUILD_TYPE}}
|
46
|
+
|
47
|
+
- name: Test
|
48
|
+
working-directory: ${{github.workspace}}/build
|
49
|
+
# Execute tests defined by the CMake configuration.
|
50
|
+
# See https://cmake.org/cmake/help/latest/manual/ctest.1.html for more detail
|
51
|
+
run: ctest -C ${{env.BUILD_TYPE}}
|
52
|
+
|
@@ -0,0 +1,24 @@
|
|
1
|
+
name: Close Stale Issues
|
2
|
+
|
3
|
+
on:
|
4
|
+
schedule:
|
5
|
+
- cron: '0 0 * * 0' # Run weekly on Sunday at midnight
|
6
|
+
|
7
|
+
jobs:
|
8
|
+
stale:
|
9
|
+
runs-on: ubuntu-latest
|
10
|
+
permissions:
|
11
|
+
issues: write
|
12
|
+
pull-requests: write
|
13
|
+
|
14
|
+
steps:
|
15
|
+
- uses: actions/stale@v5
|
16
|
+
with:
|
17
|
+
repo-token: ${{ secrets.GITHUB_TOKEN }}
|
18
|
+
stale-issue-message: 'This issue has not been updated for over 1 year and will be marked as stale. If the issue still exists, please comment or update the issue, otherwise it will be closed after 7 days.'
|
19
|
+
close-issue-message: 'This issue has been automatically closed due to inactivity. If the issue still exists, please reopen it.'
|
20
|
+
days-before-issue-stale: 365
|
21
|
+
days-before-issue-close: 7
|
22
|
+
stale-issue-label: 'Stale'
|
23
|
+
exempt-issue-labels: 'pinned,security'
|
24
|
+
operations-per-run: 100
|
@@ -1,4 +1,53 @@
|
|
1
|
-
#
|
1
|
+
# CHANGELOG
|
2
|
+
|
3
|
+
## v5.3.2
|
4
|
+
|
5
|
+
+ removed test/demo.cpp and linked https://github.com/yanyiwu/cppjieba-demo
|
6
|
+
+ Update Demo Link in README.md
|
7
|
+
+ [github/actions] stale 1 year ago issues
|
8
|
+
+ limonp v0.9.0 -> v1.0.0
|
9
|
+
|
10
|
+
## v5.3.1
|
11
|
+
|
12
|
+
+ [cmake] fetch googletest
|
13
|
+
+ [submodules] rm test/googletest
|
14
|
+
|
15
|
+
## v5.3.0
|
16
|
+
|
17
|
+
+ [c++17,c++20] compatibility
|
18
|
+
+ limonp version 0.6.7 -> 0.9.0
|
19
|
+
|
20
|
+
## v5.2.0
|
21
|
+
|
22
|
+
+ [CI] windows-[2019,2022]
|
23
|
+
+ [googletest] v1.6.0->v1.10.0
|
24
|
+
+ [CI] ubuntu version from 20 to 22, macos version from 12 to 14
|
25
|
+
+ [CMake] mini_required 2.6->3.5 and fix CXX_VERSION variable passed from cmd
|
26
|
+
+ [CI] matrix and multi cpp version [11, 14]
|
27
|
+
|
28
|
+
## v5.1.3
|
29
|
+
|
30
|
+
+ [googletest] git submodule add googletest-1.6.0
|
31
|
+
|
32
|
+
## v5.1.2
|
33
|
+
|
34
|
+
+ [submodule:deps/limonp] upgrade to v0.6.7
|
35
|
+
|
36
|
+
## v5.1.1
|
37
|
+
|
38
|
+
+ Merged [pr-186](https://github.com/yanyiwu/cppjieba/pull/186)
|
39
|
+
|
40
|
+
## v5.1.0
|
41
|
+
|
42
|
+
+ Merged [feature: add RemoveWord api from gojieba/pull/99 #172](https://github.com/yanyiwu/cppjieba/pull/172)
|
43
|
+
|
44
|
+
## v5.0.5
|
45
|
+
|
46
|
+
+ Merged [pr-171 submodule update limonp to v0.6.6 #171](https://github.com/yanyiwu/cppjieba/pull/171)
|
47
|
+
|
48
|
+
## v5.0.4
|
49
|
+
|
50
|
+
+ Merged [pr-168 limonp as submodule #168](https://github.com/yanyiwu/cppjieba/pull/168)
|
2
51
|
|
3
52
|
## v5.0.3
|
4
53
|
|
data/ext/cppjieba/CMakeLists.txt
CHANGED
@@ -1,28 +1,25 @@
|
|
1
|
+
CMAKE_MINIMUM_REQUIRED (VERSION 3.5)
|
1
2
|
PROJECT(CPPJIEBA)
|
2
3
|
|
3
|
-
|
4
|
-
|
5
|
-
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/deps
|
4
|
+
INCLUDE_DIRECTORIES(${PROJECT_SOURCE_DIR}/deps/limonp/include
|
6
5
|
${PROJECT_SOURCE_DIR}/include)
|
7
6
|
|
8
7
|
if (CMAKE_INSTALL_PREFIX_INITIALIZED_TO_DEFAULT)
|
9
8
|
set (CMAKE_INSTALL_PREFIX "/usr/local/cppjieba" CACHE PATH "default install path" FORCE )
|
10
9
|
endif()
|
11
10
|
|
12
|
-
|
13
|
-
|
14
|
-
ADD_DEFINITIONS(-std=c++0x)
|
11
|
+
if(NOT DEFINED CMAKE_CXX_STANDARD)
|
12
|
+
set(CMAKE_CXX_STANDARD 11)
|
15
13
|
endif()
|
14
|
+
set(CMAKE_CXX_STANDARD_REQUIRED ON)
|
15
|
+
set(CMAKE_CXX_EXTENSIONS OFF)
|
16
16
|
|
17
|
-
|
18
|
-
# IF (DEFINED ENC)
|
19
|
-
# ADD_DEFINITIONS(-DCPPJIEBA_${ENC})
|
20
|
-
# ENDIF()
|
17
|
+
ADD_DEFINITIONS(-O3 -Wall -g)
|
21
18
|
|
22
|
-
ADD_SUBDIRECTORY(deps)
|
23
19
|
ADD_SUBDIRECTORY(test)
|
24
20
|
|
25
21
|
ENABLE_TESTING()
|
26
|
-
|
27
|
-
ADD_TEST(NAME ./
|
28
|
-
ADD_TEST(NAME ./
|
22
|
+
if(NOT MSVC)
|
23
|
+
ADD_TEST(NAME ./test/test.run COMMAND ./test/test.run)
|
24
|
+
ADD_TEST(NAME ./load_test COMMAND ./load_test)
|
25
|
+
endif()
|
@@ -0,0 +1,20 @@
|
|
1
|
+
The MIT License (MIT)
|
2
|
+
|
3
|
+
Copyright (c) 2013
|
4
|
+
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy of
|
6
|
+
this software and associated documentation files (the "Software"), to deal in
|
7
|
+
the Software without restriction, including without limitation the rights to
|
8
|
+
use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of
|
9
|
+
the Software, and to permit persons to whom the Software is furnished to do so,
|
10
|
+
subject to the following conditions:
|
11
|
+
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
13
|
+
copies or substantial portions of the Software.
|
14
|
+
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS
|
17
|
+
FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR
|
18
|
+
COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER
|
19
|
+
IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN
|
20
|
+
CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|