Ejemplo n.º 1
0
        /// <summary>
        /// Creates XML file from Numenera items extracted from PDF
        /// </summary>
        /// <param name="info"></param>
        /// <param name="sourcebookName"></param>
        /// <param name="objectsName"></param>
        /// <param name="objectName"></param>
        private static void NumeneraCreateXML(PDFTextFileInfo info, string sourcebookName, string objectsName, string objectName)
        {
            var linesFromFile = File.ReadAllLines(info.ItemsFileName);
            var itemsLines    = new List <string>(linesFromFile);

            itemsLines = PDFTextParser.FixBrokenWords(itemsLines);
            itemsLines = PDFTextParser.SplitLinesByKeywords(itemsLines, info.KeywordsList);
            var objects = PDFTextParser.SplitItemsToObjects(info, itemsLines.ToArray());

            var smthToWrite = new List <string>();

            objects.ForEach(x => x.ForEach(s => smthToWrite.Add(s)));
            File.WriteAllLines(info.ItemsFileName + "_Cleared.txt", smthToWrite);

            var parsedDic = PDFTextParser.CreateDictionariesFromObjects(objects, info.KeywordsList);

            // and make XML from it
            var xmlInfo = new PDFTextXmlInfo()
            {
                XmlFileName = Path.GetDirectoryName(info.ItemsFileName) +
                              @"\OUTPUT_" + objectsName + "_" + sourcebookName + ".xml",
                ObjectsName = objectsName,
                ObjectName  = objectName,
                Source      = sourcebookName
            };

            PDFTextXmlCreator.CreateXMLWithRollTable(xmlInfo, parsedDic, info.TableKeyword);
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Create XML from file with oddities
        /// First digits are passed by (roll numbers)
        /// </summary>
        /// <param name="source"></param>
        /// <param name="itemsFileName"></param>
        public static void OdditiesParseFileToXML(string source, string itemsFileName)
        {
            var strings = PDFTextParser.ParseFileWithRollTableToStrings(itemsFileName);

            var xmlInfo = new PDFTextXmlInfo()
            {
                XmlFileName = Path.GetDirectoryName(itemsFileName) +
                              @"\OUTPUT_Oddities_" + source + ".xml",
                ObjectsName = "Oddities",
                ObjectName  = "Oddity",
                Source      = "Discovery"
            };

            PDFTextXmlCreator.CreateXMLForStrings(xmlInfo, strings);
        }