コード例 #1
0
ファイル: MainForm.cs プロジェクト: doronuziel71/HebMorph
        private void btnInitAnalyzer_Click(object sender, EventArgs e)
        {
            using (new BusyObject(this))
            {
                if (analyzer == null)
                {
                    string hspellPath = SelectProjectFolder("Select a path to HSpell data files", "hspell-data-files" + System.IO.Path.DirectorySeparatorChar);
                    if (hspellPath == null)
                        return;

                    MorphAnalyzer a = new MorphAnalyzer(hspellPath);
                    if (!a.IsInitialized)
                    {
                        MessageBox.Show("Error while trying to create a morphological analyzer object; please check the existance of the required data files and try again");
                        return;
                    }

                    analyzer = a;
                }

                // Recreate the index
                IndexWriter writer = new IndexWriter(FSDirectory.Open(tempPath), new Lucene.Net.Analysis.SimpleAnalyzer(), true, new IndexWriter.MaxFieldLength(10));
                writer.Close();
            }

            btnIndexAddFolder.Enabled = true;
            btnRunAutoTests.Enabled = true;
            btnExecuteSearch.Enabled = true;
        }
コード例 #2
0
		public MorphAnalyzer(MorphAnalyzer other)
			: base()
		{
			hebMorphLemmatizer = other.hebMorphLemmatizer;
			SetOverridesTokenStreamMethod<MorphAnalyzer>();
		}
コード例 #3
0
		public HtmlMorphAnalyzer(MorphAnalyzer other) : base(other)
		{
		}
コード例 #4
0
ファイル: MorphAnalyzer.cs プロジェクト: tsimonyan/HebMorph
 public MorphAnalyzer(MorphAnalyzer other)
     : base()
 {
     hebMorphLemmatizer = other.hebMorphLemmatizer;
     SetOverridesTokenStreamMethod <MorphAnalyzer>();
 }
コード例 #5
0
        private static void MoveLuceneIndex(String lng, int indexServer)
        {
            T.TraceMessage("Moving lucene index to server {0}", indexServer);

            Directory[] readers = new Directory[1];
            string impDomain = string.Empty, impUser = string.Empty, impPass = string.Empty;
            string destIndexBasePath = string.Empty;

            if (indexServer == 1)
            {
                destIndexBasePath = ConfigurationController.IndexRootPath;
            }

            Analyzer analyzer = new SpanishAnalyzer(ConfigurationController.Stop_Words);
            string destIndexPath = destIndexBasePath + "\\ES\\IDX";
            string tempIndexPath = ConfigurationController.TempIndexRootPath + "/ES/IDX";

            if (lng.ToLower().Trim().Equals("en"))
            {
                destIndexPath = destIndexBasePath + "\\EN\\IDX";
                tempIndexPath = ConfigurationController.TempIndexRootPath + "/EN/IDX";
                analyzer = new EnglishAnalyzer(ConfigurationController.Stop_Words);
            }
            if (lng.ToLower().Trim().Equals("he"))
            {
                destIndexPath = destIndexBasePath + "\\HE\\IDX";
                tempIndexPath = ConfigurationController.TempIndexRootPath + "/HE/IDX";
                analyzer = new MorphAnalyzer(ConfigurationController.MorphFilesPath);
            }

            MoveIndexFiles(impDomain, impUser, impPass, destIndexPath, tempIndexPath, analyzer);
        }
コード例 #6
0
        /// <summary>
        /// Update Index by Language
        /// </summary>
        /// <param name="indexDir"></param>
        /// <param name="lng"></param>
        /// <returns></returns>
        public static void UpdateIndex(String lng)
        {
            Analyzer analyzer = new SpanishAnalyzer(ConfigurationController.Stop_Words);

            Directory indexDir = FSDirectory.Open(new System.IO.DirectoryInfo(ConfigurationController.TempIndexRootPath + "/ES/IDX"));
            if (lng.ToLower().Trim().Equals("en"))
            {
                indexDir = FSDirectory.Open(new System.IO.DirectoryInfo(ConfigurationController.TempIndexRootPath + "/EN/IDX"));
                analyzer = new EnglishAnalyzer(ConfigurationController.Stop_Words);
            }
            if (lng.ToLower().Trim().Equals("he"))
            {
                indexDir = FSDirectory.Open(new System.IO.DirectoryInfo(ConfigurationController.TempIndexRootPath + "/HE/IDX"));
                analyzer = new MorphAnalyzer(ConfigurationController.MorphFilesPath);
            }

            LuceneDao dao = new LuceneDao();
            dao.Analizer = analyzer;

            dao.UpdateIndex(indexDir, lng);
        }