예제 #1
0
 public IEnumerable <Posting> Start(sqliteContext db, List <string> words)
 {
     return(new List <string>(new string[] {
         "e-prostor.gov.si",
         "e-uprava.gov.si",
         "evem.gov.si",
         "podatki.gov.si"
     })
            .SelectMany(p => Index(p, db, words))
            .ToList());
 }
예제 #2
0
        public IEnumerable <Posting> Index(string path, sqliteContext db, List <string> words)
        {
            var files = Directory.GetFiles(basePath + path, "*.html");

            if (db != null)
            {
                Console.WriteLine("Indexing {0} files from {1}", files.Length, path);
            }

            return(new List <string>(files)
                   .SelectMany(f => new Document(f, f.Replace(basePath, "")).Index(db, words)));
        }
예제 #3
0
        public IEnumerable <Posting> Index(sqliteContext dbContext, List <string> words)
        {
            Dictionary <string, Posting> postings = new Dictionary <string, Posting>();
            int index = 0;

            foreach (var token in Tokens)
            {
                var word = token.ToString().ToLower();
                index++;
                if (StopWords.Contains(word))
                {
                    continue;
                }
                if (words != null && !words.Contains(word))
                {
                    continue;
                }

                if (dbContext?.IndexWord.Find(word) == null)
                {
                    dbContext?.IndexWord.Add(new IndexWord()
                    {
                        Word = word
                    });
                }

                if (!postings.ContainsKey(word))
                {
                    postings.Add(word, new Posting()
                    {
                        Word         = word,
                        DocumentName = name,
                        Indexes      = ""
                    });
                }

                var p = postings[word];
                p.Frequency++;
                if (p.Indexes != "")
                {
                    p.Indexes += ",";
                }
                p.Indexes += index;
            }

            foreach (var posting in postings)
            {
                dbContext?.Posting.Add(posting.Value);
            }
            return(postings.Values);
        }
예제 #4
0
        static void Main(string[] args)
        {
            var db    = new sqliteContext();
            var words = new List <string>(args);

            words.RemoveAt(0);
            var basePath = "../../../sites/";

            switch (args[0])
            {
            case "i":
                Indexer indexer = new Indexer(basePath);
                indexer.Start(db, null);
                db.SaveChanges();
                break;

            case "q":
                new IndexedSearcher(basePath, db)
                .Query(words);
                break;

            case "d":
                new DirectSearcher(basePath)
                .Query(words);
                break;

            default:
                Console.WriteLine("WebSearcher");
                Console.WriteLine("i - Indexing");
                Console.WriteLine("q - Query with provided index");
                Console.WriteLine("d - Query directly without index");
                break;
            }
            Console.WriteLine("Program finished, press Enter to quit");
            Console.Read();
        }
예제 #5
0
 public PlayerController(sqliteContext sqliteContext)
 {
     db = sqliteContext;
 }
예제 #6
0
 public MapController(sqliteContext sqliteContext)
 {
     db = sqliteContext;
 }
예제 #7
0
 public IndexedSearcher(string basePath, sqliteContext db) : base(basePath)
 {
     this.db = db;
 }