Skip to content

Commit

Permalink
Updated marisa to 0.2.6
Browse files Browse the repository at this point in the history
  • Loading branch information
bendangelo committed Sep 17, 2024
1 parent fa68836 commit 5ae70a1
Show file tree
Hide file tree
Showing 155 changed files with 6,237 additions and 45,164 deletions.
10 changes: 10 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,11 @@
.DS_Store
/.bundle/
/.yardoc
/_yardoc/
/coverage/
/doc/
/pkg/
/spec/reports/
/tmp/
*.gem
.byebug_history
44 changes: 21 additions & 23 deletions Gemfile.lock
Original file line number Diff line number Diff line change
@@ -1,39 +1,37 @@
PATH
remote: .
specs:
melisa (0.2.2)
melisa (0.2.6)

GEM
remote: https://rubygems.org/
specs:
byebug (3.4.2)
columnize (~> 0.8)
debugger-linecache (~> 1.2)
slop (~> 3.6)
columnize (0.8.9)
debugger-linecache (1.2.0)
diff-lcs (1.2.5)
rake (10.3.2)
rspec (3.1.0)
rspec-core (~> 3.1.0)
rspec-expectations (~> 3.1.0)
rspec-mocks (~> 3.1.0)
rspec-core (3.1.4)
rspec-support (~> 3.1.0)
rspec-expectations (3.1.1)
byebug (11.1.3)
diff-lcs (1.5.1)
rake (13.2.1)
rspec (3.13.0)
rspec-core (~> 3.13.0)
rspec-expectations (~> 3.13.0)
rspec-mocks (~> 3.13.0)
rspec-core (3.13.1)
rspec-support (~> 3.13.0)
rspec-expectations (3.13.3)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.1.0)
rspec-mocks (3.1.1)
rspec-support (~> 3.1.0)
rspec-support (3.1.0)
slop (3.6.0)
rspec-support (~> 3.13.0)
rspec-mocks (3.13.1)
diff-lcs (>= 1.2.0, < 2.0)
rspec-support (~> 3.13.0)
rspec-support (3.13.1)

PLATFORMS
ruby

DEPENDENCIES
bundler (~> 1.7)
bundler (~> 2.0)
byebug
melisa!
rake (~> 10.3)
rake (~> 13.0)
rspec (~> 3.1)

BUNDLED WITH
2.5.18
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
Melisa is a Ruby gem that wraps the very efficient [Marisa Trie C++ library](https://pypi.python.org/pypi/marisa-trie/). See also Marisa Trie's [README](http://marisa-trie.googlecode.com/svn/trunk/docs/readme.en.html).
Melisa is a Ruby gem that wraps the very efficient [Marisa Trie C++ library](https://github.com/s-yata/marisa-trie). See also Marisa Trie's [README](https://www.s-yata.jp/marisa-trie/docs/readme.en.html).

A "trie" is a useful data structure for storing strings, especially ngrams.

Expand Down
2 changes: 2 additions & 0 deletions Rakefile
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
require "bundler/gem_tasks"
task :default => :spec
4 changes: 2 additions & 2 deletions bin/melisa
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,6 @@ if ARGV.size > 0 && available_commands.include?(ARGV.first.downcase)
else
$stderr.puts "USAGE: melisa COMMAND [options]"
$stderr.puts "Commands: #{available_commands}"
$stderr.puts "See http://marisa-trie.googlecode.com/svn/trunk/docs/readme.en.html"
$stderr.puts "See https://github.com/s-yata/marisa-trie"
exit -1
end
end
59 changes: 47 additions & 12 deletions ext/extconf.rb
Original file line number Diff line number Diff line change
Expand Up @@ -2,35 +2,70 @@
require "fileutils"

def sys(cmd)
puts " -- #{cmd}"
puts " -- Running command: #{cmd}"
unless ret = xsystem(cmd)
raise "#{cmd} failed, please report issue on https://github.com/wordtreefoundation/melisa"
raise <<-ERROR
***************************************************************************************
Error: Command `#{cmd}` failed.
Please ensure the following:
1. You have all necessary build tools installed (e.g., make, g++, etc.).
2. The command can be run in your environment.
3. If this error persists, please report it along with the full error output here:
https://github.com/wordtreefoundation/melisa/issues
***************************************************************************************
ERROR
end
ret
end

if `which make`.strip.empty?
STDERR.puts "\n\n"
STDERR.puts "***************************************************************************************"
STDERR.puts "*************** make required (apt-get install make build-essential) =( ***************"
STDERR.puts "***************************************************************************************"
exit(1)
def check_command_exists(command)
if `which #{command}`.strip.empty?
STDERR.puts <<-ERROR
***************************************************************************************
Error: `#{command}` is required but not installed.
You can install it by running:
apt-get install make build-essential
On macOS, you may need to run:
xcode-select --install
Please install the required tool and try again.
***************************************************************************************
ERROR
exit(1)
end
end

MARISA_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "marisa-0.2.4"))
# Check if essential commands are available
check_command_exists("make")
check_command_exists("g++")

MARISA_ROOT = File.expand_path(File.join(File.dirname(__FILE__), "marisa-trie-0.2.6"))
PREFIX = File.expand_path(File.join(File.dirname(__FILE__), "pkg"))

# Magic incantation that lets the linker see the installed marisa lib
# Ensure linker sees the installed marisa lib
$LDFLAGS << " -Wl,-rpath,#{File.join(PREFIX, "lib")}"

# Build Marisa Trie from source
FileUtils.cd(MARISA_ROOT) do
sys "./configure --enable-sse3 --prefix='#{PREFIX}'"
sys "autoreconf -i"
sys "./configure --enable-native-code --prefix='#{PREFIX}'"
sys "make"
sys "make install"
end

# Update flags to avoid potential security issues
$CFLAGS.sub!('-Werror=format-security', '')
$CXXFLAGS.sub!('-Werror=format-security', '')
$CFLAGS << " -I#{File.join(PREFIX, 'include')}"
$CPPFLAGS << " -I#{File.join(PREFIX, 'include')}"
$CXXFLAGS << " -I#{File.join(PREFIX, 'include')}"
$LDFLAGS << " -L#{File.join(PREFIX, 'lib')} -lmarisa"

# Create makefile for marisa
create_makefile("marisa")
Binary file removed ext/marisa-0.2.4.tar.gz
Binary file not shown.
1 change: 0 additions & 1 deletion ext/marisa-0.2.4/AUTHORS

This file was deleted.

Loading

0 comments on commit 5ae70a1

Please sign in to comment.