OTGrammar_ex_NoCoda.cpp 2.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263
  1. /* OTGrammar_ex_NoCoda.cpp
  2. *
  3. * Copyright (C) 1997-2005,2007,2009,2011,2012,2015-2018 Paul Boersma
  4. *
  5. * This code is free software; you can redistribute it and/or modify
  6. * it under the terms of the GNU General Public License as published by
  7. * the Free Software Foundation; either version 2 of the License, or (at
  8. * your option) any later version.
  9. *
  10. * This code is distributed in the hope that it will be useful, but
  11. * WITHOUT ANY WARRANTY; without even the implied warranty of
  12. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
  13. * See the GNU General Public License for more details.
  14. *
  15. * You should have received a copy of the GNU General Public License
  16. * along with this work. If not, see <http://www.gnu.org/licenses/>.
  17. */
  18. #include "OTGrammar.h"
  19. autoOTGrammar OTGrammar_create_NoCoda_grammar () {
  20. try {
  21. OTGrammarCandidate candidate;
  22. OTGrammarTableau tableau;
  23. OTGrammarConstraint constraint;
  24. autoOTGrammar me = Thing_new (OTGrammar);
  25. my constraints = NUMvector <structOTGrammarConstraint> (1, my numberOfConstraints = 2);
  26. constraint = & my constraints [1];
  27. constraint -> name = Melder_dup (U"N\\s{O}C\\s{ODA}");
  28. constraint -> ranking = 100.0;
  29. constraint -> plasticity = 1.0;
  30. constraint = & my constraints [2];
  31. constraint -> name = Melder_dup (U"P\\s{ARSE}");
  32. constraint -> ranking = 90.0;
  33. constraint -> plasticity = 1.0;
  34. my tableaus = NUMvector <structOTGrammarTableau> (1, my numberOfTableaus = 2);
  35. tableau = & my tableaus [1];
  36. tableau -> input = Melder_dup (U"pat");
  37. tableau -> candidates = NUMvector <structOTGrammarCandidate> (1, tableau -> numberOfCandidates = 2);
  38. candidate = & tableau -> candidates [1];
  39. candidate -> output = Melder_dup (U"pa");
  40. candidate -> marks = INTVECzero (candidate -> numberOfConstraints = 2);
  41. candidate -> marks [2] = 1;
  42. candidate = & tableau -> candidates [2];
  43. candidate -> output = Melder_dup (U"pat");
  44. candidate -> marks = INTVECzero (candidate -> numberOfConstraints = 2);
  45. candidate -> marks [1] = 1;
  46. tableau = & my tableaus [2];
  47. tableau -> input = Melder_dup (U"pa");
  48. tableau -> candidates = NUMvector <structOTGrammarCandidate> (1, tableau -> numberOfCandidates = 1);
  49. candidate = & tableau -> candidates [1];
  50. candidate -> output = Melder_dup (U"pa");
  51. candidate -> marks = INTVECzero (candidate -> numberOfConstraints = 2);
  52. OTGrammar_checkIndex (me.get());
  53. OTGrammar_newDisharmonies (me.get(), 0.0);
  54. return me;
  55. } catch (MelderError) {
  56. Melder_throw (U"NoCoda grammar not created.");
  57. }
  58. }
  59. /* End of file OTGrammar_ex_NoCoda.cpp */