Пример #1
0
 public Abs_view_f(JournalArticle article)
 {
     //Initialize new form to display suitable document
     InitializeComponent();
     //Load form components and data
     this.Text      = "Abstract View - DocID: " + article.ID;
     AV_title.Text  = "Title: " + article.Title + "\n";
     AV_author.Text = "Author: " + article.Author + "\n";
     AV_abs.Text    = "Abstract:\n" + article.Words + "\n";
 }
Пример #2
0
        /// <summary>
        /// Indexes the given text
        /// </summary>
        /// <param name="text">Text to index</param>
        public void IndexText(JournalArticle article)
        {
            //Always store document ID regardless of index setting
            Lucene.Net.Documents.Field I_field = new Field(ID_FN, article.ID, STORE, INDEX_FIELD, TERM_VECTOR);
            Lucene.Net.Documents.Field T_field = new Field(TITLE_FN, article.Title, STORE, INDEX_FIELD, TERM_VECTOR);
            Lucene.Net.Documents.Field A_field = new Field(AUTHOR_FN, article.Author, STORE, INDEX_FIELD, TERM_VECTOR);
            Lucene.Net.Documents.Field B_field = new Field(BILI_FN, article.Bibliographic, STORE, INDEX_FIELD, TERM_VECTOR);
            Lucene.Net.Documents.Field W_field = new Field(WORD_FN, article.Words, STORE, INDEX_FIELD, TERM_VECTOR);

            Lucene.Net.Documents.Document doc = new Document();
            doc.Add(I_field);
            doc.Add(T_field);
            doc.Add(A_field);
            doc.Add(B_field);
            doc.Add(W_field);
            writer.AddDocument(doc);
        }
Пример #3
0
        public JournalArticle GetArticle(string DocID)

        /*
         */
        {
            JournalArticle result = null;

            for (int i = 0; i < Articles.Count; i++)
            {
                JournalArticle article = Articles[i];
                if (article.ID == DocID)
                {
                    result = article;
                    break;
                }
            }
            return(result);
        }
Пример #4
0
        //function to traverse through the directory path and find article files
        private void WalkDirectoryTree(String path)
        {
            System.IO.DirectoryInfo   root    = new System.IO.DirectoryInfo(path);
            System.IO.FileInfo[]      files   = null;
            System.IO.DirectoryInfo[] subDirs = null;

            // First, process all the files directly under this folder
            try
            {
                files = root.GetFiles("*.txt");
            }

            catch (UnauthorizedAccessException e)
            {
                System.Console.WriteLine(e.Message);
            }

            catch (System.IO.DirectoryNotFoundException e)
            {
                Console.WriteLine(e.Message);
            }

            if (files != null)
            {
                foreach (System.IO.FileInfo fi in files)
                {
                    string         name           = fi.FullName;
                    JournalArticle journalArticle = new JournalArticle(name);
                    articles.Add(journalArticle);
                }

                // Now find all the subdirectories under this directory.
                subDirs = root.GetDirectories();

                foreach (System.IO.DirectoryInfo dirInfo in subDirs)
                {
                    // Resursive call for each subdirectory.
                    string name = dirInfo.FullName;
                    WalkDirectoryTree(name);
                }
            }
        }