Beispiel #1
0
        public void FromBytes(byte[] bytes)
        {
            if (Serialization.Selected == Serialization.Mode.Spacy)
            {
                using (Py.GIL())
                {
                    var pyObj = ToPython.GetBytes(bytes);
                    _pyDocBin.from_bytes(pyObj);
                }
            }
            else
            {
                var stream = new MemoryStream(bytes);

                var settings = new XmlReaderSettings();
                settings.IgnoreComments   = true;
                settings.IgnoreWhitespace = true;
                var reader = XmlReader.Create(stream, settings);

                var docBin = new DocBin();
                docBin.ReadXml(reader);
                Copy(docBin);
            }
        }
Beispiel #2
0
        public void FromDisk(string pathFile)
        {
            if (Serialization.Selected == Serialization.Mode.Spacy)
            {
                using (Py.GIL())
                {
                    var pyPath = new PyString(pathFile);
                    _pyDocBin.from_disk(pyPath);
                }
            }
            else
            {
                using var stream = new FileStream(pathFile, FileMode.Open, FileAccess.Read);

                var settings = new XmlReaderSettings();
                settings.IgnoreComments   = true;
                settings.IgnoreWhitespace = true;
                var reader = XmlReader.Create(stream, settings);

                var docBin = new DocBin();
                docBin.ReadXml(reader);
                Copy(docBin);
            }
        }