Exemple #1
0
 internal Orthography(Alphabet alphabet, IEnumerable<OrthographyRule> rules)
 {
     Alphabet = alphabet;
     foreach (OrthographyRule rule in rules)
     {
         _rules.Add(rule.Id, rule);
     }
 }
Exemple #2
0
 protected ConditionBase(string position, string operand, Alphabet alphabet)
 {
     if (!Enum.TryParse(position, out Position))
     {
         throw new ArgumentException("Invalid Morpheme Location: " + position);
     }
     Operand = operand;
     Alphabet = alphabet;
 }
Exemple #3
0
        public static ConditionBase Create(string name, string morphemePosition, string operand, Alphabet alphabet)
        {
            switch (name)
            {
                case "EndsWithConsonant":
                    return new EndsWithConsonant(morphemePosition, operand, alphabet);
                case "EndsWithVowel":
                    return new EndsWithVowel(morphemePosition, operand, alphabet);
                case "FirstLetterEquals":
                    return new FirstLetterEquals(morphemePosition, operand, alphabet);
                case "LastLetterEquals":
                    return new LastLetterEquals(morphemePosition, operand, alphabet);
                case "LastVowelEquals":
                    return new LastVowelEquals(morphemePosition, operand, alphabet);
                case "MorphemeEquals":
                    return new MorphemeEquals(morphemePosition, operand, alphabet);
                case "MorphemeExists":
                    return new MorphemeExists(morphemePosition, operand, alphabet);
                case "MorphemeNotEquals":
                    return new MorphemeNotEquals(morphemePosition, operand, alphabet);
                case "MorphemeSequenceEquals":
                    return new MorphemeSequenceEquals(morphemePosition, operand, alphabet);
                case "PenultVowelEquals":
                    return new PenultVowelEquals(morphemePosition, operand, alphabet);
                case "StartsWithConsonant":
                    return new StartsWithConsonant(morphemePosition, operand, alphabet);
                case "StartsWithVowel":
                    return new StartsWithVowel(morphemePosition, operand, alphabet);
                case "HasFlags":
                    return new HasLabel(morphemePosition, operand, alphabet);
                case "HasNotFlags":
                    return new HasNotLabel(morphemePosition, operand, alphabet);
                case "IsLastMorpheme":
                    return new IsLastMorpheme(morphemePosition, operand, alphabet);
                case "IsNotLastMorpheme":
                    return new IsNotLastMorpheme(morphemePosition, operand, alphabet);
                case "IsFirstMorpheme":
                    return new IsFirstMorpheme(morphemePosition, operand, alphabet);
                case "IsNotFirstMorpheme":
                    return new IsNotFirstMorpheme(morphemePosition, operand, alphabet);

                default:
                    throw new ArgumentException("Invalid Condition: " + name);
            }
        }
Exemple #4
0
        private MorphotacticsReader(Stream xml, Alphabet alphabet)
        {
            _alphabet = alphabet;

            try
            {
                _xDocument = XDocument.Load(xml);
            }
            catch (XmlException ex)
            {
                throw new XmlException("Invalid morphotactics XML: " + ex.Message);
            }

            _suffixGroupElements = GetSuffixGroupElements();
            _transitionSets = GetTransitionSetElements();

            BuildGraph();
        }
        public static Morphotactics Read(Stream xml, Alphabet alphabet)
        {
            _alphabet = alphabet;
            XDocument doc;
            try
            {
                doc = XDocument.Load(xml);
            }

            catch (XmlException ex)
            {
                throw new XmlException("Invalid morphotactics XML: " + ex.Message);
            }

            _suffixGroupElements = GetSuffixGroupElements(doc);
            _transitionSetElements = GetTransitionSetElements(doc);

            BuildGraph();

            return new Morphotactics(Graph);
        }
Exemple #6
0
        public static Morphotactics Read(Stream xml, Alphabet alphabet)
        {
            _alphabet = alphabet;
            XDocument doc = null;
            try
            {
                doc = XDocument.Load(xml);
            }

            catch (XmlException ex)
            {
                throw new XmlException("Invalid morphotactics XML: " + ex.Message);
            }

            SUFFIX_GROUP_ELEMENTS = GetSuffixGroupElements(doc);
            TRANSITION_SET_ELEMENTS = GetTransitionSetElements(doc);

            BuildGraph();

            return new Morphotactics(Graph);
        }
Exemple #7
0
 public IsNotLastMorpheme(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemple #8
0
 public MorphemeExists(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemple #9
0
 private OrthographyReader(XmlDocument xml)
 {
     _xml = xml;
     _alphabet = ReadAlphabet();
     _rules = ReadRules();
 }
Exemple #10
0
 public HasNotLabel(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemple #11
0
 public HasLabel(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
     _label = LabelSet.ConvertLabelNameToIndex(operand);
 }
Exemple #12
0
 public LastLetterEquals(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemple #13
0
 public MorphemeNotEquals(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemple #14
0
 public EndsWithConsonant(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemple #15
0
 public HasLabel(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
     _label = operand;
 }
 public MorphemeSequenceEquals(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
     _sequence = Operand.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries);
 }
Exemple #17
0
 public static Morphotactics Read(Stream xml, Alphabet alphabet)
 {
     var reader = new MorphotacticsReader(xml, alphabet);
     return new Morphotactics(reader._graph);
 }
Exemple #18
0
 public static Orthography Read(XmlDocument xml)
 {
     _alphabet = ReadAlphabet(xml);
     IEnumerable<OrthographyRule> rules = ReadRules(xml);
     return new Orthography(_alphabet, rules);
 }
Exemple #19
0
 public EndsWithVowel(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemple #20
0
 public PenultVowelEquals(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }