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 7017841
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 27, 20262026-05-27T22:58:00+00:00 2026-05-27T22:58:00+00:00

I’m trying to use the wordalignment in the BerkeleyAligner.jar file from http://code.google.com/p/berkeleyaligner/ in my

  • 0

I’m trying to use the wordalignment in the BerkeleyAligner.jar file from http://code.google.com/p/berkeleyaligner/ in my own java class.
I have already added the .jar file into my buildpath.

What parameters does the edu.berkeley.nlp.wordAlignment.combine.CombinedAligner take?
What does the edu.berkeley.nlp.wordAlignment.combine.CombinedAligneroutput?

What i have are 2 input files that are already sentence aligned; i.e. the sentence from line number X from the sourceFile is the same (but in a different language) as the sentence from line number X of the targetFile.

import edu.berkeley.*;
import edu.berkeley.nlp.wa.mt.Alignment;
import edu.berkeley.nlp.wa.mt.SentencePair;
public class TestAlign {

BufferedReader brSrc = new BufferedReader(new FileReader ("sourceFile"));
BufferedReader brTrg = new BufferedReader(new FileReader ("targetFile"));

String currentSrcLine;

while ((currentSrcLine = brSrc.readLine()) !=null) {
    String currentTrgLine = brTrg.readline();
    // Reads into BerkeleyAligner SentencePair format.
    SentencePair src2trg = new SentencePair(sentCounter, params.get("source"),
        Arrays.asList(srcLine.split(" ")), Arrays.asList(trgLine.split(" ")));
    // How do i call the BerkeleyAligner??
    // -What parameters does the CombinedAligner takes?
    // -What does the function/class returns?
    // I assume it returns a list of strings. 
    // Is there a class in BerkeleyAligner to read the output? 
    // Please provide some example, thank you!!
    Alignment output = edu.berkeley.nlp.wordAlignment.combine.CombinedAligner
        .something.something(currentSrcLine, currentTrgLine);
    }
}

e.g. sourceFile:

this is the first line in the textfile.
that is the second line.
foo bar likes to eat bar foo.

e.g. targetFile:

Dies ist die erste Textzeile in der Datei.
das ist die zweite Zeile.
foo bar gerne bar foo essen.
  • 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-05-27T22:58:01+00:00Added an answer on May 27, 2026 at 10:58 pm

    Actual Answer

    You just wanted to align text (from a target file and a source file), right?

    If so, after creating a sentence pair, you did not even need to put them in a CombinedAligner.

    You could get an Alignment: (SentencePair, boolean) from that. The boolean is if you want a tree alignment.

    Putting it into the constructor will generate an Alignment automatically!
    So simple!

    This is where I got the code: http://code.google.com/p/berkeleyaligner/source/browse/trunk/src/edu/berkeley/nlp/wa/mt/Alignment.java


    UPDATE

    Unfortunately, I misunderstood your question, and posted an irrelevant response.

    However, I downloaded the jar file, found CombinedAligner.class, and decompiled it.

    Here’s what I got:

    package edu.berkeley.nlp.wordAlignment.combine;

    import edu.berkeley.nlp.mt.Alignment;
    import edu.berkeley.nlp.mt.SentencePair;
    import edu.berkeley.nlp.wordAlignment.PosteriorAligner;
    import edu.berkeley.nlp.wordAlignment.WordAligner;
    import fig.basic.Fmt;
    import fig.basic.ListUtils;
    import java.util.ArrayList;
    import java.util.List;
    
    public abstract  class CombinedAligner extends PosteriorAligner {
    
        private static final long serialVersionUID = 1;
        WordAligner wa1;
        WordAligner wa2;
    
        public CombinedAligner (WordAligner, WordAligner)
        public String getName()
        public Alignment alignSentencePair(SentencePair)
        public List alignSentencePairReturnAll(SentencePair)
        public void setThreshold(int)
        abstract Alignment combineAlignments(Alignment, Alignment, SentencePair)
    
    }
    

    It seems that the Alignment class you’re using is edu.berkeley.nlp.mt.Alignment.

    Anyway, CombinedAligner is abstract, so you can’t instantiate it. And I don’t know what the .something‘s are, because there is no static method or field.

    I think that what you want, however, is alignSentencePair(SentencePair).

    To get this, you need to use a subclass of CombinedAligner, as CombinedAligner is abstract.

    So, after poking around the files, I found these subclasses:

    edu.berkeley.nlp.wordAlignment.combine.HardUnion
    edu.berkeley.nlp.wordAlignment.combine.HardIntersect
    edu.berkeley.nlp.wordAlignment.combine.SoftUnion
    edu.berkeley.nlp.wordAlignment.combine.SoftIntersect
    

    You can use these instead of CombinedAligner and insert your two sentences as a SentencePair!


    After checking, I realized that WordAligner is also abstract!

    package edu.berkeley.nlp.wordAlignment;
    

    import edu.berkeley.nlp.mt.Alignment;
    import edu.berkeley.nlp.mt.SentencePair;
    import fig.basic.LogInfo;
    import java.io.Serializable;
    import java.util.ArrayList;
    import java.util.HashMap;
    import java.util.Iterator;
    import java.util.List;
    import java.util.Map;

    public abstract class WordAligner implements Serializable {

    private static final long serialVersionUID = 1;
    protected String modelPrefix;
    
    public WordAligner ()
    public abstract String getName()
    public void setThreshold(double)
    public Alignment alignSentencePair(SentencePair)
    public Map alignSentencePairs(List)
    public Alignment thresholdAlignment(Alignment, double)
    public String getModelPrefix()
    public String toString()
    

    }

    I found a subclass, though:

    edu.berkeley.nlp.wordAlignment.IterWordAligner
    

    Unfortunately, this is still abstract.

    But there’s a subclass of IterWordAligner that isn’t:
    edu.berkeley.nlp.wordAlignment.EMWordAligner

    However, the constructor is really weird.

    public EMWordAligner (SentencePairState$Factory, Evaluator, boolean)
    

    It uses an INNER CLASS in the CONSTRUCTOR!? That’s terrible programming practice.

    WAIT…

    I found a word aligner!
    http://code.google.com/p/tdx-nlp/source/browse/trunk/pa2/java/src/cs224n/assignments/WordAlignmentTester.java?r=67

    Maybe that helps and you can resolve your problem with it.

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

Sidebar

Related Questions

I'm trying to decode HTML entries from here NYTimes.com and I cannot figure out
I am trying to understand how to use SyndicationItem to display feed which is
I want use html5's new tag to play a wav file (currently only supported
I'm trying to use string.replace('’','') to replace the dreaded weird single-quote character: ’ (aka
Basically, what I'm trying to create is a page of div tags, each has
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I have just tried to save a simple *.rtf file with some websites and
For some reason, after submitting a string like this Jack’s Spindle from a text
I am currently running into a problem where an element is coming back from
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this

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.