Exemplo n.º 1
0
 internal Orthography(Alphabet alphabet, IEnumerable<OrthographyRule> rules)
 {
     Alphabet = alphabet;
     foreach (OrthographyRule rule in rules)
     {
         _rules.Add(rule.Id, rule);
     }
 }
Exemplo n.º 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;
 }
Exemplo n.º 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);
            }
        }
Exemplo n.º 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();
        }
Exemplo n.º 5
0
        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);
        }
Exemplo n.º 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);
        }
Exemplo n.º 7
0
 public IsNotLastMorpheme(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemplo n.º 8
0
 public MorphemeExists(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemplo n.º 9
0
 private OrthographyReader(XmlDocument xml)
 {
     _xml = xml;
     _alphabet = ReadAlphabet();
     _rules = ReadRules();
 }
Exemplo n.º 10
0
 public HasNotLabel(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemplo n.º 11
0
 public HasLabel(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
     _label = LabelSet.ConvertLabelNameToIndex(operand);
 }
Exemplo n.º 12
0
 public LastLetterEquals(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemplo n.º 13
0
 public MorphemeNotEquals(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemplo n.º 14
0
 public EndsWithConsonant(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemplo n.º 15
0
 public HasLabel(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
     _label = operand;
 }
Exemplo n.º 16
0
 public MorphemeSequenceEquals(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
     _sequence = Operand.Split(new[] {',', ' '}, StringSplitOptions.RemoveEmptyEntries);
 }
Exemplo n.º 17
0
 public static Morphotactics Read(Stream xml, Alphabet alphabet)
 {
     var reader = new MorphotacticsReader(xml, alphabet);
     return new Morphotactics(reader._graph);
 }
Exemplo n.º 18
0
 public static Orthography Read(XmlDocument xml)
 {
     _alphabet = ReadAlphabet(xml);
     IEnumerable<OrthographyRule> rules = ReadRules(xml);
     return new Orthography(_alphabet, rules);
 }
Exemplo n.º 19
0
 public EndsWithVowel(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }
Exemplo n.º 20
0
 public PenultVowelEquals(string position, string operand, Alphabet alphabet)
     : base(position, operand, alphabet)
 {
 }