Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8720523
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T07:03:45+00:00 2026-06-13T07:03:45+00:00

I am getting this error: SyntaxError: hello.rb:13: syntax error, unexpected tIDENTIFIER public HelloWorld( InputStream

  • 0

I am getting this error:

SyntaxError: hello.rb:13: syntax error, unexpected tIDENTIFIER
public HelloWorld( InputStream data ) throws IOException {

The HelloWorld.rb is:

require "java"

import java.io.FileInputStream;
import java.io.InputStream;
import java.io.IOException;

import opennlp.tools.postag.POSModel;
import opennlp.tools.postag.POSTaggerME;

public class HelloWorld {
    private POSModel model;

    public HelloWorld( InputStream data ) throws IOException {
    setModel( new POSModel( data ) );
    }

    public void run( String sentence ) {
    POSTaggerME tagger = new POSTaggerME( getModel() );
    String[] words = sentence.split( "\\s+" );
    String[] tags = tagger.tag( words );
    double[] probs = tagger.probs();

    for( int i = 0; i < tags.length; i++ ) {
    System.out.println( words[i] + " => " + tags[i] + " @ " + probs[i] );
    }
    }

    private void setModel( POSModel model ) {
    this.model = model;
    }

    private POSModel getModel() {
    return this.model;
    }

    public static void main( String args[] ) throws IOException {
    if( args.length < 2 ) {
    System.out.println( "HelloWord <file> \"sentence to tag\"" );
    return;
    }

    InputStream is = new FileInputStream( args[0] );
    HelloWorld hw = new HelloWorld( is );
    is.close();

    hw.run( args[1] );
    }
}

when running ruby HelloWorld.rb "I am trying to make it work"

when I run the HelloWorld.java "I am trying to make it work" it works perfectly, of course the .java doesn’t contain the require java statement.

EDIT:

I followed the following steps.

The output for jruby -v :

jruby 1.6.7.2 (ruby-1.8.7-p357) (2012-05-01 26e08ba) (Java HotSpot(TM) 64-Bit Server VM 1.6.0_35) [darwin-x86_64-java]
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-13T07:03:46+00:00Added an answer on June 13, 2026 at 7:03 am

    JRuby is a ruby implementation in Java, this means if you want to use JRuby, you have to use the ruby syntax. You can indeed use Java objects in JRuby, but using the ruby syntax – you just can’t use Java syntax.

    For example, frame = javax.swing.JFrame.new("Window") uses JFrame, but with a ruby syntax (i.e. JFrame.new rather than new JFrame).

    And so your code would be something like:

    require 'java'
    # Require opennlp jars
    Dir.glob('**/*.jar').each do |jar|
      require jar
    end
    
    java_import 'opennlp.tools.postag.POSTaggerME'
    java_import 'opennlp.tools.postag.POSModel'
    
    class HelloWorld
      def initialize(data)
        @model = POSModel.new(data)
      end
    
      def run(sentence)
        tagger = POSTaggerME.new(@model)
        words = sentence.split
        tags = tagger.tag(words)
        probs = tagger.probs
    
        probs.each_with_index do |p,i|
          puts "#{words[i]} => #{tags[i]} @ #{p}"
        end
      end
    end
    
    stream = File.new(ARGV[0]).to_java.getInStream
    HelloWorld.new(stream).run(ARGV[1])
    

    All. ruby. code.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i'm getting this error: Parse error: syntax error, unexpected T_PRINT, expecting T_STRING in /homepages/26/d94605010/htdocs/lz/writecodeonline.com/php/index.php(190)
hello im am getting JS error : Uncaught SyntaxError: Unexpected identifier here <script type=text/javascript>
I'm getting this JavaScript error on my console: Uncaught SyntaxError: Unexpected token ILLEGAL This
I keep getting this error: SyntaxError: Unexpected token o For a v.simple piece of
I am getting the following error: Uncaught SyntaxError: Unexpected token ILLEGAL and this is
I am getting this error Uncaught SyntaxError: Unexpected token < from chrome but everything
Why am I getting this error: Uncaught SyntaxError: Unexpected token < c.b.extend.globalEval jquery-1.4.4.min.js:32 c.extend.httpData
For some reason, I'm getting this error message: Uncaught SyntaxError: Unexpected token < For
I am getting this Uncaught SyntaxError: Unexpected identifier error , Why ? I think
I'm getting a syntax error with this access query, but I can't see what

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.