@Override public R compare( T[] specific_, T[] general_) throws Exception { Alignment< T > alignment = aligner.align( specific_, general_ ); R result = scorer.scoreAlignment( alignment ); return result; }
/** * generate the result (score, label, etc.) for the given alignment using * GreedyAlignmentScorer * * @param alignment_ * @return */ public EntailmentResult scoreAlignment(Alignment<String> alignment_) { return scorer.scoreAlignment(alignment_); }
/** * allows client to access aligner used by this comparator * * @param specific_ * @param general_ * @return * @throws Exception */ public Alignment< T > alignArrays( T[] specific_, T[] general_ ) throws Exception { return aligner.align( specific_, general_ ); }
/** * trivial implementation: * -- run each type of comparator over all constituents * -- keep a set of scores for each comparison made * @param specific_ A View presumed to represent elements of a more specific text * @param general_ A View presumed to represent elements of a more general text * @return an alignment between the two Views */ public ViewAlignment align( View specific_, View general_ ) { ViewAlignment viewAlignment = new ViewAlignment(); for( Constituent h: general_.getConstituents() ) { for ( Constituent t: specific_.getConstituents() ) { for ( ConstituentComparator cptr : m_constituentComparators ) { Result r = cptr.compare( t, h ); viewAlignment.addResult( t, h, r ); } } } return viewAlignment; }
/** * generate a score (Result) for an alignment. * * @param alignment_ * @return */ public R scoreAlignment( Alignment< T > alignment_ ) { return scorer.scoreAlignment( alignment_ ); }
private void initialize(ResourceManager rm_, Comparator<String, EntailmentResult> comparator) throws IOException { ResourceManager fullRm = new SimConfigurator().getConfig(rm_); double threshold = fullRm.getDouble(SimConfigurator.LLM_ENTAILMENT_THRESHOLD.key); tokenizer = new IllinoisTokenizer(); this.comparator = comparator; filter = new WordListFilter(fullRm); neAligner = new Aligner<String, EntailmentResult>(new NEComparator(), filter); aligner = new Aligner<String, EntailmentResult>(comparator, filter); scorer = new GreedyAlignmentScorer<String>(threshold); }
@Override public R compare( T[] specific_, T[] general_) throws Exception { Alignment< T > alignment = aligner.align( specific_, general_ ); R result = scorer.scoreAlignment( alignment ); return result; }
/** * determines best lexical level match of two arrays of Name Entity using * NESim. * * @param ne1_ * @param ne2_ * @return * @throws Exception */ public Alignment<String> alignNEStringArrays(String[] ne1_, String[] ne2_) throws Exception { return neAligner.align(ne1_, ne2_); }
/** * trivial implementation: * -- run each type of comparator over all constituents * -- keep a set of scores for each comparison made * @param specific_ Text view, typically longer * @param general_ Hypothesis view, typically shorter */ public ViewAlignment align( View specific_, View general_ ) { ViewAlignment viewAlignment = new ViewAlignment(); for( Constituent h: general_.getConstituents() ) { for ( Constituent t: specific_.getConstituents() ) { for ( ConstituentComparator cptr : m_constituentComparators ) { Result r = cptr.compare( t, h ); viewAlignment.addResult( t, h, r ); } } } return viewAlignment; }
/** * generate a score (Result) for an alignment. * * @param alignment_ * @return */ public R scoreAlignment( Alignment< T > alignment_ ) { return scorer.scoreAlignment( alignment_ ); }
double sentenceScore = scorer.scoreAlignment(sentenceAlignment).getScore(); double neScore = scorer.scoreAlignment(neAlignment).getScore();
/** * allows client to access aligner used by this comparator * * @param specific_ * @param general_ * @return * @throws Exception */ public Alignment< T > alignArrays( T[] specific_, T[] general_ ) throws Exception { return aligner.align( specific_, general_ ); }
/** * generate a lexical alignment using the comparator specified at * construction, and the * * * @param textTokens_ * @param hypTokens_ * @return * @throws Exception */ public Alignment<String> alignStringArrays(String[] textTokens_, String[] hypTokens_) throws Exception { return aligner.align(textTokens_, hypTokens_); }