<commit_before>#!/usr/bin/env ruby

# Copyright (c) 2009 - 2012 National ICT Australia Limited (NICTA).
# This software may be used and distributed solely under the terms of the MIT license (License).
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
# ------------------
#
# = oml4r-simple-example.rb
#
# == Description
#
# A very simple straightforward example of OML4R.
#

# Use the oml4r.rb from ../lib
$:.unshift "#{File.dirname(__FILE__)}/../lib"

require 'rubygems'
require 'oml4r'

# Define your own Measurement Points
class SinMP < OML4R::MPBase
  name :sin
  #channel :default

  param :label
  param :angle, :type => :int32
  param :value, :type => :double
end

class CosMP < OML4R::MPBase
  name :cos
  # channel :ch1
  # channel :default

  param :label
  param :value, :type => :double
end

# Initialise the OML4R module for your application
opts = {:appName => 'oml4rSimpleExample',
  :domain => 'foo',
  :collect => 'file:-'} # Server could also be tcp:host:port
#  
#OML4R::create_channel(:ch1, 'file:/tmp/foo.log')    

begin
  OML4R::init(ARGV, opts)
rescue OML4R::MissingArgumentException => mex
  $stderr.puts mex
  exit
end

# Now collect and inject some measurements
500.times do |i|
  sleep 0.5
  angle = 15 * i
  SinMP.inject("label_#{angle}", angle, Math.sin(angle))
  CosMP.inject("label_#{angle}", Math.cos(angle))    
end

# Don't forget to close when you are finished
OML4R::close()

# vim: sw=2<commit_msg>Inject some metadata in oml4r-simple-example.rb<commit_after>#!/usr/bin/env ruby

# Copyright (c) 2009 - 2012 National ICT Australia Limited (NICTA).
# This software may be used and distributed solely under the terms of the MIT license (License).
# You should find a copy of the License in LICENSE.TXT or at http://opensource.org/licenses/MIT.
# By downloading or using this software you accept the terms and the liability disclaimer in the License.
# ------------------
#
# = oml4r-simple-example.rb
#
# == Description
#
# A very simple straightforward example of OML4R.
#

# Use the oml4r.rb from ../lib
$:.unshift "#{File.dirname(__FILE__)}/../lib"

require 'rubygems'
require 'oml4r'

# Define your own Measurement Points
class SinMP < OML4R::MPBase
  name :sin
  #channel :default

  param :label
  param :angle, :type => :int32
  param :value, :type => :double
end

class CosMP < OML4R::MPBase
  name :cos
  # channel :ch1
  # channel :default

  param :label
  param :value, :type => :double
end

# Initialise the OML4R module for your application
opts = {:appName => 'oml4rSimpleExample',
  :domain => 'foo',
  :collect => 'file:-'} # Server could also be tcp:host:port
#  
#OML4R::create_channel(:ch1, 'file:/tmp/foo.log')    

begin
  OML4R::init(ARGV, opts)
rescue OML4R::MissingArgumentException => mex
  $stderr.puts mex
  exit
end

freq = 2.0 # Hz
inc = 15 # rad

# Now collect and inject some measurements
SinMP.inject_metadata "unit", "radian", "angle"
SinMP.inject_metadata "freq_Hz", "#{freq}"
SinMP.inject_metadata "inc_rad", "#{inc}"
CosMP.inject_metadata "freq_Hz", "#{freq}"
CosMP.inject_metadata "inc_rad", "#{inc}"
500.times do |i|
  sleep 1./freq
  angle = inc * i
  SinMP.inject("label_#{angle}", angle, Math.sin(angle))
  CosMP.inject("label_#{angle}", Math.cos(angle))    
end

# Don't forget to close when you are finished
OML4R::close()

# vim: sw=2
{'fraction_non_alphanumeric': 0.13894494090516, 'fraction_numerical': 0.01902565580859037, 'mean_word_length': 3.915014164305949, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 17, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 2, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '499866', 'n_tokens_mistral': 1229, 'n_tokens_neox': 1174, 'n_words': 381}