Top Level Namespace

Defined Under Namespace

Modules: MeCab Classes: MiniPortile

Instance Method Summary collapse

Methods included from MeCab::Heavy::Extension::Tagger

included

Instance Method Details

#cook_internal(name, version, url, patches = []) ⇒ Object


12
13
14
15
16
17
18
19
# File 'ext/mecab/extconf.rb', line 12

def cook_internal(name, version, url, patches = [])
  recipe = MiniPortile.new(name, version)
  recipe.files = [url]
  recipe.configure_options += %w[--with-charset=utf8 --disable-shared --enable-static CXX='g++ -fPIC' CC='gcc -fPIC']
  recipe.patch_files += patches.map{|f| File.expand_path(f, __dir__)} unless patches.empty?
  recipe.cook
  recipe.activate
end

#cook_mecabObject


21
22
23
# File 'ext/mecab/extconf.rb', line 21

def cook_mecab
  cook_internal('mecab', '0.996', 'https://mecab.googlecode.com/files/mecab-0.996.tar.gz')
end

#cook_naist_jdicObject


25
26
27
28
29
# File 'ext/mecab/extconf.rb', line 25

def cook_naist_jdic
  cook_internal('mecab-naist-jdic', '0.6.3b-20111013',
                'http://jaist.dl.sourceforge.jp/naist-jdic/53500/mecab-naist-jdic-0.6.3b-20111013.tar.gz',
                %w[patch/prefix.patch])
end

#processor_countObject


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
# File 'ext/mecab/parallel_make.rb', line 2

def processor_count
  os_name = RbConfig::CONFIG["target_os"]
  if os_name =~ /mingw|mswin/
    require 'win32ole'
    result = WIN32OLE.connect("winmgmts://").
      ExecQuery("select NumberOfLogicalProcessors from Win32_Processor")
    result.to_enum.collect(&:NumberOfLogicalProcessors).reduce(:+)
  elsif File.readable?("/proc/cpuinfo")
    IO.read("/proc/cpuinfo").scan(/^processor/).size
  elsif File.executable?("/usr/bin/hwprefs")
    IO.popen("/usr/bin/hwprefs thread_count").read.to_i
  elsif File.executable?("/usr/sbin/psrinfo")
    IO.popen("/usr/sbin/psrinfo").read.scan(/^.*on-*line/).size
  elsif File.executable?("/usr/sbin/ioscan")
    IO.popen("/usr/sbin/ioscan -kC processor") do |out|
      out.read.scan(/^.*processor/).size
    end
  elsif File.executable?("/usr/sbin/pmcycles")
    IO.popen("/usr/sbin/pmcycles -m").read.count("\n")
  elsif File.executable?("/usr/sbin/lsdev")
    IO.popen("/usr/sbin/lsdev -Cc processor -S 1").read.count("\n")
  elsif File.executable?("/usr/sbin/sysconf") and os_name =~ /irix/i
    IO.popen("/usr/sbin/sysconf NPROC_ONLN").read.to_i
  elsif File.executable?("/usr/sbin/sysctl")
    IO.popen("/usr/sbin/sysctl -n hw.ncpu").read.to_i
  elsif File.executable?("/sbin/sysctl")
    IO.popen("/sbin/sysctl -n hw.ncpu").read.to_i
  else
    1
  end
end