Exemplo n.º 1
0
// Fills the complement of the radius of the trail with minus infties.
// The return value true means success. Failure means that during the fill,
// we intersected the outside of the quasidiagonal area.
// In this case, the operation is not finished.
bool borderDetailedAlignMatrix( AlignMatrix& alignMatrix, const Trail& trail, int radius )
{
  int huBookSize = alignMatrix.size();
  int enBookSize = alignMatrix.otherSize();

  int huPos, enPos;
  for ( huPos=0; huPos<huBookSize; ++huPos )
  {
    int rowStart = alignMatrix.rowStart(huPos);
    int rowEnd   = alignMatrix.rowEnd(huPos);
    for ( enPos=rowStart; enPos<rowEnd; ++enPos )
    {
      alignMatrix.cell(huPos,enPos) = outsideOfRadiusValue;
    }
  }

  // We seriously use the fact that many-to-zero segments are subdivided into one-to-zero segments.
  // Inside setBox, an exception is thrown if we try to write outside the quasidiagonal.
  // If we catch such an exception, it means that the quasidiagonal is not thick enough.
  // In this case, we abandon the whole align, just to be sure.
  try
  {
    for ( int i=0; i<trail.size(); ++i )
    {
      setBox( alignMatrix, trail[i].first, trail[i].second, radius, insideOfRadiusValue );
    }
  }
  catch ( const char* errorType )
  {
    massert( std::string(errorType) == "out of quasidiagonal" )
    return false;
  }

  bool verify = true;
  if (verify)
  {
    int numberOfEvaluatedItems(0);
    for ( huPos=0; huPos<huBookSize; ++huPos )
    {
      int rowStart = alignMatrix.rowStart(huPos);
      int rowEnd   = alignMatrix.rowEnd(huPos);
      for ( enPos=rowStart; enPos<rowEnd; ++enPos )
      {
        if (alignMatrix[huPos][enPos]==insideOfRadiusValue)
        {
          ++numberOfEvaluatedItems;
        }
      }
    }

    std::cerr << numberOfEvaluatedItems << " items inside the border." << std::endl;
  }

  return true;
}
Exemplo n.º 2
0
// A bit of an abuse of the fact that Trail and BisentenceList are typedef'd to the same structure.
double scoreTrailOrBisentenceList( const Trail& trailAuto, const Trail& trailHand )
{
  int score = countIntersectionOfTrails( trailAuto, trailHand );

  std::cerr << trailAuto.size()-score << " misaligned out of " << trailHand.size() << " correct items, "
    << trailAuto.size() << " bets." << std::endl;

  std::cerr << "Precision: " << 1.0*score/trailAuto.size() 
    << ", Recall: " << 1.0*score/trailHand.size() << std::endl;

  double ratio = 1.0*(trailAuto.size()-score)/trailAuto.size();
  return ratio;
}
Exemplo n.º 3
0
void trailToBisentenceList( const Trail& bestTrail,
                            BisentenceList& bisentenceList )
{
  bisentenceList.clear();

  int trailSize = bestTrail.size();

  for ( int pos=0; pos<trailSize-1; ++pos )
  {
    if ( oneToOne(bestTrail,pos) )
    {
      bisentenceList.push_back(bestTrail  [pos]);
    }
  }
}
Exemplo n.º 4
0
void DrawTrail(const Trail& tr, const Graph& g)
{
  if (tr.empty())
  {
    return;
  }

  int prev = tr[0];

  for (unsigned int i = 1; i < tr.size(); i++)
  {
    const GraphEdge& edge = g.GetEdge(tr[i], prev);
    prev = tr[i];
    DrawEdge(edge, g);
  }
}