EditDistanceTable.h 3.9 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394
  1. #ifndef _EditDistanceTable_h_
  2. #define _EditDistanceTable_h_
  3. /* EditDistanceTable.h
  4. *
  5. * Copyright (C) 2012,2015-2017 David Weenink
  6. *
  7. * This code is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License as published by
  9. * the Free Software Foundation; either version 2 of the License, or (at
  10. * your option) any later version.
  11. *
  12. * This code is distributed in the hope that it will be useful, but
  13. * WITHOUT ANY WARRANTY; without even the implied warranty of
  14. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
  15. * General Public License for more details.
  16. *
  17. * You should have received a copy of the GNU General Public License
  18. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  19. */
  20. #include "Strings_extensions.h"
  21. #include "TableOfReal.h"
  22. #define WARPING_fromLeft 1
  23. #define WARPING_fromBelow 2
  24. #define WARPING_fromDiag 4
  25. #include "EditDistanceTable_def.h"
  26. autoWarpingPath WarpingPath_create (integer length);
  27. // Search the path for the corresponding axis value. If path is horizontal/vertical
  28. // ivar1 and ivar2 will not be equal. The return value is the length of the path segment (ivar2-ivar1 +1)
  29. integer WarpingPath_getColumnsFromRowIndex (WarpingPath me, integer irow, integer *icol1, integer *icol2);
  30. integer WarpingPath_getRowsFromColumnIndex (WarpingPath me, integer icol, integer *irow1, integer *irow2);
  31. autoEditCostsTable EditCostsTable_create (integer targetAlphabetSize, integer sourceAlphabetSize);
  32. /* The insertion, deletion and substitution costs are specified in this table
  33. * 1..n-2 target symbols (target alphabet)
  34. * 1..m-2 source symbols (source alphabet)
  35. * row n-1 and col m-1 specify no-match symbols
  36. * cells [n][1..m-1] specify insertion costs
  37. * cells [1..n-1][m] specify deletion costs
  38. * cell [n-1][m-1] no-match target == no-match source
  39. * cell [n][m] no-match target != no-match source
  40. */
  41. void EditCostsTable_setDefaultCosts (EditCostsTable me, double insertionCosts, double deletionCosts, double substitutionCosts);
  42. integer EditCostsTable_getTargetIndex (EditCostsTable me, conststring32 symbol);
  43. integer EditCostsTable_getSourceIndex (EditCostsTable me, conststring32 symbol);
  44. double EditCostsTable_getInsertionCost (EditCostsTable me, conststring32 symbol);
  45. void EditCostsTable_setInsertionCosts (EditCostsTable me, conststring32 targets, double cost);
  46. void EditCostsTable_setOthersCosts (EditCostsTable me, double insertionCosts, double deletionCost, double substitutionCost_equal, double substitutionCost_unequal);
  47. double EditCostsTable_getOthersCost (EditCostsTable me, int type);
  48. double EditCostsTable_getDeletionCost (EditCostsTable me, conststring32 symbol);
  49. void EditCostsTable_setDeletionCosts (EditCostsTable me, conststring32 sources, double cost);
  50. double EditCostsTable_getSubstitutionCost (EditCostsTable me, conststring32 symbol, conststring32 replacement);
  51. void EditCostsTable_setSubstitutionCosts (EditCostsTable me, conststring32 targets, conststring32 sources, double cost);
  52. autoTableOfReal EditCostsTable_to_TableOfReal (EditCostsTable me);
  53. autoEditDistanceTable EditDistanceTable_create (Strings target, Strings source);
  54. autoEditDistanceTable EditDistanceTable_createFromCharacterStrings (const char32 chars1 [], const char32 chars2 []);
  55. void EditDistanceTable_draw (EditDistanceTable me, Graphics graphics, int iformat, int precision, double angle);
  56. void EditDistanceTable_drawEditOperations (EditDistanceTable me, Graphics graphics);
  57. void EditDistanceTable_setDefaultCosts (EditDistanceTable me, double insertionCosts, double deletionCosts, double substitutionCosts);
  58. void EditDistanceTable_findPath (EditDistanceTable me, autoTableOfReal *directions);
  59. void EditDistanceTable_setEditCosts (EditDistanceTable me, EditCostsTable thee);
  60. autoTableOfReal EditDistanceTable_to_TableOfReal_directions (EditDistanceTable me);
  61. autoTableOfReal EditDistanceTable_to_TableOfReal (EditDistanceTable me);
  62. #endif /* _EditDistanceTable_h_ */