Ejemplo n.º 1
0
        private Suffixes ReadSuffixes()
        {
            try
            {
                Dictionary <string, Suffix>        suffixesById;
                MorphemeSurfaceDictionary <Suffix> suffixesBySurface;

                string path   = _dirPath + _seperator + Resources.InternalSuffixesPath;
                var    reader = new SuffixLexiconReader(_orthography);

                if (_external)
                {
                    using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        reader.Read(TextToDataSet.Convert(stream, DefaultTableName, Delimiter), DefaultTableName,
                                    out suffixesById, out suffixesBySurface);
                    }

                    return(new Suffixes(suffixesById, suffixesBySurface));
                }

                DataSet dataSet = EmbeddedTextResourceToDataSet(path);

                reader.Read(dataSet, DefaultTableName, out suffixesById, out suffixesBySurface);

                return(new Suffixes(suffixesById, suffixesBySurface));
            }
            catch (Exception ex)
            {
                throw new InvalidLanguageFileException(ex, Type.Suffixes, "Invalid language file for suffixes: ");
            }
        }
Ejemplo n.º 2
0
        private MorphemeContainer <Suffix> ParseSuffixes(string dataTxt)
        {
            try
            {
                var reader = new SuffixLexiconReader(_orthography);

                using (var stream = GenerateStreamFromString(dataTxt))
                {
                    return(reader.Read(TextToDataSet.Convert(stream, DefaultTableName, Delimiter), DefaultTableName));
                }
            }
            catch (Exception ex)
            {
                throw new InvalidLanguageFileException(ex, Type.Suffixes, "Invalid language file for suffixes: ");
            }
        }
Ejemplo n.º 3
0
        private MorphemeContainer <Root> ParseRoots(string dataTxt)
        {
            try
            {
                var rootsBySurface = new MorphemeSurfaceDictionary <Root>();
                var rootsById      = new Dictionary <string, Root>();
                var reader         = new RootLexiconReader(_orthography);

                using (var stream = GenerateStreamFromString(dataTxt))
                {
                    var ds = TextToDataSet.Convert(stream, DefaultTableName, Delimiter);
                    reader.AddEntries(ds, DefaultTableName, rootsById, rootsBySurface);
                }

                return(new MorphemeContainer <Root>(rootsById, rootsBySurface));
            }
            catch (Exception ex)
            {
                throw new InvalidLanguageFileException(ex, Type.Roots, "Invalid language file for roots: " + _languageType);
            }
        }
Ejemplo n.º 4
0
        private MorphemeSurfaceDictionary <Root> ReadRoots()
        {
            try
            {
                var roots  = new MorphemeSurfaceDictionary <Root>();
                var reader = new RootLexiconReader(_orthography);


                string rootsPath = _dirPath + _seperator + Resources.InternalMainRootsPath;


                if (_external)
                {
                    using (var stream = new FileStream(rootsPath, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        reader.AddEntries(TextToDataSet.Convert(stream, DefaultTableName, Delimiter), DefaultTableName,
                                          roots);
                    }

                    return(roots);
                }


                reader.AddEntries(EmbeddedTextResourceToDataSet(rootsPath), DefaultTableName, roots);


                string namesPath = _dirPath + _seperator + Resources.InternalPersonNamesPath;
                reader.AddEntries(EmbeddedTextResourceToDataSet(namesPath), DefaultTableName, roots);

                string abbreviationPath = _dirPath + _seperator + Resources.InternalAbbreviationsPath;
                reader.AddEntries(EmbeddedTextResourceToDataSet(abbreviationPath), DefaultTableName, roots);

                return(roots);
            }
            catch (Exception ex)
            {
                throw new InvalidLanguageFileException(ex, Type.Roots, "Invalid language file for roots: ");
            }
        }
Ejemplo n.º 5
0
        private MorphemeContainer <Suffix> ReadSuffixes()
        {
            try
            {
                var path   = _dirPath + _seperator + Resources.InternalSuffixesPath;
                var reader = new SuffixLexiconReader(_orthography);

                if (_external)
                {
                    using (var stream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
                    {
                        return(reader.Read(TextToDataSet.Convert(stream, DefaultTableName, Delimiter), DefaultTableName));
                    }
                }

                var dataSet = EmbeddedTextResourceToDataSet(path);

                return(reader.Read(dataSet, DefaultTableName));
            }
            catch (Exception ex)
            {
                throw new InvalidLanguageFileException(ex, Type.Suffixes, "Invalid language file for suffixes: ");
            }
        }
Ejemplo n.º 6
0
        private DataSet EmbeddedTextResourceToDataSet(string path)
        {
            var textStream = EmbeddedResourceReader.Read(path);

            return(TextToDataSet.Convert(textStream, DefaultTableName, Delimiter));
        }