Class: FreeLing::Analyzer::FreelingDefault

Inherits:
Object
  • Object
show all
Defined in:
lib/freeling/analyzer/freeling_default.rb

Constant Summary collapse

LOCAL_ANALYZE_PATH =
"/usr/local/bin/analyzer"
USR_ANALYZE_PATH =
"/usr/bin/analyzer"
LOCAL_ANALYZE_CLIENT_PATH =
"/usr/local/bin/analyzer_client"
USR_ANALYZE_CLIENT_PATH =
"/usr/bin/analyzer_client"
LOCAL_FREELING_SHARE_PATH =
"/usr/local/share/freeling"
USR_FREELING_SHARE_PATH =
"/usr/share/freeling"

Class Method Summary collapse

Instance Method Summary collapse

Class Method Details

.analyzer_client_pathObject



17
18
19
# File 'lib/freeling/analyzer/freeling_default.rb', line 17

def analyzer_client_path
  self.new.analyzer_client_path
end

.analyzer_pathObject



13
14
15
# File 'lib/freeling/analyzer/freeling_default.rb', line 13

def analyzer_path
  self.new.analyzer_path
end

.freeling_pathObject



22
23
24
# File 'lib/freeling/analyzer/freeling_default.rb', line 22

def freeling_path
  self.new.freeling_path
end

.language_configObject



26
27
28
# File 'lib/freeling/analyzer/freeling_default.rb', line 26

def language_config
  self.new.language_config
end

Instance Method Details

#analyzer_client_pathObject



49
50
51
52
53
54
55
56
57
# File 'lib/freeling/analyzer/freeling_default.rb', line 49

def analyzer_client_path
  if File.exists? LOCAL_ANALYZE_CLIENT_PATH
    LOCAL_ANALYZE_CLIENT_PATH
  elsif File.exists? USR_ANALYZE_CLIENT_PATH
    USR_ANALYZE_CLIENT_PATH
  else
    raise_error(:analyze_client)
  end
end

#analyzer_pathObject



39
40
41
42
43
44
45
46
47
# File 'lib/freeling/analyzer/freeling_default.rb', line 39

def analyzer_path
  if File.exists? LOCAL_ANALYZE_PATH
    LOCAL_ANALYZE_PATH
  elsif File.exists? USR_ANALYZE_PATH
    USR_ANALYZE_PATH
  else
    raise_error(:analyze)
  end
end

#freeling_pathObject



60
61
62
63
64
65
66
67
68
# File 'lib/freeling/analyzer/freeling_default.rb', line 60

def freeling_path
  if Dir.exists? LOCAL_FREELING_SHARE_PATH
    LOCAL_FREELING_SHARE_PATH
  elsif Dir.exists? USR_FREELING_SHARE_PATH
    USR_FREELING_SHARE_PATH
  else
    raise_error(:freeling)
  end
end

#language_configObject



31
32
33
34
35
36
37
# File 'lib/freeling/analyzer/freeling_default.rb', line 31

def language_config
  if freeling_path.instance_of? String
    File.join(freeling_path, "config")
  else
    raise_error(:analyze)
  end
end

#raise_error(type) ⇒ Object



70
71
72
# File 'lib/freeling/analyzer/freeling_default.rb', line 70

def raise_error(type)
  raise "#{type} is not installed."
end