Ruby string -> toCharArray


#1

Hello,
I get fallowing error:

$ jruby jr.rb
jr.rb:33: for method tokenizer expected [[C, int, int]; got:
[java.lang.String,j
ava.lang.Integer,java.lang.Integer]; error: argument type mismatch
(TypeError)

It is caused by this code (commented fragemts in Java):

#String line = bufReader.readLine();
#…

char[] cs = line.toCharArray();

cs = String.new(“The import statement can be used to import a Java
Class.”)

char[] cs = line.toCharArray();

Tokenizer tokenizer = TOKENIZER_FACTORY.tokenizer(cs,0,cs.length);

tokenizer = tokenizer_factory.tokenizer(cs, 0, cs.length) # this line 33
tokens = tokenizer.tokenize()

How to modify that code to pass?

Cheers,
Tomasz Bak

PS There is the full code:

jr.rb

=begin

based on
http://alias-i.com/lingpipe/demos/tutorial/posTags/src/RunMedPost.java

$ jruby jr.rb
jr.rb:33: for method tokenizer expected [[C, int, int]; got:
[java.lang.String,j
ava.lang.Integer,java.lang.Integer]; error: argument type mismatch
(TypeError)

=end

require ‘java’
require ‘lingpipe-3.6.0’ #
http://alias-i.com/lingpipe/web/downloadJarOrDistro.html

include_class ‘com.aliasi.hmm.HiddenMarkovModel’
include_class ‘com.aliasi.hmm.HmmDecoder’
include_class ‘com.aliasi.hmm.TagWordLattice’

include_class ‘com.aliasi.symbol.SymbolTable’

include_class ‘com.aliasi.tokenizer.Tokenizer’
include_class ‘com.aliasi.tokenizer.TokenizerFactory’
include_class ‘com.aliasi.tokenizer.RegExTokenizerFactory’

include_class ‘com.aliasi.util.ScoredObject’
include_class ‘com.aliasi.util.Streams’
include_class ‘com.aliasi.util.Strings’

include_class ‘java.io.BufferedReader’
include_class ‘java.io.FileInputStream’
include_class ‘java.io.InputStreamReader’
include_class ‘java.io.IOException’
include_class ‘java.io.ObjectInputStream’

include_class ‘java.util.Arrays’

#estimator = HmmCharLmEstimator.new(8,256,8.0)
#parser = MedPostPosParser.new
#parser.setHandler(estimator)

tokenizer_factory = RegExTokenizerFactory.new("(-|’|\d|\p{L})+|\S")

#String line = bufReader.readLine();
#…

char[] cs = line.toCharArray();

cs = String.new(“The import statement can be used to import a Java
Class.”)

char[] cs = line.toCharArray();

Tokenizer tokenizer = TOKENIZER_FACTORY.tokenizer(cs,0,cs.length);

tokenizer = tokenizer_factory.tokenizer(cs, 0, cs.length)
tokens = tokenizer.tokenize()

puts “Success!”