From 60c3fa642b77b12e9692477b8620da172ba49019 Mon Sep 17 00:00:00 2001 From: John Maxwell Date: Tue, 28 May 2024 11:11:57 -0700 Subject: [PATCH] Make changes requested by Andy Black --- Src/LexText/ParserCore/HCLoader.cs | 3 +- Src/LexText/ParserCore/HCParser.cs | 27 ++++ Src/Transforms/Presentation/FormatCommon.xsl | 159 +++++++++++++------ 3 files changed, 136 insertions(+), 53 deletions(-) diff --git a/Src/LexText/ParserCore/HCLoader.cs b/Src/LexText/ParserCore/HCLoader.cs index 25242c9ee3..4e09cf7572 100644 --- a/Src/LexText/ParserCore/HCLoader.cs +++ b/Src/LexText/ParserCore/HCLoader.cs @@ -1159,7 +1159,8 @@ private AffixProcessAllomorph LoadAffixProcessAllomorph(IMoAffixProcess allo) IPhCode code = termUnit.CodesOS[0]; string strRep = termUnit.ClassID == PhBdryMarkerTags.kClassId ? code.Representation.BestVernacularAlternative.Text : code.Representation.VernacularDefaultWritingSystem.Text; - strRep = strRep.Trim(); + if (strRep != null) + strRep = strRep.Trim(); if (string.IsNullOrEmpty(strRep)) throw new InvalidAffixProcessException(allo, false); sb.Append(strRep); diff --git a/Src/LexText/ParserCore/HCParser.cs b/Src/LexText/ParserCore/HCParser.cs index ad025e9bdc..a1f08afd7f 100644 --- a/Src/LexText/ParserCore/HCParser.cs +++ b/Src/LexText/ParserCore/HCParser.cs @@ -235,6 +235,33 @@ public void WriteDataIssues(XElement elem) writer.WriteEndElement(); } } + foreach (IPhPhoneme phone in m_cache.LangProject.PhonologicalDataOA.PhonemeSetsOS[0].PhonemesOC) + { + foreach (IPhCode code in phone.CodesOS) + { + if (code != null && code.Representation != null) + { + var grapheme = code.Representation.BestVernacularAlternative.Text; + // Check for empty graphemes/codes whcih can cause a crash; see https://jira.sil.org/browse/LT-21589 + if (String.IsNullOrEmpty(grapheme) || grapheme == "***") + { + writer.WriteStartElement("EmptyGrapheme"); + writer.WriteElementString("Phoneme", phone.Name.BestVernacularAnalysisAlternative.Text); + writer.WriteEndElement(); + } + else + // Check for '[' and ']' which can cause a mysterious message in Try a Word + if (grapheme.Contains("[") || grapheme.Contains("]")) + { + writer.WriteStartElement("NoBracketsAsGraphemes"); + writer.WriteElementString("Grapheme", grapheme); + writer.WriteElementString("Phoneme", phone.Name.BestVernacularAnalysisAlternative.Text); + writer.WriteElementString("Bracket", grapheme); + writer.WriteEndElement(); + } + } + } + } writer.WriteEndElement(); } } diff --git a/Src/Transforms/Presentation/FormatCommon.xsl b/Src/Transforms/Presentation/FormatCommon.xsl index c0a32f8376..4e9a52c3da 100644 --- a/Src/Transforms/Presentation/FormatCommon.xsl +++ b/Src/Transforms/Presentation/FormatCommon.xsl @@ -156,69 +156,124 @@ + + + + + -
-

+

+

+ The following data issue + + + s were + + + was + + + found that may affect how the parser works. When the Hermit Crab parser uses a natural class during its synthesis process, the natural class will use the phonological features which are the intersection of the features of all the phonemes in the class while trying to see if a segment matches the natural class. The implied phonological features are shown for each class below and mean that it will match any of the predicted phonemes shown. (If the implied features field is blank, then it will match *all* phonemes.) For each of the natural classes shown below, the set of predicted phonemes is not the same as the set of actual phonemes. You will need to rework your phonological feature system and the assignment of these features to phonemes to make it be correct. +

+ + + + + + + + +
+ + + + + + + +
+ +
+ [ + + ] +
+
+ + + + + + + + + + + + + +
Implied Features + +
Predicted Phonemes + +
Actual Phonemes + +
+
+ +
+ +
+ + + + + + +
+
The following data issue - + s were was - found that may affect how the parser works. When the Hermit Crab parser uses a natural class during its synthesis process, the natural class will use the phonological features which are the intersection of the features of all the phonemes in the class while trying to see if a segment matches the natural class. The implied phonological features are shown for each class below and mean that it will match any of the predicted phonemes shown. (If the implied features field is blank, then it will match *all* phonemes.) For each of the natural classes shown below, the set of predicted phonemes is not the same as the set of actual phonemes. You will need to rework your phonological feature system and the assignment of these features to phonemes to make it be correct. -

- - - - - - - - -
- - - - - - - -
- -
- [ - - ] -
-
- - - - - - - - - - - - - -
Implied Features - -
Predicted Phonemes - -
Actual Phonemes - -
-
- + found that may affect how the parser works. Empty graphemes can make the Hermit Crab parser not respond correctly. + +
+ The phoneme + + has an empty grapheme. Please delete it or fill it out. +
+
+
+ + + +
+
+ The following data issue + + + s were + + + was + + + found that may affect how the parser works. Using left or right square brackets as graphemes can make the Hermit Crab parser not respond correctly. + +
+ The phoneme + + has a bracket ( + + ) as a grapheme. Please delete it.
-