<commit_before>#!/usr/bin/ruby

require "knj/autoload"
include Knj::Php

rgettext_argv = []
skipnext = false

ofn = nil

count = 0
ARGV.each do |value|
	if skipnext
		skipnext = false
	else
		skipnext = false
		
		if value == "-o"
			ofn = ARGV[count + 1]
			skipnext = true
		elsif value == "--debug"
			$debug = true
		else
			rgettext_argv << value
		end
		
		count += 1
	end
end

if !ofn
	die "No output filename defined.\n"
end

def debug(str)
	if $debug
		print str + "\n"
	end
end

rgettext_cmd = "rgettext " + rgettext_argv.join(" ")
debug "Command: " + rgettext_cmd

output = %x[#{rgettext_cmd}]

debug "Output filename: " + ofn

File.open(ofn, "a") do |file|
	file.print(output)
end

debug "Output:\n" + output<commit_msg>Made it compatible with ruby1.9.1 on Ubuntu.<commit_after>#!/usr/bin/env ruby1.9.1

require "knj/autoload"
include Knj::Php

rgettext_argv = []
skipnext = false

ofn = nil

count = 0
ARGV.each do |value|
	if skipnext
		skipnext = false
	else
		skipnext = false
		
		if value == "-o"
			ofn = ARGV[count + 1]
			skipnext = true
		elsif value == "--debug"
			$debug = true
		else
			rgettext_argv << value
		end
		
		count += 1
	end
end

if !ofn
	die "No output filename defined.\n"
end

def debug(str)
	if $debug
		print str + "\n"
	end
end

Knj::Php.print_r(ENV)
exit

rgettext_cmd = "ruby1.9.1 /usr/lib/ruby/1.9.1/gettext/tools/rgettext.rb " + rgettext_argv.join(" ")
debug "Command: " + rgettext_cmd

output = %x[#{rgettext_cmd}]

debug "Output filename: " + ofn

File.open(ofn, "a") do |file|
	file.print(output)
end

debug "Output:\n" + output
{'fraction_non_alphanumeric': 0.13806206459784673, 'fraction_numerical': 0.011399620012666244, 'mean_word_length': 3.202127659574468, 'pattern_counts': {'":': 0, '<': 7, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '188284', 'n_tokens_mistral': 710, 'n_tokens_neox': 647, 'n_words': 171}