Skip to content

Commit 0d6dace

Browse files
authored
Lt22438 Try to share code between HCSynthByGloss tools and ParserCore (#740)
* LT-22438 Try to share code between HCSynthByGloss tools and ParserCore Change-Id: Icfea29c8a5c84b8033a4609a4e2d47175c57ce4f * LT-22438 Try to improve JavaScript formatting Change-Id: I2ef3d3d92ba6d213fff49477876ffd4978120aed
1 parent bcfbea0 commit 0d6dace

14 files changed

Lines changed: 316 additions & 3339 deletions

Src/GenerateHCConfig/ConsoleLogger.cs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55

66
namespace GenerateHCConfig
77
{
8-
internal class ConsoleLogger : ILcmUI, IHCLoadErrorLogger
8+
public class ConsoleLogger : ILcmUI, IHCLoadErrorLogger
99
{
1010
private readonly ISynchronizeInvoke m_synchronizeInvoke;
1111

Src/LexText/ParserCore/HCLoader.cs

Lines changed: 22 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -41,19 +41,19 @@ public static Language Load(LcmCache cache, IHCLoadErrorLogger logger)
4141
};
4242

4343
private readonly LcmCache m_cache;
44-
private readonly Dictionary<IMoForm, List<Allomorph>> m_allomorphs;
44+
protected readonly Dictionary<IMoForm, List<Allomorph>> m_allomorphs;
4545
private readonly Dictionary<IMoMorphSynAnalysis, List<Morpheme>> m_morphemes;
4646
private readonly Dictionary<IMoStemName, StemName> m_stemNames;
47-
private readonly Dictionary<ICmObject, MprFeature> m_mprFeatures;
47+
protected readonly Dictionary<ICmObject, MprFeature> m_mprFeatures;
4848

49-
private Language m_language;
49+
protected Language m_language;
5050
private CharacterDefinitionTable m_table;
5151
private Stratum m_morphophonemic;
5252
private Stratum m_clitic;
53-
private ComplexFeature m_headFeature;
54-
private SymbolicFeature m_posFeature;
53+
protected ComplexFeature m_headFeature;
54+
protected SymbolicFeature m_posFeature;
5555

56-
private readonly IHCLoadErrorLogger m_logger;
56+
protected readonly IHCLoadErrorLogger m_logger;
5757
private readonly PhonEnvRecognizer m_envValidator;
5858
private readonly Dictionary<string, IPhNaturalClass> m_naturalClassLookup;
5959
private readonly Dictionary<IPhNaturalClass, NaturalClass> m_naturalClasses;
@@ -71,7 +71,7 @@ public static Language Load(LcmCache cache, IHCLoadErrorLogger logger)
7171
private CharacterDefinition m_null;
7272
private CharacterDefinition m_morphBdry;
7373

74-
private HCLoader(LcmCache cache, IHCLoadErrorLogger logger)
74+
protected HCLoader(LcmCache cache, IHCLoadErrorLogger logger)
7575
{
7676
m_cache = cache;
7777
m_logger = logger;
@@ -160,7 +160,7 @@ private string RemoveDottedCircles(string text)
160160
return text?.Replace(dottedCircle, string.Empty);
161161
}
162162

163-
private void LoadLanguage()
163+
protected void LoadLanguage()
164164
{
165165
m_language = new Language { Name = m_cache.ProjectId.Name };
166166

@@ -513,7 +513,7 @@ private void LoadInflClassMprFeature(IMoInflClass inflClass, MprFeatureGroup inf
513513
LoadInflClassMprFeature(subclass, inflClassesGroup);
514514
}
515515

516-
private bool HasValidRuleForm(ILexEntry entry)
516+
protected bool HasValidRuleForm(ILexEntry entry)
517517
{
518518
if (entry.IsCircumfix() && entry.LexemeFormOA is IMoAffixAllomorph)
519519
{
@@ -622,7 +622,7 @@ private static bool IsCliticType(IMoMorphType type)
622622
return false;
623623
}
624624

625-
private void LoadLexEntries(Stratum stratum, ILexEntry entry, IList<IMoStemAllomorph> allos)
625+
protected virtual void LoadLexEntries(Stratum stratum, ILexEntry entry, IList<IMoStemAllomorph> allos)
626626
{
627627
if (entry.SensesOS.Count == 0)
628628
{
@@ -653,7 +653,7 @@ private void LoadLexEntries(Stratum stratum, ILexEntry entry, IList<IMoStemAllom
653653
LoadLexEntry(stratum, msa, allos, entry.ShortName);
654654
}
655655

656-
private IEnumerable<ILexEntryInflType> GetInflTypes(ILexEntryRef lexEntryRef)
656+
protected IEnumerable<ILexEntryInflType> GetInflTypes(ILexEntryRef lexEntryRef)
657657
{
658658
if (lexEntryRef.VariantEntryTypesRS.Count == 0)
659659
{
@@ -677,7 +677,7 @@ private IEnumerable<ILexEntryInflType> GetInflTypes(ILexEntryRef lexEntryRef)
677677
}
678678
}
679679

680-
private void AddEntry(Stratum stratum, LexEntry hcEntry, IMoMorphSynAnalysis msa, string name)
680+
protected void AddEntry(Stratum stratum, LexEntry hcEntry, IMoMorphSynAnalysis msa, string name)
681681
{
682682
if (hcEntry.Allomorphs.Count > 0)
683683
{
@@ -729,7 +729,7 @@ private void LoadLexEntry(Stratum stratum, IMoStemMsa msa, IList<IMoStemAllomorp
729729
AddEntry(stratum, hcEntry, msa, name);
730730
}
731731

732-
private void LoadLexEntryOfVariant(Stratum stratum, ILexEntryInflType inflType, IMoStemMsa msa, IList<IMoStemAllomorph> allos, string name)
732+
protected void LoadLexEntryOfVariant(Stratum stratum, ILexEntryInflType inflType, IMoStemMsa msa, IList<IMoStemAllomorph> allos, string name)
733733
{
734734
var hcEntry = new LexEntry();
735735

@@ -805,7 +805,7 @@ private void LoadLexEntryOfVariant(Stratum stratum, ILexEntryInflType inflType,
805805
AddEntry(stratum, hcEntry, msa, name);
806806
}
807807

808-
private RootAllomorph LoadRootAllomorph(IMoStemAllomorph allo, IMoMorphSynAnalysis msa)
808+
protected RootAllomorph LoadRootAllomorph(IMoStemAllomorph allo, IMoMorphSynAnalysis msa)
809809
{
810810
string form = FormatForm(RemoveDottedCircles(allo.Form.VernacularDefaultWritingSystem.Text));
811811
Shape shape = Segment(form);
@@ -843,7 +843,7 @@ private RootAllomorph LoadRootAllomorph(IMoStemAllomorph allo, IMoMorphSynAnalys
843843
return hcAllo;
844844
}
845845

846-
private void LoadMorphologicalRules(Stratum stratum, ILexEntry entry, IList<IMoForm> allos)
846+
protected virtual void LoadMorphologicalRules(Stratum stratum, ILexEntry entry, IList<IMoForm> allos)
847847
{
848848
if (!HasValidRuleForm(entry))
849849
return;
@@ -912,7 +912,7 @@ private string GetGloss(IMoMorphSynAnalysis msa)
912912
return sense == null ? null : sense.Gloss.BestAnalysisAlternative.Text;
913913
}
914914

915-
private void AddMorphologicalRule(Stratum stratum, AffixProcessRule rule, IMoMorphSynAnalysis msa)
915+
protected void AddMorphologicalRule(Stratum stratum, AffixProcessRule rule, IMoMorphSynAnalysis msa)
916916
{
917917
if (rule.Allomorphs.Count > 0)
918918
{
@@ -922,7 +922,7 @@ private void AddMorphologicalRule(Stratum stratum, AffixProcessRule rule, IMoMor
922922
}
923923
}
924924

925-
private AffixProcessRule LoadDerivAffixProcessRule(ILexEntry entry, IMoDerivAffMsa msa, IList<IMoForm> allos)
925+
protected AffixProcessRule LoadDerivAffixProcessRule(ILexEntry entry, IMoDerivAffMsa msa, IList<IMoForm> allos)
926926
{
927927
var mrule = new AffixProcessRule { Name = entry.ShortName };
928928

@@ -972,7 +972,7 @@ private AffixProcessRule LoadDerivAffixProcessRule(ILexEntry entry, IMoDerivAffM
972972
return mrule;
973973
}
974974

975-
private AffixProcessRule LoadInflAffixProcessRule(ILexEntry entry, IMoInflAffMsa msa, IList<IMoForm> allos)
975+
protected AffixProcessRule LoadInflAffixProcessRule(ILexEntry entry, IMoInflAffMsa msa, IList<IMoForm> allos)
976976
{
977977
// TODO: use realizational affix process rules
978978
var mrule = new AffixProcessRule
@@ -1004,7 +1004,7 @@ private AffixProcessRule LoadInflAffixProcessRule(ILexEntry entry, IMoInflAffMsa
10041004
return mrule;
10051005
}
10061006

1007-
private AffixProcessRule LoadUnclassifiedAffixProcessRule(ILexEntry entry, IMoUnclassifiedAffixMsa msa, IList<IMoForm> allos)
1007+
protected AffixProcessRule LoadUnclassifiedAffixProcessRule(ILexEntry entry, IMoUnclassifiedAffixMsa msa, IList<IMoForm> allos)
10081008
{
10091009
var mrule = new AffixProcessRule
10101010
{
@@ -1026,7 +1026,7 @@ private AffixProcessRule LoadUnclassifiedAffixProcessRule(ILexEntry entry, IMoUn
10261026
return mrule;
10271027
}
10281028

1029-
private AffixProcessRule LoadCliticAffixProcessRule(ILexEntry entry, IMoStemMsa msa, IList<IMoForm> allos)
1029+
protected AffixProcessRule LoadCliticAffixProcessRule(ILexEntry entry, IMoStemMsa msa, IList<IMoForm> allos)
10301030
{
10311031
var mrule = new AffixProcessRule { Name = entry.ShortName };
10321032

@@ -2496,7 +2496,7 @@ private static bool IsWordBoundary(IPhPhonContext ctxt)
24962496
return false;
24972497
}
24982498

2499-
private FeatureStruct LoadFeatureStruct(IFsFeatStruc fs, FeatureSystem featSys)
2499+
protected FeatureStruct LoadFeatureStruct(IFsFeatStruc fs, FeatureSystem featSys)
25002500
{
25012501
var hcFS = new FeatureStruct();
25022502
if (fs != null)
@@ -2621,7 +2621,7 @@ private IEnumerable<MprFeature> LoadMprFeatures(IPhPhonRuleFeat ruleFeat)
26212621
}
26222622
}
26232623

2624-
private static IMoInflClass GetInflClass(IMoStemMsa msa)
2624+
protected static IMoInflClass GetInflClass(IMoStemMsa msa)
26252625
{
26262626
if (msa.InflectionClassRA != null)
26272627
return msa.InflectionClassRA;

Src/LexText/ParserCore/HCParser.cs

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -31,20 +31,21 @@ public class HCParser : DisposableBase, IParser
3131
private bool m_guessRoots;
3232
private bool m_mergeAnalyses;
3333

34+
// the public const strings are for GenerateHCConfigForFLExTrans and HCSynthByGlossLib
3435
internal const string CRuleID = "ID";
3536
internal const string FormID = "ID";
3637
internal const string FormID2 = "ID2";
37-
internal const string InflTypeID = "InflTypeID";
38-
internal const string MsaID = "ID";
38+
public const string InflTypeID = "InflTypeID";
39+
public const string MsaID = "ID";
3940
internal const string PRuleID = "ID";
4041
internal const string SlotID = "SlotID";
4142
internal const string TemplateID = "ID";
4243

4344
internal const string IsNull = "IsNull";
4445
internal const string IsPrefix = "IsPrefix";
45-
internal const string Env = "Env";
46-
internal const string PrefixEnv = "PrefixEnv";
47-
internal const string SuffixEnv = "SuffixEnv";
46+
public const string Env = "Env";
47+
public const string PrefixEnv = "PrefixEnv";
48+
public const string SuffixEnv = "SuffixEnv";
4849

4950
public HCParser(LcmCache cache)
5051
{

Src/LexText/ParserCore/InvalidAffixProcessException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
using System;
1+
using System;
22
using SIL.LCModel;
33

44
namespace SIL.FieldWorks.WordWorks.Parser
55
{
6-
internal class InvalidAffixProcessException : Exception
6+
public class InvalidAffixProcessException : Exception
77
{
88
private readonly IMoAffixProcess m_affixProcess;
99
private readonly bool m_invalidLhs;

Src/LexText/ParserCore/InvalidReduplicationFormException.cs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,12 @@
1-
// Copyright (c) 2015 SIL International
1+
// Copyright (c) 2015 SIL International
22
// This software is licensed under the LGPL, version 2.1 or later
33
// (http://www.gnu.org/licenses/lgpl-2.1.html)
44

55
using System;
66

77
namespace SIL.FieldWorks.WordWorks.Parser
88
{
9-
internal class InvalidReduplicationFormException : Exception
9+
public class InvalidReduplicationFormException : Exception
1010
{
1111
public InvalidReduplicationFormException(string message)
1212
: base(message)

0 commit comments

Comments
 (0)