Class: Opener::SocialMediaClassifier

Inherits:
Object
  • Object
show all
Defined in:
lib/opener/social_media_classifier.rb,
lib/opener/social_media_classifier/version.rb

Constant Summary collapse

CORE_DIRECTORY =

Path to the directory containing all the Java source code.

File.expand_path('../../../core', __FILE__)
TMP_DIRECTORY =

Path to the local tmp/ directory.

File.expand_path('../../../tmp', __FILE__)
VERSION =
'1.0.0'

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(input, output) ⇒ SocialMediaClassifier

input filename of the set that we want to be classified. output filename. Full path or relative path (current directory.)



19
20
21
22
# File 'lib/opener/social_media_classifier.rb', line 19

def initialize(input, output)
  @input  = input
  @output = output
end

Instance Attribute Details

#inputObject

Returns the value of attribute input.



6
7
8
# File 'lib/opener/social_media_classifier.rb', line 6

def input
  @input
end

#outputObject

Returns the value of attribute output.



6
7
8
# File 'lib/opener/social_media_classifier.rb', line 6

def output
  @output
end

Instance Method Details

#classifyObject



24
25
26
27
28
29
30
31
32
33
# File 'lib/opener/social_media_classifier.rb', line 24

def classify
  command1 = "sed -i '18s/.*/@attribute category? {0,1,2,3}/' #{input}"
  command2 = "java -classpath #{CORE_DIRECTORY}/target/weka.jar weka.filters.supervised.attribute.AddClassification -serialized #{TMP_DIRECTORY}/rf_liking.model -classification  -remove-old-class -i #{input} -o #{output}.liking -c last"
  command3 = "sed -i '18s/.*/@attribute category? {0,1}/' #{input}"
  command4 = "java -classpath #{CORE_DIRECTORY}/target/weka.jar weka.filters.supervised.attribute.AddClassification -serialized #{TMP_DIRECTORY}/rf_recommendation.model -classification  -remove-old-class -i #{input} -o #{output}.recommendation -c last"
  `#{command1}`
  `#{command2}`
  `#{command3}`
  `#{command4}`
end