Skip to content

Commit

Permalink
Make changes requested by Andy Black
Browse files Browse the repository at this point in the history
  • Loading branch information
jtmaxwell3 authored and jasonleenaylor committed May 31, 2024
1 parent f91af50 commit 60c3fa6
Show file tree
Hide file tree
Showing 3 changed files with 136 additions and 53 deletions.
3 changes: 2 additions & 1 deletion Src/LexText/ParserCore/HCLoader.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down
27 changes: 27 additions & 0 deletions Src/LexText/ParserCore/HCParser.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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();
}
}
Expand Down
159 changes: 107 additions & 52 deletions Src/Transforms/Presentation/FormatCommon.xsl
Original file line number Diff line number Diff line change
Expand Up @@ -156,69 +156,124 @@
</xsl:template>

<xsl:template name="ShowAnyDataIssues">
<xsl:call-template name="ShowAnyNaturalClassPhonemeMismatch"/>
<xsl:call-template name="ShowAnyIllFormedGraphemes"/>
</xsl:template>

<xsl:template name="ShowAnyNaturalClassPhonemeMismatch">
<xsl:variable name="issues" select="DataIssues/NatClassPhonemeMismatch"/>
<xsl:if test="count($issues)&gt;0">
<div style="color:red">
<p>
<div style="color:red">
<p>
<xsl:text>The following data issue</xsl:text>
<xsl:choose>
<xsl:when test="count($issues) &gt; 1">
<xsl:text>s were</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> was</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> 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.</xsl:text>
</p>
<!-- <ul>-->
<xsl:for-each select="$issues">
<!-- <li>-->
<table>
<tr valign="top">
<td>
<table>
<tr style="color:red">
<td>
<xsl:value-of select="ClassName"/>
</td>
</tr>
<tr style="color:red">
<td>
<xsl:text>[</xsl:text>
<xsl:value-of select="ClassAbbeviation"/>
<xsl:text>]</xsl:text>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr style="color:red">
<td>Implied Features</td>
<td>
<xsl:value-of select="ImpliedPhonologicalFeatures"/>
</td>
</tr>
<tr style="color:red">
<td>Predicted Phonemes</td>
<td>
<xsl:value-of select="PredictedPhonemes"/>
</td>
</tr>
<tr style="color:red">
<td>Actual Phonemes</td>
<td>
<xsl:value-of select="ActualPhonemes"/>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- </li>-->
</xsl:for-each>
<!-- </ul>-->
</div>
</xsl:if>
</xsl:template>

<xsl:template name="ShowAnyIllFormedGraphemes">
<xsl:variable name="emptyGraphemes" select="DataIssues/EmptyGrapheme"/>
<xsl:if test="count($emptyGraphemes)&gt;0">
<div style="color:red">
<br/>
<xsl:text>The following data issue</xsl:text>
<xsl:choose>
<xsl:when test="count($issues) &gt; 1">
<xsl:when test="count($emptyGraphemes) &gt; 1">
<xsl:text>s were</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> was</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> 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.</xsl:text>
</p>
<!-- <ul>-->
<xsl:for-each select="$issues">
<!-- <li>-->
<table>
<tr valign="top">
<td>
<table>
<tr style="color:red">
<td>
<xsl:value-of select="ClassName"/>
</td>
</tr>
<tr style="color:red">
<td>
<xsl:text>[</xsl:text>
<xsl:value-of select="ClassAbbeviation"/>
<xsl:text>]</xsl:text>
</td>
</tr>
</table>
</td>
<td>
<table>
<tr style="color:red">
<td>Implied Features</td>
<td>
<xsl:value-of select="ImpliedPhonologicalFeatures"/>
</td>
</tr>
<tr style="color:red">
<td>Predicted Phonemes</td>
<td>
<xsl:value-of select="PredictedPhonemes"/>
</td>
</tr>
<tr style="color:red">
<td>Actual Phonemes</td>
<td>
<xsl:value-of select="ActualPhonemes"/>
</td>
</tr>
</table>
</td>
</tr>
</table>
<!-- </li>-->
<xsl:text> found that may affect how the parser works. Empty graphemes can make the Hermit Crab parser not respond correctly.</xsl:text>
<xsl:for-each select="$emptyGraphemes">
<br/>
<xsl:text>The phoneme </xsl:text>
<xsl:value-of select="Phoneme"/>
<xsl:text> has an empty grapheme. Please delete it or fill it out.</xsl:text>
</xsl:for-each>
</div>
</xsl:if>
<xsl:variable name="bracketsInGraphemes" select="DataIssues/NoBracketsAsGraphemes"/>

<xsl:if test="count($bracketsInGraphemes)&gt;0">
<div style="color:red">
<br/>
<xsl:text>The following data issue</xsl:text>
<xsl:choose>
<xsl:when test="count($bracketsInGraphemes) &gt; 1">
<xsl:text>s were</xsl:text>
</xsl:when>
<xsl:otherwise>
<xsl:text> was</xsl:text>
</xsl:otherwise>
</xsl:choose>
<xsl:text> 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.</xsl:text>
<xsl:for-each select="$bracketsInGraphemes">
<br/>
<xsl:text>The phoneme </xsl:text>
<xsl:value-of select="Phoneme"/>
<xsl:text> has a bracket ( </xsl:text>
<xsl:value-of select="Bracket"/>
<xsl:text> ) as a grapheme. Please delete it.</xsl:text>
</xsl:for-each>
<!-- </ul>-->
</div>
</xsl:if>
</xsl:template>
Expand Down

0 comments on commit 60c3fa6

Please sign in to comment.