public static void ProcessInline()
        {
            //string[] args = new string[]
            //{
            //    "content"
            //};
            //var inFileNames = File.ReadAllLines(args[0]);
            //var inFileNames = new string[]
            //{

            //};
            foreach (var inFileName in Directory.EnumerateFiles(Path.Combine(Directory.GetCurrentDirectory(), "Data"), "*", SearchOption.AllDirectories))
            //foreach (var inFileName in inFileNames)
            {
                var langCode   = Path.GetFileNameWithoutExtension(inFileName).Substring(0, Path.GetFileNameWithoutExtension(inFileName).IndexOf("wiki"));
                var outFile    = Path.Combine(Path.GetDirectoryName(inFileName), langCode + "_" + Path.GetFileNameWithoutExtension(inFileName) + "_parsed.txt");
                var wikiformat = !inFileName.Contains("abst") ? "content" : "abstract";
                //var wikiformat = "abstract";
                long absCnt = 0;
                if (wikiformat == "content")
                {
                    using (var rd = new XmlContentReader(new StreamReader(inFileName, System.Text.Encoding.UTF8, false)))
                    {
                        using (var wr = new StreamWriter(outFile, false, System.Text.Encoding.UTF8))
                        {
                            for (; ;)
                            {
                                var text = rd.Read();
                                if (text == null)
                                {
                                    break;
                                }
                                wr.WriteLine(Cleaning.CleanWiki(text));
                                absCnt++;
                            }
                        }
                    }
                }
                else
                {
                    using (var rd = new XmlTextReader(inFileName))
                    {
                        using (var wr = new StreamWriter(outFile, false, System.Text.Encoding.UTF8))
                        {
                            while (rd.Read())
                            {
                                if (rd.IsStartElement("abstract") && !rd.IsEmptyElement)
                                {
                                    var text = rd.ReadElementString("abstract");
                                    wr.WriteLine(Cleaning.CleanWiki(text));
                                    absCnt++;
                                }
                            }
                        }
                    }
                }
                Console.Error.WriteLine("Done with {0}. Wrote {1} docs.", langCode, absCnt);
            }
        }
Ejemplo n.º 2
0
 //public float Rotation
 //{
 //    get { return rotation; }
 //    set { rotation = value; }
 //}
 //public Texture2D Texture
 //{
 //    get { return texture; }
 //}
 public Obstacle(Game game, XmlContentReader.Obstacle readIn)
     : base(game)
 {
     this.location = readIn.Location;
     //this.location.X += 400;
     //this.location.Y -= 300;
     this.rotation = readIn.Rotation;
     this.texture = readIn.Texture;
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Defines the attributes of this content
        /// </summary>
        /// <param name="reader">The reading tool</param>
        /// <remarks>Implements IXmlContent</remarks>
        public override void ReadAttributes(XmlContentReader reader)
        {
            m_Point = new PointFeature();
            m_Point.ReadFeatureAttributes(reader);

            PointFeature p = reader.ReadFeatureByReference<PointFeature>("FirstPoint");
            m_Point.Node = p.Node;
            p.Node.AttachPoint(m_Point);
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Defines the attributes of this content
        /// </summary>
        /// <param name="reader">The reading tool</param>
        /// <remarks>Implements IXmlContent</remarks>
        public override void ReadAttributes(XmlContentReader reader)
        {
            m_Point = new PointFeature();
            m_Point.ReadFeatureAttributes(reader);

            PointFeature p = reader.ReadFeatureByReference <PointFeature>("FirstPoint");

            m_Point.Node = p.Node;
            p.Node.AttachPoint(m_Point);
        }
 public static void ProcessCmdline(string[] args)
 {
     if (args.Length != 2 || (args[1] != "abstract" && args[1] != "content"))
     {
         Console.Error.WriteLine("Usage: ParseWikipedia xml-files.txt [abstract|content]");
     }
     else
     {
         var inFileNames = File.ReadAllLines(args[0]);
         foreach (var inFileName in inFileNames)
         {
             var  langCode = inFileName.Substring(0, inFileName.IndexOf("wiki"));
             var  outFile  = langCode + "_parsed.txt";
             long absCnt   = 0;
             if (args[1] == "content")
             {
                 using (var rd = new XmlContentReader(new StreamReader(inFileName, System.Text.Encoding.UTF8, false)))
                 {
                     using (var wr = new StreamWriter(outFile, false, System.Text.Encoding.UTF8))
                     {
                         for (; ;)
                         {
                             var text = rd.Read();
                             if (text == null)
                             {
                                 break;
                             }
                             wr.WriteLine(Cleaning.CleanWiki(text));
                             absCnt++;
                         }
                     }
                 }
             }
             else
             {
                 using (var rd = new XmlTextReader(inFileName))
                 {
                     using (var wr = new StreamWriter(outFile, false, System.Text.Encoding.UTF8))
                     {
                         while (rd.Read())
                         {
                             if (rd.IsStartElement("abstract") && !rd.IsEmptyElement)
                             {
                                 var text = rd.ReadElementString("abstract");
                                 wr.WriteLine(Cleaning.CleanWiki(text));
                                 absCnt++;
                             }
                         }
                     }
                 }
             }
             Console.Error.WriteLine("Done with {0}. Wrote {1} docs.", langCode, absCnt);
         }
     }
 }
Ejemplo n.º 6
0
        /// <summary>
        /// Takes the provided content and deserialize it in type specified by <see cref="ContentType"/>.
        /// </summary>
        /// <typeparam name="T"></typeparam>
        /// <param name="content"></param>
        /// <param name="instance"></param>
        /// <returns></returns>
        public static T Reader <T>(string content, T instance)
            where T : IRESTfulResponse, new()
        {
            switch (instance.ContentType)
            {
            case ContentType.None:
                throw new InvalidOperationException($"The desired deserialization class has no {nameof(ContentType)}");

            case ContentType.Json:
                instance = new JsonContentReader <T>().ProcessContent(content);
                break;

            case ContentType.Xml:
                instance = new XmlContentReader <T>().ProcessContent(content);
                break;

            case ContentType.Form:
                break;
            }

            return(instance);
        }
Ejemplo n.º 7
0
 public Sofa(Game game, XmlContentReader.Obstacle readIn)
     : base(game,readIn)
 {
 }
Ejemplo n.º 8
0
 public SpawnPoint(Game game, XmlContentReader.Obstacle readIn)
     : base(game,readIn)
 {
     spawnTimer = new GameTimer(this.Game, GameTimer.TimerType.SPAWN, this.Location);
 }