Esempio n. 1
0
        /// <summary>
        /// Creates an analzyer.
        /// </summary>
        /// <param name="name">Sets the name of the analyzer.</param>
        /// <param name="type">Sets the type of the analyzer.</param>
        public AnalyzerBase(string name, AnalyzerTypeEnum type)
        {
            if (string.IsNullOrWhiteSpace(name))
                throw new ArgumentNullException("name", "All analyzers require a name.");
            if (type == null)
                throw new ArgumentNullException("type", "All analzyers require a type.");

            Name = name;
            Type = type;
        }
 /// <summary>
 /// Create a language analyzer that allows stem exclusions.
 /// </summary>
 /// <param name="name">Sets the name of the language analyzer.</param>
 /// <param name="type">Sets the language analyzer type.</param>
 public StemExclusionLanguageAnalyzerBase(string name, AnalyzerTypeEnum type)
     : base(name, type)
 { }
Esempio n. 3
0
 /// <summary>
 /// This constructor is for items that inherit the StopAnalyzer.
 /// </summary>
 /// <param name="name">Sets the name of the analyzer.</param>
 /// <param name="type">Sets the type of the analyzer.</param>
 protected StopAnalyzer(string name, AnalyzerTypeEnum type) : base(name, type) { }
 /// <summary>
 /// Creates a language analyzer.
 /// </summary>
 /// <param name="name">Sets the name of the analyzer.</param>
 /// <param name="type">Sets the language analyzer type.</param>
 public LanguageAnalyzerBase(string name, AnalyzerTypeEnum type)
     : base(name, type)
 { }
    protected void Initialize()
    {
        string stopWordsScript = ScriptHelper.GetScript(@" function CheckAnalyzerOptions(){
        stopRow = document.getElementById('" + stopWordsRow.ClientID + @"');
        analyzerElem = document.getElementById('" + mDropDown.ClientID + @"');
        if ((analyzerElem.value == 'stop')||(analyzerElem.value == 'standard'))
        {
            stopRow.style.display = '';
        }
        else
        {
            stopRow.style.display = 'none';
        }

        customRow = document.getElementById('" + customAnalyzerAssemblyName.ClientID + @"');
        customRow2 = document.getElementById('" + customAnalyzerClassName.ClientID + @"');
        if (analyzerElem.value == 'custom')
        {
            customRow.style.display = '';
            customRow2.style.display = '';
        }
        else
        {
            customRow.style.display = 'none';
            customRow2.style.display = 'none';
        }
        }");

        mDropDown.Attributes.Add("onchange", "CheckAnalyzerOptions();");

        ScriptHelper.RegisterClientScriptBlock(this.Page, typeof(string), "StopWordsDropDown", stopWordsScript);

        if (!RequestHelper.IsPostBack())
        {
            string stopWordsDir = SearchIndexInfo.IndexPathPrefix + "_StopWords\\";
            if (Directory.Exists(stopWordsDir))
            {
                string[] files = Directory.GetFiles(stopWordsDir, "*.txt");

                if (files != null)
                {
                    foreach (string file in files)
                    {
                        string name  = file;
                        int    index = name.LastIndexOf('\\');
                        if (index > -1)
                        {
                            name = name.Substring(index + 1);
                        }

                        name = name.Substring(0, name.LastIndexOf('.'));

                        drpStopWords.Items.Add(new ListItem(name, name));
                    }
                }
            }

            drpStopWords.Items.Insert(0, new ListItem("(" + GetString("general.default") + ")", String.Empty));
        }

        bool hideCustom = true;
        bool hideStop   = true;

        AnalyzerTypeEnum type = SearchIndexInfoProvider.AnalyzerCodenameToEnum(mDropDown.SelectedValue);

        if ((!RequestHelper.IsPostBack()) && (mIndexInfo != null))
        {
            type = mIndexInfo.IndexAnalyzerType;
            txtCustomAnalyzerAssemblyName.Text = mIndexInfo.CustomAnalyzerAssemblyName;
            txtCustomAnalyzerClassName.Text    = mIndexInfo.CustomAnalyzerClassName;
            try
            {
                drpStopWords.SelectedValue = mIndexInfo.StopWordsFile;
            }
            catch
            {
            }
        }

        switch (type)
        {
        case AnalyzerTypeEnum.CustomAnalyzer:
            hideCustom = false;
            break;

        case AnalyzerTypeEnum.StandardAnalyzer:
        case AnalyzerTypeEnum.StopAnalyzer:
            hideStop = false;
            break;
        }

        stopWordsRow.Style.Clear();
        if (hideStop)
        {
            stopWordsRow.Style.Add("display", "none");
        }

        customAnalyzerAssemblyName.Style.Clear();
        customAnalyzerClassName.Style.Clear();

        if (hideCustom)
        {
            customAnalyzerAssemblyName.Style.Add("display", "none");
            customAnalyzerClassName.Style.Add("display", "none");
        }
    }