opener-social-media-classifier 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
@@ -0,0 +1,7 @@
1
+ ---
2
+ SHA1:
3
+ metadata.gz: b019eca18894f21da4ceebad0ec7049809df46fe
4
+ data.tar.gz: 56f7c81b4386d63fc71c06f1fb5ba161f3628260
5
+ SHA512:
6
+ metadata.gz: bdaf4dc8f7f65cd2046abf51a272c79655a9bfdf3c3a27a98d1e88530769b4af5aee726ebd7f233dfec75d9970b7b1f52547cf6097719049e6a344d81bce6754
7
+ data.tar.gz: 37da5b032ebcdf650ce417ee436d04041c7cdff09b56ef17627c35ce4baa9bfb28dd015507092a5060455b2339870701244f1892d4d318fdba5ed9193796793f
@@ -0,0 +1,85 @@
1
+ # Social Media Classifier
2
+
3
+ This repository contains the source code used for classifying Social Media.
4
+ This version classifies Facebook pages for hotels, both for liking and for recommendation
5
+ (see documentation)
6
+
7
+ ## Requirements
8
+
9
+ * Java 1.7 or newer
10
+ * Ruby 1.9.2 or newer
11
+
12
+ Development requirements:
13
+
14
+ * Bundler
15
+
16
+ ## Installation
17
+
18
+ Installing as a regular Gem:
19
+
20
+ gem install opener-social-media-classifier
21
+
22
+ Using Bundler:
23
+
24
+ gem 'opener-social-media-classifier',
25
+ :git => 'git@github.com:opener-project/social-media-classifier.git',
26
+ :branch => 'master'
27
+
28
+ Using specific install:
29
+
30
+ gem install specific_install
31
+ gem specific_install opener-social-media-classifier \
32
+ -l https://github.com/opener-project/social-media-classifier.git
33
+
34
+ ## Generate the model (required)
35
+
36
+ First make sure all the required dependencies are installed:
37
+
38
+ bundle install
39
+
40
+ Then generate the required Weka model:
41
+
42
+ bundle exec rake generate
43
+
44
+ For this you'll need to have Java 1.7. and maven.
45
+
46
+ To install them (on linux):
47
+
48
+ sudo apt-get purge openjdk*
49
+
50
+ sudo add-apt-repository ppa:webupd8team/java
51
+
52
+ sudo apt-get update
53
+
54
+ sudo apt-get install oracle-java7-installer
55
+
56
+ sudo apt-get install maven
57
+
58
+ These requirements
59
+ are verified for you before the Rake.
60
+
61
+
62
+ ## Usage
63
+
64
+ social-media-classifier input output
65
+ (produces two files <output.liking> <output.recommendation> )
66
+
67
+
68
+ ## Testing
69
+
70
+ To run the tests (which are powered by Cucumber), simply run the following:
71
+
72
+ bundle exec rake
73
+
74
+ This will take care of verifying the requirements, installing the required Java
75
+ packages and running the tests.
76
+
77
+ For more information on the available Rake tasks run the following:
78
+
79
+ bundle exec rake -T
80
+
81
+ ## Structure
82
+
83
+ This repository comes in two parts: a collection of Java source files, Weka sets and Ruby
84
+ source files. The Java code and Weka requirements can be found in the `core/` directory, everything
85
+ else will be Ruby source code.
@@ -0,0 +1,8 @@
1
+ #!/usr/bin/env ruby
2
+
3
+ require_relative '../lib/opener/social_media_classifier'
4
+
5
+ raise ArgumentError("Usage: social-media-classifier input.arff output.arff") if ARGV.count != 2
6
+ kernel = Opener::SocialMediaClassifier.new(ARGV[0], ARGV[1])
7
+
8
+ kernel.classify
Binary file
@@ -0,0 +1,35 @@
1
+ require_relative 'social_media_classifier/version'
2
+ require 'rake'
3
+
4
+ module Opener
5
+ class SocialMediaClassifier
6
+ attr_accessor :input, :output
7
+
8
+ # Path to the directory containing all the Java source code.
9
+ CORE_DIRECTORY = File.expand_path('../../../core', __FILE__)
10
+
11
+ # Path to the local tmp/ directory.
12
+ TMP_DIRECTORY = File.expand_path('../../../tmp', __FILE__)
13
+
14
+ ##
15
+ # input filename of the set that we want to be classified.
16
+ # output filename.
17
+ # Full path or relative path (current directory.)
18
+ #
19
+ def initialize(input, output)
20
+ @input = input
21
+ @output = output
22
+ end
23
+
24
+ def classify
25
+ command1 = "sed -i '18s/.*/@attribute category? {0,1,2,3}/' #{input}"
26
+ 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"
27
+ command3 = "sed -i '18s/.*/@attribute category? {0,1}/' #{input}"
28
+ 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"
29
+ `#{command1}`
30
+ `#{command2}`
31
+ `#{command3}`
32
+ `#{command4}`
33
+ end
34
+ end
35
+ end
@@ -0,0 +1,5 @@
1
+ module Opener
2
+ class SocialMediaClassifier
3
+ VERSION = '1.0.0'
4
+ end # SocialMediaClassifier
5
+ end # Opener
@@ -0,0 +1,27 @@
1
+ require File.expand_path('../lib/opener/social_media_classifier/version', __FILE__)
2
+
3
+ generated = Dir.glob('core/target/weka.jar')
4
+
5
+ Gem::Specification.new do |gem|
6
+ gem.name = 'opener-social-media-classifier'
7
+ gem.version = Opener::SocialMediaClassifier::VERSION
8
+ gem.authors = ['development@olery.com']
9
+ gem.summary = 'Opener Component for classifying Social Media.'
10
+ gem.description = gem.summary
11
+ gem.homepage = 'http://opener-project.github.com/'
12
+
13
+ gem.files = Dir.glob([
14
+ 'core/target/weka.jar',
15
+ 'lib/**/*',
16
+ '*.gemspec',
17
+ 'README.md'
18
+ ]).select { |file| File.file?(file) }
19
+
20
+ gem.executables = Dir.glob('bin/*').map { |file| File.basename(file) }
21
+
22
+ gem.add_dependency 'opener-build-tools'
23
+
24
+ gem.add_development_dependency 'rspec'
25
+ gem.add_development_dependency 'cucumber'
26
+ gem.add_development_dependency 'rake'
27
+ end
metadata ADDED
@@ -0,0 +1,106 @@
1
+ --- !ruby/object:Gem::Specification
2
+ name: opener-social-media-classifier
3
+ version: !ruby/object:Gem::Version
4
+ version: 1.0.0
5
+ platform: ruby
6
+ authors:
7
+ - development@olery.com
8
+ autorequire:
9
+ bindir: bin
10
+ cert_chain: []
11
+ date: 2014-05-20 00:00:00.000000000 Z
12
+ dependencies:
13
+ - !ruby/object:Gem::Dependency
14
+ name: opener-build-tools
15
+ requirement: !ruby/object:Gem::Requirement
16
+ requirements:
17
+ - - ">="
18
+ - !ruby/object:Gem::Version
19
+ version: '0'
20
+ type: :runtime
21
+ prerelease: false
22
+ version_requirements: !ruby/object:Gem::Requirement
23
+ requirements:
24
+ - - ">="
25
+ - !ruby/object:Gem::Version
26
+ version: '0'
27
+ - !ruby/object:Gem::Dependency
28
+ name: rspec
29
+ requirement: !ruby/object:Gem::Requirement
30
+ requirements:
31
+ - - ">="
32
+ - !ruby/object:Gem::Version
33
+ version: '0'
34
+ type: :development
35
+ prerelease: false
36
+ version_requirements: !ruby/object:Gem::Requirement
37
+ requirements:
38
+ - - ">="
39
+ - !ruby/object:Gem::Version
40
+ version: '0'
41
+ - !ruby/object:Gem::Dependency
42
+ name: cucumber
43
+ requirement: !ruby/object:Gem::Requirement
44
+ requirements:
45
+ - - ">="
46
+ - !ruby/object:Gem::Version
47
+ version: '0'
48
+ type: :development
49
+ prerelease: false
50
+ version_requirements: !ruby/object:Gem::Requirement
51
+ requirements:
52
+ - - ">="
53
+ - !ruby/object:Gem::Version
54
+ version: '0'
55
+ - !ruby/object:Gem::Dependency
56
+ name: rake
57
+ requirement: !ruby/object:Gem::Requirement
58
+ requirements:
59
+ - - ">="
60
+ - !ruby/object:Gem::Version
61
+ version: '0'
62
+ type: :development
63
+ prerelease: false
64
+ version_requirements: !ruby/object:Gem::Requirement
65
+ requirements:
66
+ - - ">="
67
+ - !ruby/object:Gem::Version
68
+ version: '0'
69
+ description: Opener Component for classifying Social Media.
70
+ email:
71
+ executables:
72
+ - social-media-classifier
73
+ extensions: []
74
+ extra_rdoc_files: []
75
+ files:
76
+ - README.md
77
+ - bin/social-media-classifier
78
+ - core/target/weka.jar
79
+ - lib/opener/social_media_classifier.rb
80
+ - lib/opener/social_media_classifier/version.rb
81
+ - social-media-classifier.gemspec
82
+ homepage: http://opener-project.github.com/
83
+ licenses: []
84
+ metadata: {}
85
+ post_install_message:
86
+ rdoc_options: []
87
+ require_paths:
88
+ - lib
89
+ required_ruby_version: !ruby/object:Gem::Requirement
90
+ requirements:
91
+ - - ">="
92
+ - !ruby/object:Gem::Version
93
+ version: '0'
94
+ required_rubygems_version: !ruby/object:Gem::Requirement
95
+ requirements:
96
+ - - ">="
97
+ - !ruby/object:Gem::Version
98
+ version: '0'
99
+ requirements: []
100
+ rubyforge_project:
101
+ rubygems_version: 2.2.2
102
+ signing_key:
103
+ specification_version: 4
104
+ summary: Opener Component for classifying Social Media.
105
+ test_files: []
106
+ has_rdoc: