Ejemplo n.º 1
0
        //Egyszerű sql utasításokkal tölt fel, a for ciklusban beállított dokumentumokra.
        //Aminerekhez,
        public static void AThreadProc1()
        {
            OServer   server   = Server.Connect();
            ODatabase database = new ODatabase("localhost", 2424, "TreeOfScience", ODatabaseType.Graph, "admin", "admin");

            string url, json;
            Vertex v;

            AminerVertex a = new AminerVertex {
            };

            url = @"F:\graph\aminer_papers_";
            for (int i = 0; i < 1 /*55*/; i++)
            {
                using (StreamReader sr = File.OpenText(url + i + ".txt"))
                {
                    while ((json = sr.ReadLine()) != null)
                    {
                        v = JsonConvert.DeserializeObject <Vertex>(json);

                        if (v.authors != null)
                        {
                            for (int currentAuthor = 0; currentAuthor < v.authors.Length; currentAuthor++)
                            {
                                v.authors[currentAuthor].@class = "Author";
                                v.authors[currentAuthor].@type  = "d";
                            }
                        }
                        a.aminer_id  = v.id;
                        a.title      = v.title;
                        a.authors    = v.authors;
                        a.year       = v.year;
                        a.venue      = v.venue;
                        a.keywords   = v.keywords;
                        a.fos        = v.fos;
                        a.n_citation = v.n_citation;
                        a.references = v.references;
                        a.page_stat  = v.page_stat;
                        a.page_end   = v.page_end;
                        a.doc_type   = v.doc_type;
                        a.lang       = v.lang;
                        a.publisher  = v.publisher;
                        a.volume     = v.volume;
                        a.issue      = v.issue;
                        a.issn       = v.issn;
                        a.isbn       = v.isbn;
                        a.doi        = v.doi;
                        a.pdf        = v.pdf;
                        a.url        = v.url;
                        a.Abstract   = v.Abstract;
                        json         = JsonConvert.SerializeObject(a).Replace("Abstract", "abstract").Replace("type", "@type").Replace("class", "@class").Replace("doc_@type", "doc_type");
                        database.Command("INSERT INTO Document CONTENT " + json);
                    }
                }
                Console.WriteLine("a" + i);
            }
        }
Ejemplo n.º 2
0
        //Éleket tölt fel, jelenleg nem működik megfelelően.
        public static void Edge1()
        {
            try
            {
                OServer   server = Server.Connect();
                ODatabase database = new ODatabase("localhost", 2424, "TreeOfScience", ODatabaseType.Graph, "admin", "admin");
                string    url, json;
                Vertex    v;

                AminerVertex a = new AminerVertex {
                };
                url = @"F:\graph\aminer_papers_";
                for (int i = 0; i < 1; i++)
                {
                    using (StreamReader sr = File.OpenText(url + i + ".txt"))
                    {
                        while ((json = sr.ReadLine()) != null)
                        {
                            v            = JsonConvert.DeserializeObject <Vertex>(json);
                            a.aminer_id  = v.id;
                            a.references = v.references;
                            if (a.references != null)
                            {
                                if (a.references.Length != 0)
                                {
                                    foreach (string refr in a.references)
                                    {
                                        //if (a.references.Length != 0) foreach (string refr in a.references)
                                        //{
                                        //    database.Command("create edge from (select from document where aminer_id = '" + a.aminer_id + "') to (select from document where aminer_id = '" + refr + "')");
                                        //}
                                        for (int refn = 0; refn < a.references.Length; refn++)
                                        {
                                            database.Command("create edge from (select from document where aminer_id = '" + a.aminer_id + "') to (select from document where aminer_id = '" + a.references[refn] + "')");
                                        }
                                    }
                                }
                            }
                        }
                    }
                    Console.WriteLine("a" + i);
                }
            }
            catch (OException e)
            {
                Console.WriteLine(e.Message);
            }
        }
Ejemplo n.º 3
0
        public static void AmiTransThr3()
        {
            OServer   server   = Server.Connect();
            ODatabase database = new ODatabase("localhost", 2424, "TreeOfScience", ODatabaseType.Graph, "admin", "admin");

            string url, json;
            Vertex v;

            AminerVertex a = new AminerVertex {
            };

            url = @"F:\graph\aminer_papers_";
            for (int i = 104; i < 155 /*155*/; i++)
            {
                string        batch;
                StringBuilder builder = new StringBuilder("BEGIN;\n", 250000000);
                using (StreamReader sr = File.OpenText(url + i + ".txt"))
                {
                    for (int rcount = 1; (json = sr.ReadLine()) != null; rcount++)
                    {
                        v = JsonConvert.DeserializeObject <Vertex>(json);
                        if (v.authors != null)
                        {
                            for (int currentAuthor = 0; currentAuthor < v.authors.Length; currentAuthor++)
                            {
                                v.authors[currentAuthor].@class = "Author";
                                v.authors[currentAuthor].@type  = "d";
                            }
                        }
                        a.aminer_id  = v.id;
                        a.title      = v.title;
                        a.authors    = v.authors;
                        a.year       = v.year;
                        a.venue      = v.venue;
                        a.keywords   = v.keywords;
                        a.fos        = v.fos;
                        a.n_citation = v.n_citation;
                        a.references = v.references;
                        a.page_stat  = v.page_stat;
                        a.page_end   = v.page_end;
                        a.doc_type   = v.doc_type;
                        a.lang       = v.lang;
                        a.publisher  = v.publisher;
                        a.volume     = v.volume;
                        a.issue      = v.issue;
                        a.issn       = v.issn;
                        a.isbn       = v.isbn;
                        a.doi        = v.doi;
                        a.pdf        = v.pdf;
                        a.url        = v.url;
                        a.Abstract   = v.Abstract;
                        json         = JsonConvert.SerializeObject(a).Replace("Abstract", "abstract").Replace("type", "@type").Replace("class", "@class").Replace("doc_@type", "doc_type");
                        builder.Append("INSERT INTO Document CONTENT ");
                        builder.Append(json);
                        builder.Append(";\n");
                        if (rcount % 1000 == 0)
                        {
                            builder.Append("COMMIT;");
                            batch = builder.ToString();
                            Console.WriteLine(String.Concat(DateTime.Now, " a", i, " ", rcount / 1000));
                            database.SqlBatch(batch).Run();
                            builder.Clear();
                            builder.Append("BEGIN;\n");
                        }
                    }
                }
                builder.Append("COMMIT;");
                batch = builder.ToString();
                database.SqlBatch(batch).Run();
                Console.WriteLine(String.Concat(DateTime.Now, " a", i, " OK"));
            }
        }