You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@lucenenet.apache.org by cc...@apache.org on 2013/04/03 19:40:31 UTC
[48/51] [partial] Mass convert mixed tabs to spaces
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/DistributedSearch/Distributed/Indexing/IndexSets.cs
----------------------------------------------------------------------
diff --git a/src/contrib/DistributedSearch/Distributed/Indexing/IndexSets.cs b/src/contrib/DistributedSearch/Distributed/Indexing/IndexSets.cs
index bf56282..e0403d8 100644
--- a/src/contrib/DistributedSearch/Distributed/Indexing/IndexSets.cs
+++ b/src/contrib/DistributedSearch/Distributed/Indexing/IndexSets.cs
@@ -48,26 +48,26 @@ namespace Lucene.Net.Distributed.Indexing
/// </code>
/// </summary>
public class IndexSets
- {
- private bool _bCompoundFile;
- private string _strDeltaDirectory;
- private IndexSet[] _arIndexSet;
+ {
+ private bool _bCompoundFile;
+ private string _strDeltaDirectory;
+ private IndexSet[] _arIndexSet;
/// <summary>
/// Accessor method for the configurable master indexes.
/// </summary>
public static IndexSets GetConfig
- {
+ {
get { return (IndexSets)ConfigurationManager.GetSection("IndexSets"); }
- }
+ }
/// <summary>
/// Strongly-typed array of IndexSet objects as defined in a configuration section.
/// </summary>
/// <param name="node">XmlNode definition for a given IndexSet</param>
public void LoadIndexSetArray(XmlNode node)
- {
- XmlAttributeCollection attributeCollection = node.Attributes;
+ {
+ XmlAttributeCollection attributeCollection = node.Attributes;
try
{
@@ -91,66 +91,66 @@ namespace Lucene.Net.Distributed.Indexing
throw new ConfigurationErrorsException("No indexset definitions found " + Environment.NewLine + node.OuterXml);
this._arIndexSet = new IndexSet[node.ChildNodes.Count];
- int x=0;
- foreach (XmlNode c in node.ChildNodes)
- {
- if (c.Name.ToLower()=="IndexSet")
- {
- IndexSet idxSet = new IndexSet(c);
- this._arIndexSet[x] = idxSet;
- x++;
- }
+ int x=0;
+ foreach (XmlNode c in node.ChildNodes)
+ {
+ if (c.Name.ToLower()=="IndexSet")
+ {
+ IndexSet idxSet = new IndexSet(c);
+ this._arIndexSet[x] = idxSet;
+ x++;
+ }
- }
- }
+ }
+ }
/// <summary>
/// Public constructor for IndexSets. An IndexSet is defined in XML configuration
/// and is loaded via a custom configuration handler.
/// </summary>
public IndexSets()
- {
- }
+ {
+ }
/// <summary>
/// Indicates if the indexes under configuration should be built in the Compound format.
/// </summary>
- public bool CompoundFile
- {
- get {return this._bCompoundFile;}
- }
+ public bool CompoundFile
+ {
+ get {return this._bCompoundFile;}
+ }
/// <summary>
/// Filesystem location of where pending update IndexDocuments are retrieved.
/// </summary>
- public string DeltaDirectory
- {
- get {return this._strDeltaDirectory;}
- }
+ public string DeltaDirectory
+ {
+ get {return this._strDeltaDirectory;}
+ }
/// <summary>
/// Strongly-typed array of IndexSet objects as defined in a configuration section.
/// </summary>
public IndexSet[] IndexSetArray
- {
- get {return this._arIndexSet;}
- }
+ {
+ get {return this._arIndexSet;}
+ }
/// <summary>
/// Returns an IndexSet object for a given IndexDocument id value
/// </summary>
/// <param name="deleteId">Id value of the IndexDocument</param>
/// <returns>The IndexSet containing the referenced IndexDocument</returns>
- public IndexSet GetIndexSet(int deleteId)
- {
- IndexSet getSet=null;
- foreach(IndexSet idxSet in this._arIndexSet)
- {
- if ((deleteId>=idxSet.BottomId)&&(deleteId<=idxSet.TopId))
- getSet=idxSet;
- }
- return getSet;
- }
+ public IndexSet GetIndexSet(int deleteId)
+ {
+ IndexSet getSet=null;
+ foreach(IndexSet idxSet in this._arIndexSet)
+ {
+ if ((deleteId>=idxSet.BottomId)&&(deleteId<=idxSet.TopId))
+ getSet=idxSet;
+ }
+ return getSet;
+ }
/// <summary>
/// Queries the DeltaDirectory to access any IndexDocument files. All IndexDocuments
@@ -159,112 +159,112 @@ namespace Lucene.Net.Distributed.Indexing
/// IndexSet.
/// </summary>
/// <param name="sourceDir">Filesystem path to the DeltaDirectory</param>
- public void LoadIndexDocuments(string sourceDir)
- {
- DirectoryInfo oDirectoryInfo = new DirectoryInfo(sourceDir);
- FileInfo[] arFiles = oDirectoryInfo.GetFiles("*.bin");
- Array.Sort(arFiles, new FileNameComparer());
- IndexSet idxSet;
+ public void LoadIndexDocuments(string sourceDir)
+ {
+ DirectoryInfo oDirectoryInfo = new DirectoryInfo(sourceDir);
+ FileInfo[] arFiles = oDirectoryInfo.GetFiles("*.bin");
+ Array.Sort(arFiles, new FileNameComparer());
+ IndexSet idxSet;
- foreach (FileInfo fi in arFiles)
- {
- FileStream fs = new FileStream(fi.FullName, FileMode.Open);
- IndexDocument iDoc = (IndexDocument)IndexDocument.Formatter.Deserialize(fs);
+ foreach (FileInfo fi in arFiles)
+ {
+ FileStream fs = new FileStream(fi.FullName, FileMode.Open);
+ IndexDocument iDoc = (IndexDocument)IndexDocument.Formatter.Deserialize(fs);
- idxSet = this.GetIndexSet(iDoc.RecordId);
- if (idxSet != null)
- {
- idxSet.FileSystemDocuments.Add(fi.FullName);
- if (idxSet.IndexDocuments.ContainsKey(iDoc.RecordId))
- {
- IndexDocument curDoc = (IndexDocument)idxSet.IndexDocuments[iDoc.RecordId];
- idxSet.IndexDocuments.Add(iDoc.RecordId, iDoc);
- }
- else
- idxSet.IndexDocuments.Add(iDoc.RecordId, iDoc);
- }
- else
- {
- //Handling exceptions -- write file out somewhere else?
- if (ConfigurationManager.AppSettings["ExceptionsBasePath"] != null)
- iDoc.Save(ConfigurationManager.AppSettings["ExceptionsBasePath"]);
- }
- fs.Close();
- }
- oDirectoryInfo=null;
- arFiles=null;
- }
+ idxSet = this.GetIndexSet(iDoc.RecordId);
+ if (idxSet != null)
+ {
+ idxSet.FileSystemDocuments.Add(fi.FullName);
+ if (idxSet.IndexDocuments.ContainsKey(iDoc.RecordId))
+ {
+ IndexDocument curDoc = (IndexDocument)idxSet.IndexDocuments[iDoc.RecordId];
+ idxSet.IndexDocuments.Add(iDoc.RecordId, iDoc);
+ }
+ else
+ idxSet.IndexDocuments.Add(iDoc.RecordId, iDoc);
+ }
+ else
+ {
+ //Handling exceptions -- write file out somewhere else?
+ if (ConfigurationManager.AppSettings["ExceptionsBasePath"] != null)
+ iDoc.Save(ConfigurationManager.AppSettings["ExceptionsBasePath"]);
+ }
+ fs.Close();
+ }
+ oDirectoryInfo=null;
+ arFiles=null;
+ }
/// <summary>
/// Method to apply pending updates (additions & deletions) for all configured IndexSet objects.
/// </summary>
- public void ProcessIndexDocuments()
- {
- foreach(IndexSet idxSet in this._arIndexSet)
- {
- if (idxSet.IndexDocuments.Count>0)
- {
- idxSet.CurrentIndex.ProcessLocalIndexDeletes(idxSet.GetDeletionCollection());
- idxSet.CurrentIndex.ProcessLocalIndexAdditions(idxSet.Analzyer, idxSet.Documents, this.CompoundFile);
- }
- }
- }
+ public void ProcessIndexDocuments()
+ {
+ foreach(IndexSet idxSet in this._arIndexSet)
+ {
+ if (idxSet.IndexDocuments.Count>0)
+ {
+ idxSet.CurrentIndex.ProcessLocalIndexDeletes(idxSet.GetDeletionCollection());
+ idxSet.CurrentIndex.ProcessLocalIndexAdditions(idxSet.Analzyer, idxSet.Documents, this.CompoundFile);
+ }
+ }
+ }
/// <summary>
/// Method to apply updated index files from master index to slave indexes
/// </summary>
- public void CopyUpdatedFiles()
- {
- Hashtable htUpdates = new Hashtable();
- bool bCopy=false;
+ public void CopyUpdatedFiles()
+ {
+ Hashtable htUpdates = new Hashtable();
+ bool bCopy=false;
foreach (IndexSet idxSet in this._arIndexSet)
- {
- bCopy=false;
- if (idxSet.CurrentIndex!=null && idxSet.CurrentIndex.CanCopy)
- bCopy=idxSet.CurrentIndex.CopyIncremental();
- if (bCopy && !htUpdates.ContainsKey(idxSet.CurrentIndex.StatusDirectory))
- htUpdates.Add(idxSet.CurrentIndex.StatusDirectory, idxSet.CurrentIndex);
- }
+ {
+ bCopy=false;
+ if (idxSet.CurrentIndex!=null && idxSet.CurrentIndex.CanCopy)
+ bCopy=idxSet.CurrentIndex.CopyIncremental();
+ if (bCopy && !htUpdates.ContainsKey(idxSet.CurrentIndex.StatusDirectory))
+ htUpdates.Add(idxSet.CurrentIndex.StatusDirectory, idxSet.CurrentIndex);
+ }
- foreach(DictionaryEntry de in htUpdates)
- {
- string sTargetDir = de.Key.ToString();
- CurrentIndex ci = (CurrentIndex)de.Value;
- ci.UpdateRefresh();
- }
- }
+ foreach(DictionaryEntry de in htUpdates)
+ {
+ string sTargetDir = de.Key.ToString();
+ CurrentIndex ci = (CurrentIndex)de.Value;
+ ci.UpdateRefresh();
+ }
+ }
/// <summary>
/// Method to apply updated index files from master index to slave indexes
/// </summary>
/// <returns>Hashtable of updated indexes</returns>
- public Hashtable CopyAllFiles()
- {
- Hashtable htUpdates = new Hashtable();
- bool bCopy = false;
+ public Hashtable CopyAllFiles()
+ {
+ Hashtable htUpdates = new Hashtable();
+ bool bCopy = false;
foreach (IndexSet idxSet in this._arIndexSet)
- {
- bCopy = false;
- if (idxSet.CurrentIndex != null && idxSet.CurrentIndex.CanCopy)
- bCopy = idxSet.CurrentIndex.Copy();
- if (bCopy && !htUpdates.ContainsKey(idxSet.CurrentIndex.StatusDirectory))
- htUpdates.Add(idxSet.CurrentIndex.StatusDirectory, idxSet.CurrentIndex);
- }
+ {
+ bCopy = false;
+ if (idxSet.CurrentIndex != null && idxSet.CurrentIndex.CanCopy)
+ bCopy = idxSet.CurrentIndex.Copy();
+ if (bCopy && !htUpdates.ContainsKey(idxSet.CurrentIndex.StatusDirectory))
+ htUpdates.Add(idxSet.CurrentIndex.StatusDirectory, idxSet.CurrentIndex);
+ }
- foreach (DictionaryEntry de in htUpdates)
- {
- string sTargetDir = de.Key.ToString();
- CurrentIndex ci = (CurrentIndex)de.Value;
- ci.UpdateRefresh();
- }
+ foreach (DictionaryEntry de in htUpdates)
+ {
+ string sTargetDir = de.Key.ToString();
+ CurrentIndex ci = (CurrentIndex)de.Value;
+ ci.UpdateRefresh();
+ }
- return htUpdates;
- }
+ return htUpdates;
+ }
/// <summary>
/// Method to execute an index optimization for each configured IndexSet object
/// </summary>
- public void OptimizeIndexes()
+ public void OptimizeIndexes()
{
foreach (IndexSet idxSet in this._arIndexSet)
idxSet.Optimize();
@@ -274,20 +274,20 @@ namespace Lucene.Net.Distributed.Indexing
/// Method to finalize update process for each IndexSet object
/// </summary>
public void CompleteUpdate()
- {
+ {
foreach (IndexSet idxSet in this._arIndexSet)
- {
- if (idxSet.FileSystemDocuments.Count>0)
- {
- foreach(string s in idxSet.FileSystemDocuments)
- {
- FileInfo fi = new FileInfo(s);
- fi.Delete();
- }
- idxSet.Reset();
- }
- }
- }
+ {
+ if (idxSet.FileSystemDocuments.Count>0)
+ {
+ foreach(string s in idxSet.FileSystemDocuments)
+ {
+ FileInfo fi = new FileInfo(s);
+ fi.Delete();
+ }
+ idxSet.Reset();
+ }
+ }
+ }
- }
+ }
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/DistributedSearch/Distributed/Search/DistributedSearchable.cs
----------------------------------------------------------------------
diff --git a/src/contrib/DistributedSearch/Distributed/Search/DistributedSearchable.cs b/src/contrib/DistributedSearch/Distributed/Search/DistributedSearchable.cs
index 87d7665..3488e26 100644
--- a/src/contrib/DistributedSearch/Distributed/Search/DistributedSearchable.cs
+++ b/src/contrib/DistributedSearch/Distributed/Search/DistributedSearchable.cs
@@ -53,19 +53,19 @@ namespace Lucene.Net.Distributed.Search
public override object InitializeLifetimeService()
{
DistributedSearchable.leaseTimeSpan = new TimeSpan(0, 0, DistributedSearchable.initialLeaseTime + DistributedSearchable.TIME_FACTOR);
- if (DistributedSearchable.initialLeaseTime == -1)
- {
- return null; //Permanent TTL; never get's GC'd
- }
- else
- {
- ILease oLease = (ILease) base.InitializeLifetimeService();
- if (oLease.CurrentState == LeaseState.Initial)
- {
- oLease.InitialLeaseTime = TimeSpan.FromSeconds(DistributedSearchable.leaseTimeSpan.TotalSeconds);
- oLease.RenewOnCallTime = TimeSpan.FromSeconds(DistributedSearchable.TIME_FACTOR);
- }
- return oLease;
+ if (DistributedSearchable.initialLeaseTime == -1)
+ {
+ return null; //Permanent TTL; never get's GC'd
+ }
+ else
+ {
+ ILease oLease = (ILease) base.InitializeLifetimeService();
+ if (oLease.CurrentState == LeaseState.Initial)
+ {
+ oLease.InitialLeaseTime = TimeSpan.FromSeconds(DistributedSearchable.leaseTimeSpan.TotalSeconds);
+ oLease.RenewOnCallTime = TimeSpan.FromSeconds(DistributedSearchable.TIME_FACTOR);
+ }
+ return oLease;
}
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/DistributedSearch/LuceneMonitor/LuceneMonitor.cs
----------------------------------------------------------------------
diff --git a/src/contrib/DistributedSearch/LuceneMonitor/LuceneMonitor.cs b/src/contrib/DistributedSearch/LuceneMonitor/LuceneMonitor.cs
index 153d6f7..e36beb7 100644
--- a/src/contrib/DistributedSearch/LuceneMonitor/LuceneMonitor.cs
+++ b/src/contrib/DistributedSearch/LuceneMonitor/LuceneMonitor.cs
@@ -36,149 +36,149 @@ namespace Lucene.Net.Distributed.Operations
/// <summary>
/// A Windows service that provides system ping checking against LuceneServer.
/// </summary>
- public class LuceneMonitor : System.ServiceProcess.ServiceBase
- {
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
- private ServiceController scMonitor = new ServiceController();
- private Thread serviceThread;
- private int sleepTime = 5000;
- private bool bRun = true;
- private string ipAddress = "";
- private int port = 0;
- private static readonly log4net.ILog oLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
+ public class LuceneMonitor : System.ServiceProcess.ServiceBase
+ {
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.Container components = null;
+ private ServiceController scMonitor = new ServiceController();
+ private Thread serviceThread;
+ private int sleepTime = 5000;
+ private bool bRun = true;
+ private string ipAddress = "";
+ private int port = 0;
+ private static readonly log4net.ILog oLog = log4net.LogManager.GetLogger(System.Reflection.MethodBase.GetCurrentMethod().DeclaringType);
public LuceneMonitor()
- {
- // This call is required by the Windows.Forms Component Designer.
- InitializeComponent();
+ {
+ // This call is required by the Windows.Forms Component Designer.
+ InitializeComponent();
- // TODO: Add any initialization after the InitComponent call
- }
+ // TODO: Add any initialization after the InitComponent call
+ }
- // The main entry point for the process
- static void Main()
- {
- System.ServiceProcess.ServiceBase[] ServicesToRun;
+ // The main entry point for the process
+ static void Main()
+ {
+ System.ServiceProcess.ServiceBase[] ServicesToRun;
ServicesToRun = new System.ServiceProcess.ServiceBase[] { new LuceneMonitor() };
- System.ServiceProcess.ServiceBase.Run(ServicesToRun);
- }
-
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- components = new System.ComponentModel.Container();
- this.ServiceName = "LuceneMonitor";
- }
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if (components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
-
- /// <summary>
- /// Set things in motion so your service can do its work.
- /// </summary>
- protected override void OnStart(string[] args)
- {
- ThreadStart threadStart = new ThreadStart(MonitorService);
- serviceThread = new Thread(threadStart);
- serviceThread.Start();
- }
-
- private void LogMessage(string message)
- {
- this.LogMessage(message, Level.Info);
- }
- private void LogMessage(string message, Level msgLevel)
- {
- if (msgLevel==Level.Info)
- {
- if (oLog.IsInfoEnabled)
- oLog.Info(message);
- }
- else if (msgLevel==Level.Warn)
- {
- if (oLog.IsWarnEnabled)
- oLog.Warn(message);
- }
- }
- private void LogMessage(string message, Level msgLevel, int ErrorLevel)
- {
- if (msgLevel==Level.Error)
- {
- if (oLog.IsErrorEnabled)
- {
- oLog.Error(message);
- EventLog.WriteEntry(this.ServiceName, message, EventLogEntryType.Error, ErrorLevel);
- }
- }
- }
-
- private void MonitorService()
- {
- this.LogMessage(this.ServiceName+" started");
- scMonitor.ServiceName="LuceneServer";
+ System.ServiceProcess.ServiceBase.Run(ServicesToRun);
+ }
+
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ components = new System.ComponentModel.Container();
+ this.ServiceName = "LuceneMonitor";
+ }
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if (components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+ /// <summary>
+ /// Set things in motion so your service can do its work.
+ /// </summary>
+ protected override void OnStart(string[] args)
+ {
+ ThreadStart threadStart = new ThreadStart(MonitorService);
+ serviceThread = new Thread(threadStart);
+ serviceThread.Start();
+ }
+
+ private void LogMessage(string message)
+ {
+ this.LogMessage(message, Level.Info);
+ }
+ private void LogMessage(string message, Level msgLevel)
+ {
+ if (msgLevel==Level.Info)
+ {
+ if (oLog.IsInfoEnabled)
+ oLog.Info(message);
+ }
+ else if (msgLevel==Level.Warn)
+ {
+ if (oLog.IsWarnEnabled)
+ oLog.Warn(message);
+ }
+ }
+ private void LogMessage(string message, Level msgLevel, int ErrorLevel)
+ {
+ if (msgLevel==Level.Error)
+ {
+ if (oLog.IsErrorEnabled)
+ {
+ oLog.Error(message);
+ EventLog.WriteEntry(this.ServiceName, message, EventLogEntryType.Error, ErrorLevel);
+ }
+ }
+ }
+
+ private void MonitorService()
+ {
+ this.LogMessage(this.ServiceName+" started");
+ scMonitor.ServiceName="LuceneServer";
this.sleepTime = (ConfigurationManager.AppSettings["ServiceSleepTime"] != null ? Convert.ToInt32(ConfigurationManager.AppSettings["ServiceSleepTime"]) : this.sleepTime);
this.ipAddress = (ConfigurationManager.AppSettings["IPAddress"] != null ? ConfigurationManager.AppSettings["IPAddress"] : "");
this.port = (ConfigurationManager.AppSettings["Port"] != null ? Convert.ToInt32(ConfigurationManager.AppSettings["Port"]) : 0);
- this.LogMessage("ServiceSleepTime = "+this.sleepTime.ToString()+"; ipAddress="+this.ipAddress+"; port="+this.port.ToString());
-
- while (bRun)
- {
- this.CheckService();
- Thread.Sleep(sleepTime);
- }
- }
-
- private void CheckService()
- {
- try
- {
- scMonitor.Refresh();
-
- if (scMonitor.Status.Equals(ServiceControllerStatus.StopPending))
- scMonitor.WaitForStatus(ServiceControllerStatus.Stopped);
-
- if (scMonitor.Status.Equals(ServiceControllerStatus.Stopped))
- {
- // Start the service if the current status is stopped.
- foreach (IChannel ic in ChannelServices.RegisteredChannels)
- ChannelServices.UnregisterChannel(ic);
- scMonitor.Start();
- this.LogMessage(scMonitor.ServiceName + " started (Service stopped or StopPending)", Level.Error, 99);
- }
- }
- catch (Exception e)
- {
- this.LogMessage(scMonitor.ServiceName + " error: "+e.Message+e.StackTrace, Level.Error, 199);
- }
-
- }
-
-
- /// <summary>
- /// Stop this service.
- /// </summary>
- protected override void OnStop()
- {
- this.bRun=false;
- }
- }
+ this.LogMessage("ServiceSleepTime = "+this.sleepTime.ToString()+"; ipAddress="+this.ipAddress+"; port="+this.port.ToString());
+
+ while (bRun)
+ {
+ this.CheckService();
+ Thread.Sleep(sleepTime);
+ }
+ }
+
+ private void CheckService()
+ {
+ try
+ {
+ scMonitor.Refresh();
+
+ if (scMonitor.Status.Equals(ServiceControllerStatus.StopPending))
+ scMonitor.WaitForStatus(ServiceControllerStatus.Stopped);
+
+ if (scMonitor.Status.Equals(ServiceControllerStatus.Stopped))
+ {
+ // Start the service if the current status is stopped.
+ foreach (IChannel ic in ChannelServices.RegisteredChannels)
+ ChannelServices.UnregisterChannel(ic);
+ scMonitor.Start();
+ this.LogMessage(scMonitor.ServiceName + " started (Service stopped or StopPending)", Level.Error, 99);
+ }
+ }
+ catch (Exception e)
+ {
+ this.LogMessage(scMonitor.ServiceName + " error: "+e.Message+e.StackTrace, Level.Error, 199);
+ }
+
+ }
+
+
+ /// <summary>
+ /// Stop this service.
+ /// </summary>
+ protected override void OnStop()
+ {
+ this.bRun=false;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/DistributedSearch/LuceneMonitor/ProjectInstaller.cs
----------------------------------------------------------------------
diff --git a/src/contrib/DistributedSearch/LuceneMonitor/ProjectInstaller.cs b/src/contrib/DistributedSearch/LuceneMonitor/ProjectInstaller.cs
index b802cb0..9b635b5 100644
--- a/src/contrib/DistributedSearch/LuceneMonitor/ProjectInstaller.cs
+++ b/src/contrib/DistributedSearch/LuceneMonitor/ProjectInstaller.cs
@@ -24,118 +24,118 @@ using Microsoft.Win32;
namespace LuceneMonitorInstall
{
- /// <summary>
- /// Summary description for ProjectInstaller.
- /// </summary>
- [RunInstallerAttribute(true)]
- public class ProjectInstaller : Installer
- {
- private ServiceProcessInstaller processInstaller;
- private ServiceInstaller serviceInstaller;
- /// <summary>
- /// Required designer variable.
- /// </summary>
- private System.ComponentModel.Container components = null;
-
- public ProjectInstaller()
- {
- // This call is required by the Designer.
- InitializeComponent();
-
- // TODO: Add any initialization after the InitializeComponent call
- }
-
- /// <summary>
- /// Clean up any resources being used.
- /// </summary>
- protected override void Dispose( bool disposing )
- {
- if( disposing )
- {
- if(components != null)
- {
- components.Dispose();
- }
- }
- base.Dispose( disposing );
- }
-
-
- #region Component Designer generated code
- /// <summary>
- /// Required method for Designer support - do not modify
- /// the contents of this method with the code editor.
- /// </summary>
- private void InitializeComponent()
- {
- this.processInstaller = new ServiceProcessInstaller();
- this.serviceInstaller = new ServiceInstaller();
- this.processInstaller.Account = ServiceAccount.LocalSystem;
-
- this.serviceInstaller.ServiceName = "LuceneMonitor";
- this.serviceInstaller.StartType = ServiceStartMode.Manual;
-
- Installers.Add(this.processInstaller);
- Installers.Add(this.serviceInstaller);
-
- }
- #endregion
-
- public override void Install(IDictionary stateSaver)
- {
- RegistryKey system;
- RegistryKey currentControlSet; //HKEY_LOCAL_MACHINE\Services\CurrentControlSet
- RegistryKey services; //...\Services
- RegistryKey service; //...\<Service Name>
-
- try
- {
- //Let the project installer do its job
- base.Install(stateSaver);
-
- system = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("System"); //Open the HKEY_LOCAL_MACHINE\SYSTEM key
- currentControlSet = system.OpenSubKey("CurrentControlSet"); //Open CurrentControlSet
- services = currentControlSet.OpenSubKey("Services"); //Go to the services key
- service = services.OpenSubKey(this.serviceInstaller.ServiceName, true); //Open the key for serviceInstaller
-
- service.SetValue("Description", "Lucene Monitor");
-
-
- }
- catch(Exception e)
- {
- Console.WriteLine("An exception was thrown during service installation:\n" + e.ToString());
- }
- }
-
- public override void Uninstall(IDictionary savedState)
- {
- RegistryKey system;
- RegistryKey currentControlSet; //HKEY_LOCAL_MACHINE\Services\CurrentControlSet
- RegistryKey services; //...\Services
- RegistryKey service; //...\<Service Name>
-
- try
- {
- //Drill down to the service key and open it with write permission
- system = Registry.LocalMachine.OpenSubKey("System");
- currentControlSet = system.OpenSubKey("CurrentControlSet");
- services = currentControlSet.OpenSubKey("Services");
- service = services.OpenSubKey(this.serviceInstaller.ServiceName, true);
- service.DeleteSubKeyTree("Description"); //Delete keys created during installation
-
- }
- catch(Exception e)
- {
- Console.WriteLine("Exception encountered while uninstalling service:\n" + e.ToString());
- }
- finally
- {
- //Let the project installer do its job
- base.Uninstall(savedState);
- }
- }
-
-
- }
+ /// <summary>
+ /// Summary description for ProjectInstaller.
+ /// </summary>
+ [RunInstallerAttribute(true)]
+ public class ProjectInstaller : Installer
+ {
+ private ServiceProcessInstaller processInstaller;
+ private ServiceInstaller serviceInstaller;
+ /// <summary>
+ /// Required designer variable.
+ /// </summary>
+ private System.ComponentModel.Container components = null;
+
+ public ProjectInstaller()
+ {
+ // This call is required by the Designer.
+ InitializeComponent();
+
+ // TODO: Add any initialization after the InitializeComponent call
+ }
+
+ /// <summary>
+ /// Clean up any resources being used.
+ /// </summary>
+ protected override void Dispose( bool disposing )
+ {
+ if( disposing )
+ {
+ if(components != null)
+ {
+ components.Dispose();
+ }
+ }
+ base.Dispose( disposing );
+ }
+
+
+ #region Component Designer generated code
+ /// <summary>
+ /// Required method for Designer support - do not modify
+ /// the contents of this method with the code editor.
+ /// </summary>
+ private void InitializeComponent()
+ {
+ this.processInstaller = new ServiceProcessInstaller();
+ this.serviceInstaller = new ServiceInstaller();
+ this.processInstaller.Account = ServiceAccount.LocalSystem;
+
+ this.serviceInstaller.ServiceName = "LuceneMonitor";
+ this.serviceInstaller.StartType = ServiceStartMode.Manual;
+
+ Installers.Add(this.processInstaller);
+ Installers.Add(this.serviceInstaller);
+
+ }
+ #endregion
+
+ public override void Install(IDictionary stateSaver)
+ {
+ RegistryKey system;
+ RegistryKey currentControlSet; //HKEY_LOCAL_MACHINE\Services\CurrentControlSet
+ RegistryKey services; //...\Services
+ RegistryKey service; //...\<Service Name>
+
+ try
+ {
+ //Let the project installer do its job
+ base.Install(stateSaver);
+
+ system = Microsoft.Win32.Registry.LocalMachine.OpenSubKey("System"); //Open the HKEY_LOCAL_MACHINE\SYSTEM key
+ currentControlSet = system.OpenSubKey("CurrentControlSet"); //Open CurrentControlSet
+ services = currentControlSet.OpenSubKey("Services"); //Go to the services key
+ service = services.OpenSubKey(this.serviceInstaller.ServiceName, true); //Open the key for serviceInstaller
+
+ service.SetValue("Description", "Lucene Monitor");
+
+
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("An exception was thrown during service installation:\n" + e.ToString());
+ }
+ }
+
+ public override void Uninstall(IDictionary savedState)
+ {
+ RegistryKey system;
+ RegistryKey currentControlSet; //HKEY_LOCAL_MACHINE\Services\CurrentControlSet
+ RegistryKey services; //...\Services
+ RegistryKey service; //...\<Service Name>
+
+ try
+ {
+ //Drill down to the service key and open it with write permission
+ system = Registry.LocalMachine.OpenSubKey("System");
+ currentControlSet = system.OpenSubKey("CurrentControlSet");
+ services = currentControlSet.OpenSubKey("Services");
+ service = services.OpenSubKey(this.serviceInstaller.ServiceName, true);
+ service.DeleteSubKeyTree("Description"); //Delete keys created during installation
+
+ }
+ catch(Exception e)
+ {
+ Console.WriteLine("Exception encountered while uninstalling service:\n" + e.ToString());
+ }
+ finally
+ {
+ //Let the project installer do its job
+ base.Uninstall(savedState);
+ }
+ }
+
+
+ }
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/FastVectorHighlighter/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/src/contrib/FastVectorHighlighter/Properties/AssemblyInfo.cs b/src/contrib/FastVectorHighlighter/Properties/AssemblyInfo.cs
index 9a545d9..e44909c 100644
--- a/src/contrib/FastVectorHighlighter/Properties/AssemblyInfo.cs
+++ b/src/contrib/FastVectorHighlighter/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/FastVectorHighlighter/StringUtils.cs
----------------------------------------------------------------------
diff --git a/src/contrib/FastVectorHighlighter/StringUtils.cs b/src/contrib/FastVectorHighlighter/StringUtils.cs
index 7b27259..995d714 100644
--- a/src/contrib/FastVectorHighlighter/StringUtils.cs
+++ b/src/contrib/FastVectorHighlighter/StringUtils.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/FastVectorHighlighter/VectorHighlightMapper.cs
----------------------------------------------------------------------
diff --git a/src/contrib/FastVectorHighlighter/VectorHighlightMapper.cs b/src/contrib/FastVectorHighlighter/VectorHighlightMapper.cs
index da2966c..c9c6ced 100644
--- a/src/contrib/FastVectorHighlighter/VectorHighlightMapper.cs
+++ b/src/contrib/FastVectorHighlighter/VectorHighlightMapper.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Highlighter/DefaultEncoder.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Highlighter/DefaultEncoder.cs b/src/contrib/Highlighter/DefaultEncoder.cs
index 54500a5..ff1efb7 100644
--- a/src/contrib/Highlighter/DefaultEncoder.cs
+++ b/src/contrib/Highlighter/DefaultEncoder.cs
@@ -17,12 +17,12 @@
namespace Lucene.Net.Search.Highlight
{
- /// <summary>Simple <see cref="IEncoder"/> implementation that does not modify the output</summary>
- public class DefaultEncoder : IEncoder
- {
- public virtual System.String EncodeText(System.String originalText)
- {
- return originalText;
- }
- }
+ /// <summary>Simple <see cref="IEncoder"/> implementation that does not modify the output</summary>
+ public class DefaultEncoder : IEncoder
+ {
+ public virtual System.String EncodeText(System.String originalText)
+ {
+ return originalText;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Highlighter/GradientFormatter.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Highlighter/GradientFormatter.cs b/src/contrib/Highlighter/GradientFormatter.cs
index 6b102a0..3b50d42 100644
--- a/src/contrib/Highlighter/GradientFormatter.cs
+++ b/src/contrib/Highlighter/GradientFormatter.cs
@@ -19,194 +19,194 @@ using System;
namespace Lucene.Net.Search.Highlight
{
- /// <summary>
- /// Formats text with different color intensity depending on the score of the term.
- /// </summary>
- public class GradientFormatter : IFormatter
- {
- private float maxScore;
+ /// <summary>
+ /// Formats text with different color intensity depending on the score of the term.
+ /// </summary>
+ public class GradientFormatter : IFormatter
+ {
+ private float maxScore;
protected internal int fgRMin, fgGMin, fgBMin;
protected internal int fgRMax, fgGMax, fgBMax;
- protected bool highlightForeground;
+ protected bool highlightForeground;
protected internal int bgRMin, bgGMin, bgBMin;
protected internal int bgRMax, bgGMax, bgBMax;
- protected bool highlightBackground;
-
- /// <summary> Sets the color range for the IDF scores</summary>
+ protected bool highlightBackground;
+
+ /// <summary> Sets the color range for the IDF scores</summary>
/// <param name="maxScore">
- /// The score (and above) displayed as maxColor (See QueryScorer.getMaxWeight
- /// which can be used to callibrate scoring scale)
- /// </param>
+ /// The score (and above) displayed as maxColor (See QueryScorer.getMaxWeight
+ /// which can be used to callibrate scoring scale)
+ /// </param>
/// <param name="minForegroundColor">
- /// The hex color used for representing IDF scores of zero eg
- /// #FFFFFF (white) or null if no foreground color required
- /// </param>
+ /// The hex color used for representing IDF scores of zero eg
+ /// #FFFFFF (white) or null if no foreground color required
+ /// </param>
/// <param name="maxForegroundColor">
- /// The largest hex color used for representing IDF scores eg
- /// #000000 (black) or null if no foreground color required
- /// </param>
+ /// The largest hex color used for representing IDF scores eg
+ /// #000000 (black) or null if no foreground color required
+ /// </param>
/// <param name="minBackgroundColor">
- /// The hex color used for representing IDF scores of zero eg
- /// #FFFFFF (white) or null if no background color required
- /// </param>
+ /// The hex color used for representing IDF scores of zero eg
+ /// #FFFFFF (white) or null if no background color required
+ /// </param>
/// <param name="maxBackgroundColor">
- /// The largest hex color used for representing IDF scores eg
- /// #000000 (black) or null if no background color required
- /// </param>
- public GradientFormatter(float maxScore, string minForegroundColor, string maxForegroundColor, string minBackgroundColor, string maxBackgroundColor)
- {
- highlightForeground = (minForegroundColor != null) && (maxForegroundColor != null);
+ /// The largest hex color used for representing IDF scores eg
+ /// #000000 (black) or null if no background color required
+ /// </param>
+ public GradientFormatter(float maxScore, string minForegroundColor, string maxForegroundColor, string minBackgroundColor, string maxBackgroundColor)
+ {
+ highlightForeground = (minForegroundColor != null) && (maxForegroundColor != null);
if (highlightForeground)
- {
- if (minForegroundColor.Length != 7)
- {
- throw new ArgumentException("minForegroundColor is not 7 bytes long eg a hex " + "RGB value such as #FFFFFF");
- }
- if (maxForegroundColor.Length != 7)
- {
- throw new ArgumentException("minForegroundColor is not 7 bytes long eg a hex " + "RGB value such as #FFFFFF");
- }
- fgRMin = HexToInt(minForegroundColor.Substring(1, 2));
- fgGMin = HexToInt(minForegroundColor.Substring(3, 2));
- fgBMin = HexToInt(minForegroundColor.Substring(5, 2));
-
- fgRMax = HexToInt(maxForegroundColor.Substring(1, 2));
- fgGMax = HexToInt(maxForegroundColor.Substring(3, 2));
- fgBMax = HexToInt(maxForegroundColor.Substring(5, 2));
- }
-
- highlightBackground = (minBackgroundColor != null) && (maxBackgroundColor != null);
- if (highlightBackground)
- {
- if (minBackgroundColor.Length != 7)
- {
- throw new System.ArgumentException("minBackgroundColor is not 7 bytes long eg a hex " + "RGB value such as #FFFFFF");
- }
- if (maxBackgroundColor.Length != 7)
- {
- throw new System.ArgumentException("minBackgroundColor is not 7 bytes long eg a hex " + "RGB value such as #FFFFFF");
- }
- bgRMin = HexToInt(minBackgroundColor.Substring(1, 2));
- bgGMin = HexToInt(minBackgroundColor.Substring(3, 2));
- bgBMin = HexToInt(minBackgroundColor.Substring(5, 2));
-
- bgRMax = HexToInt(maxBackgroundColor.Substring(1, 2));
- bgGMax = HexToInt(maxBackgroundColor.Substring(3, 2));
- bgBMax = HexToInt(maxBackgroundColor.Substring(5, 2));
- }
- // this.corpusReader = corpusReader;
- this.maxScore = maxScore;
- // totalNumDocs = corpusReader.numDocs();
- }
-
- public virtual string HighlightTerm(string originalText, TokenGroup tokenGroup)
- {
- if (tokenGroup.TotalScore == 0)
- return originalText;
- float score = tokenGroup.TotalScore;
- if (score == 0)
- {
- return originalText;
- }
+ {
+ if (minForegroundColor.Length != 7)
+ {
+ throw new ArgumentException("minForegroundColor is not 7 bytes long eg a hex " + "RGB value such as #FFFFFF");
+ }
+ if (maxForegroundColor.Length != 7)
+ {
+ throw new ArgumentException("minForegroundColor is not 7 bytes long eg a hex " + "RGB value such as #FFFFFF");
+ }
+ fgRMin = HexToInt(minForegroundColor.Substring(1, 2));
+ fgGMin = HexToInt(minForegroundColor.Substring(3, 2));
+ fgBMin = HexToInt(minForegroundColor.Substring(5, 2));
+
+ fgRMax = HexToInt(maxForegroundColor.Substring(1, 2));
+ fgGMax = HexToInt(maxForegroundColor.Substring(3, 2));
+ fgBMax = HexToInt(maxForegroundColor.Substring(5, 2));
+ }
+
+ highlightBackground = (minBackgroundColor != null) && (maxBackgroundColor != null);
+ if (highlightBackground)
+ {
+ if (minBackgroundColor.Length != 7)
+ {
+ throw new System.ArgumentException("minBackgroundColor is not 7 bytes long eg a hex " + "RGB value such as #FFFFFF");
+ }
+ if (maxBackgroundColor.Length != 7)
+ {
+ throw new System.ArgumentException("minBackgroundColor is not 7 bytes long eg a hex " + "RGB value such as #FFFFFF");
+ }
+ bgRMin = HexToInt(minBackgroundColor.Substring(1, 2));
+ bgGMin = HexToInt(minBackgroundColor.Substring(3, 2));
+ bgBMin = HexToInt(minBackgroundColor.Substring(5, 2));
+
+ bgRMax = HexToInt(maxBackgroundColor.Substring(1, 2));
+ bgGMax = HexToInt(maxBackgroundColor.Substring(3, 2));
+ bgBMax = HexToInt(maxBackgroundColor.Substring(5, 2));
+ }
+ // this.corpusReader = corpusReader;
+ this.maxScore = maxScore;
+ // totalNumDocs = corpusReader.numDocs();
+ }
+
+ public virtual string HighlightTerm(string originalText, TokenGroup tokenGroup)
+ {
+ if (tokenGroup.TotalScore == 0)
+ return originalText;
+ float score = tokenGroup.TotalScore;
+ if (score == 0)
+ {
+ return originalText;
+ }
- var sb = new System.Text.StringBuilder();
- sb.Append("<font ");
- if (highlightForeground)
- {
- sb.Append("color=\"");
- sb.Append(GetForegroundColorString(score));
- sb.Append("\" ");
- }
- if (highlightBackground)
- {
- sb.Append("bgcolor=\"");
- sb.Append(GetBackgroundColorString(score));
- sb.Append("\" ");
- }
- sb.Append(">");
- sb.Append(originalText);
- sb.Append("</font>");
- return sb.ToString();
- }
-
- protected internal virtual string GetForegroundColorString(float score)
- {
- int rVal = GetColorVal(fgRMin, fgRMax, score);
- int gVal = GetColorVal(fgGMin, fgGMax, score);
- int bVal = GetColorVal(fgBMin, fgBMax, score);
- var sb = new System.Text.StringBuilder();
- sb.Append("#");
- sb.Append(IntToHex(rVal));
- sb.Append(IntToHex(gVal));
- sb.Append(IntToHex(bVal));
- return sb.ToString();
- }
-
- protected internal virtual string GetBackgroundColorString(float score)
- {
- int rVal = GetColorVal(bgRMin, bgRMax, score);
- int gVal = GetColorVal(bgGMin, bgGMax, score);
- int bVal = GetColorVal(bgBMin, bgBMax, score);
- var sb = new System.Text.StringBuilder();
- sb.Append("#");
- sb.Append(IntToHex(rVal));
- sb.Append(IntToHex(gVal));
- sb.Append(IntToHex(bVal));
- return sb.ToString();
- }
-
- private int GetColorVal(int colorMin, int colorMax, float score)
- {
- if (colorMin == colorMax)
- {
- return colorMin;
- }
- float scale = Math.Abs(colorMin - colorMax);
- float relScorePercent = Math.Min(maxScore, score) / maxScore;
- float colScore = scale * relScorePercent;
- return Math.Min(colorMin, colorMax) + (int) colScore;
- }
-
- private static char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
-
- private static string IntToHex(int i)
- {
- return "" + hexDigits[(i & 0xF0) >> 4] + hexDigits[i & 0x0F];
- }
-
- /// <summary> Converts a hex string into an int. Integer.parseInt(hex, 16) assumes the
- /// input is nonnegative unless there is a preceding minus sign. This method
- /// reads the input as twos complement instead, so if the input is 8 bytes
- /// long, it will correctly restore a negative int produced by
- /// Integer.toHexString() but not neccesarily one produced by
- /// Integer.toString(x,16) since that method will produce a string like '-FF'
- /// for negative integer values.
- ///
- /// </summary>
+ var sb = new System.Text.StringBuilder();
+ sb.Append("<font ");
+ if (highlightForeground)
+ {
+ sb.Append("color=\"");
+ sb.Append(GetForegroundColorString(score));
+ sb.Append("\" ");
+ }
+ if (highlightBackground)
+ {
+ sb.Append("bgcolor=\"");
+ sb.Append(GetBackgroundColorString(score));
+ sb.Append("\" ");
+ }
+ sb.Append(">");
+ sb.Append(originalText);
+ sb.Append("</font>");
+ return sb.ToString();
+ }
+
+ protected internal virtual string GetForegroundColorString(float score)
+ {
+ int rVal = GetColorVal(fgRMin, fgRMax, score);
+ int gVal = GetColorVal(fgGMin, fgGMax, score);
+ int bVal = GetColorVal(fgBMin, fgBMax, score);
+ var sb = new System.Text.StringBuilder();
+ sb.Append("#");
+ sb.Append(IntToHex(rVal));
+ sb.Append(IntToHex(gVal));
+ sb.Append(IntToHex(bVal));
+ return sb.ToString();
+ }
+
+ protected internal virtual string GetBackgroundColorString(float score)
+ {
+ int rVal = GetColorVal(bgRMin, bgRMax, score);
+ int gVal = GetColorVal(bgGMin, bgGMax, score);
+ int bVal = GetColorVal(bgBMin, bgBMax, score);
+ var sb = new System.Text.StringBuilder();
+ sb.Append("#");
+ sb.Append(IntToHex(rVal));
+ sb.Append(IntToHex(gVal));
+ sb.Append(IntToHex(bVal));
+ return sb.ToString();
+ }
+
+ private int GetColorVal(int colorMin, int colorMax, float score)
+ {
+ if (colorMin == colorMax)
+ {
+ return colorMin;
+ }
+ float scale = Math.Abs(colorMin - colorMax);
+ float relScorePercent = Math.Min(maxScore, score) / maxScore;
+ float colScore = scale * relScorePercent;
+ return Math.Min(colorMin, colorMax) + (int) colScore;
+ }
+
+ private static char[] hexDigits = new char[]{'0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F'};
+
+ private static string IntToHex(int i)
+ {
+ return "" + hexDigits[(i & 0xF0) >> 4] + hexDigits[i & 0x0F];
+ }
+
+ /// <summary> Converts a hex string into an int. Integer.parseInt(hex, 16) assumes the
+ /// input is nonnegative unless there is a preceding minus sign. This method
+ /// reads the input as twos complement instead, so if the input is 8 bytes
+ /// long, it will correctly restore a negative int produced by
+ /// Integer.toHexString() but not neccesarily one produced by
+ /// Integer.toString(x,16) since that method will produce a string like '-FF'
+ /// for negative integer values.
+ ///
+ /// </summary>
/// <param name="hex">
- /// A string in capital or lower case hex, of no more then 16
- /// characters.
- /// </param>
+ /// A string in capital or lower case hex, of no more then 16
+ /// characters.
+ /// </param>
/// <exception cref="FormatException">if the string is more than 16 characters long, or if any
- /// character is not in the set [0-9a-fA-f]</exception>
- public static int HexToInt(string hex)
- {
- int len = hex.Length;
- if (len > 16)
- throw new FormatException();
-
- int l = 0;
- for (int i = 0; i < len; i++)
- {
- l <<= 4;
- int c = (int) System.Char.GetNumericValue(hex[i]);
- if (c < 0)
- throw new FormatException();
- l |= c;
- }
- return l;
- }
- }
+ /// character is not in the set [0-9a-fA-f]</exception>
+ public static int HexToInt(string hex)
+ {
+ int len = hex.Length;
+ if (len > 16)
+ throw new FormatException();
+
+ int l = 0;
+ for (int i = 0; i < len; i++)
+ {
+ l <<= 4;
+ int c = (int) System.Char.GetNumericValue(hex[i]);
+ if (c < 0)
+ throw new FormatException();
+ l |= c;
+ }
+ return l;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Highlighter/Highlighter.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Highlighter/Highlighter.cs b/src/contrib/Highlighter/Highlighter.cs
index 28e920e..239c0f7 100644
--- a/src/contrib/Highlighter/Highlighter.cs
+++ b/src/contrib/Highlighter/Highlighter.cs
@@ -233,10 +233,10 @@ namespace Lucene.Net.Search.Highlight
tokenGroup.AddToken(_fragmentScorer.GetTokenScore());
- // if(lastEndOffset>maxDocBytesToAnalyze)
- // {
- // break;
- // }
+ // if(lastEndOffset>maxDocBytesToAnalyze)
+ // {
+ // break;
+ // }
}
currentFrag.Score = _fragmentScorer.FragmentScore;
@@ -256,10 +256,10 @@ namespace Lucene.Net.Search.Highlight
//Test what remains of the original text beyond the point where we stopped analyzing
if (
- // if there is text beyond the last token considered..
+ // if there is text beyond the last token considered..
(lastEndOffset < text.Length)
&&
- // and that text is not too large...
+ // and that text is not too large...
(text.Length <= _maxDocCharsToAnalyze)
)
{
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Highlighter/IEncoder.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Highlighter/IEncoder.cs b/src/contrib/Highlighter/IEncoder.cs
index d8cff13..0e45d49 100644
--- a/src/contrib/Highlighter/IEncoder.cs
+++ b/src/contrib/Highlighter/IEncoder.cs
@@ -17,10 +17,10 @@
namespace Lucene.Net.Search.Highlight
{
- /// <summary>Encodes original text. The IEncoder works with the Formatter to generate the output.</summary>
- public interface IEncoder
- {
- /// <param name="originalText">The section of text being output</param>
- string EncodeText(System.String originalText);
- }
+ /// <summary>Encodes original text. The IEncoder works with the Formatter to generate the output.</summary>
+ public interface IEncoder
+ {
+ /// <param name="originalText">The section of text being output</param>
+ string EncodeText(System.String originalText);
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Highlighter/IFormatter.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Highlighter/IFormatter.cs b/src/contrib/Highlighter/IFormatter.cs
index 90ca8b3..2164afd 100644
--- a/src/contrib/Highlighter/IFormatter.cs
+++ b/src/contrib/Highlighter/IFormatter.cs
@@ -17,13 +17,13 @@
namespace Lucene.Net.Search.Highlight
{
- /// <summary> Processes terms found in the original text, typically by applying some form
- /// of mark-up to highlight terms in HTML search results pages.</summary>
- public interface IFormatter
- {
- /// <param name="originalText">The section of text being considered for markup</param>
- /// <param name="tokenGroup">contains one or several overlapping Tokens along with
- /// their scores and positions.</param>
- string HighlightTerm(System.String originalText, TokenGroup tokenGroup);
- }
+ /// <summary> Processes terms found in the original text, typically by applying some form
+ /// of mark-up to highlight terms in HTML search results pages.</summary>
+ public interface IFormatter
+ {
+ /// <param name="originalText">The section of text being considered for markup</param>
+ /// <param name="tokenGroup">contains one or several overlapping Tokens along with
+ /// their scores and positions.</param>
+ string HighlightTerm(System.String originalText, TokenGroup tokenGroup);
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Highlighter/NullFragmenter.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Highlighter/NullFragmenter.cs b/src/contrib/Highlighter/NullFragmenter.cs
index fa73736..c86dda1 100644
--- a/src/contrib/Highlighter/NullFragmenter.cs
+++ b/src/contrib/Highlighter/NullFragmenter.cs
@@ -19,18 +19,18 @@ using Lucene.Net.Analysis;
namespace Lucene.Net.Search.Highlight
{
-
- /// <summary> <see cref="IFragmenter"/> implementation which does not fragment the text.
- /// This is useful for highlighting the entire content of a document or field.
- /// </summary>
- public class NullFragmenter : IFragmenter
- {
- public virtual void Start(string originalText, TokenStream tokenStream)
- { }
+
+ /// <summary> <see cref="IFragmenter"/> implementation which does not fragment the text.
+ /// This is useful for highlighting the entire content of a document or field.
+ /// </summary>
+ public class NullFragmenter : IFragmenter
+ {
+ public virtual void Start(string originalText, TokenStream tokenStream)
+ { }
- public virtual bool IsNewFragment()
- {
+ public virtual bool IsNewFragment()
+ {
return false;
- }
- }
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Highlighter/QueryTermExtractor.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Highlighter/QueryTermExtractor.cs b/src/contrib/Highlighter/QueryTermExtractor.cs
index ba2e1e2..2a5bc7e 100644
--- a/src/contrib/Highlighter/QueryTermExtractor.cs
+++ b/src/contrib/Highlighter/QueryTermExtractor.cs
@@ -24,36 +24,36 @@ using Lucene.Net.Util;
namespace Lucene.Net.Search.Highlight
{
-
- /// <summary> Utility class used to extract the terms used in a query, plus any weights.
- /// This class will not find terms for MultiTermQuery, RangeQuery and PrefixQuery classes
- /// so the caller must pass a rewritten query (see Query.rewrite) to obtain a list of
- /// expanded terms.</summary>
- public static class QueryTermExtractor
- {
-
- /// <summary> Extracts all terms texts of a given Query into an array of WeightedTerms
- ///
- /// </summary>
- /// <param name="query"> Query to extract term texts from
- /// </param>
- /// <returns> an array of the terms used in a query, plus their weights.
- /// </returns>
- public static WeightedTerm[] GetTerms(Query query)
- {
- return GetTerms(query, false);
- }
-
- /// <summary> Extracts all terms texts of a given Query into an array of WeightedTerms
- ///
- /// </summary>
- /// <param name="query">Query to extract term texts from</param>
- /// <param name="reader">used to compute IDF which can be used to a) score selected fragments better
- /// b) use graded highlights eg chaning intensity of font color</param>
- /// <param name="fieldName">the field on which Inverse Document Frequency (IDF) calculations are based</param>
- /// <returns> an array of the terms used in a query, plus their weights.</returns>
- public static WeightedTerm[] GetIdfWeightedTerms(Query query, IndexReader reader, string fieldName)
- {
+
+ /// <summary> Utility class used to extract the terms used in a query, plus any weights.
+ /// This class will not find terms for MultiTermQuery, RangeQuery and PrefixQuery classes
+ /// so the caller must pass a rewritten query (see Query.rewrite) to obtain a list of
+ /// expanded terms.</summary>
+ public static class QueryTermExtractor
+ {
+
+ /// <summary> Extracts all terms texts of a given Query into an array of WeightedTerms
+ ///
+ /// </summary>
+ /// <param name="query"> Query to extract term texts from
+ /// </param>
+ /// <returns> an array of the terms used in a query, plus their weights.
+ /// </returns>
+ public static WeightedTerm[] GetTerms(Query query)
+ {
+ return GetTerms(query, false);
+ }
+
+ /// <summary> Extracts all terms texts of a given Query into an array of WeightedTerms
+ ///
+ /// </summary>
+ /// <param name="query">Query to extract term texts from</param>
+ /// <param name="reader">used to compute IDF which can be used to a) score selected fragments better
+ /// b) use graded highlights eg chaning intensity of font color</param>
+ /// <param name="fieldName">the field on which Inverse Document Frequency (IDF) calculations are based</param>
+ /// <returns> an array of the terms used in a query, plus their weights.</returns>
+ public static WeightedTerm[] GetIdfWeightedTerms(Query query, IndexReader reader, string fieldName)
+ {
WeightedTerm[] terms = GetTerms(query, false, fieldName);
int totalNumDocs = reader.NumDocs();
foreach (WeightedTerm t in terms)
@@ -75,16 +75,16 @@ namespace Lucene.Net.Search.Highlight
//ignore
}
}
- return terms;
- }
-
- /// <summary>Extracts all terms texts of a given Query into an array of WeightedTerms</summary>
- /// <param name="query">Query to extract term texts from</param>
- /// <param name="prohibited"><c>true</c> to extract "prohibited" terms, too </param>
- /// <param name="fieldName"> The fieldName used to filter query terms</param>
- /// <returns>an array of the terms used in a query, plus their weights.</returns>
- public static WeightedTerm[] GetTerms(Query query, bool prohibited, string fieldName)
- {
+ return terms;
+ }
+
+ /// <summary>Extracts all terms texts of a given Query into an array of WeightedTerms</summary>
+ /// <param name="query">Query to extract term texts from</param>
+ /// <param name="prohibited"><c>true</c> to extract "prohibited" terms, too </param>
+ /// <param name="fieldName"> The fieldName used to filter query terms</param>
+ /// <returns>an array of the terms used in a query, plus their weights.</returns>
+ public static WeightedTerm[] GetTerms(Query query, bool prohibited, string fieldName)
+ {
var terms = new HashSet<WeightedTerm>();
if (fieldName != null)
{
@@ -92,23 +92,23 @@ namespace Lucene.Net.Search.Highlight
}
GetTerms(query, terms, prohibited, fieldName);
return terms.ToArray();
- }
-
- /// <summary> Extracts all terms texts of a given Query into an array of WeightedTerms
- ///
- /// </summary>
- /// <param name="query"> Query to extract term texts from
- /// </param>
- /// <param name="prohibited"><c>true</c> to extract "prohibited" terms, too
- /// </param>
- /// <returns> an array of the terms used in a query, plus their weights.
- /// </returns>
- public static WeightedTerm[] GetTerms(Query query, bool prohibited)
- {
- return GetTerms(query, prohibited, null);
- }
-
- //fieldname MUST be interned prior to this call
+ }
+
+ /// <summary> Extracts all terms texts of a given Query into an array of WeightedTerms
+ ///
+ /// </summary>
+ /// <param name="query"> Query to extract term texts from
+ /// </param>
+ /// <param name="prohibited"><c>true</c> to extract "prohibited" terms, too
+ /// </param>
+ /// <returns> an array of the terms used in a query, plus their weights.
+ /// </returns>
+ public static WeightedTerm[] GetTerms(Query query, bool prohibited)
+ {
+ return GetTerms(query, prohibited, null);
+ }
+
+ //fieldname MUST be interned prior to this call
private static void GetTerms(Query query, HashSet<WeightedTerm> terms, bool prohibited, string fieldName)
{
try
@@ -136,28 +136,28 @@ namespace Lucene.Net.Search.Highlight
}
}
- /// <summary> extractTerms is currently the only query-independent means of introspecting queries but it only reveals
- /// a list of terms for that query - not the boosts each individual term in that query may or may not have.
- /// "Container" queries such as BooleanQuery should be unwrapped to get at the boost info held
- /// in each child element.
- /// Some discussion around this topic here:
- /// http://www.gossamer-threads.com/lists/lucene/java-dev/34208?search_string=introspection;#34208
- /// Unfortunately there seemed to be limited interest in requiring all Query objects to implement
- /// something common which would allow access to child queries so what follows here are query-specific
- /// implementations for accessing embedded query elements.
- /// </summary>
- private static void GetTermsFromBooleanQuery(BooleanQuery query, HashSet<WeightedTerm> terms, bool prohibited, string fieldName)
- {
+ /// <summary> extractTerms is currently the only query-independent means of introspecting queries but it only reveals
+ /// a list of terms for that query - not the boosts each individual term in that query may or may not have.
+ /// "Container" queries such as BooleanQuery should be unwrapped to get at the boost info held
+ /// in each child element.
+ /// Some discussion around this topic here:
+ /// http://www.gossamer-threads.com/lists/lucene/java-dev/34208?search_string=introspection;#34208
+ /// Unfortunately there seemed to be limited interest in requiring all Query objects to implement
+ /// something common which would allow access to child queries so what follows here are query-specific
+ /// implementations for accessing embedded query elements.
+ /// </summary>
+ private static void GetTermsFromBooleanQuery(BooleanQuery query, HashSet<WeightedTerm> terms, bool prohibited, string fieldName)
+ {
BooleanClause[] queryClauses = query.GetClauses();
for (int i = 0; i < queryClauses.Length; i++)
{
if (prohibited || queryClauses[i].Occur != Occur.MUST_NOT)
GetTerms(queryClauses[i].Query, terms, prohibited, fieldName);
}
- }
+ }
private static void GetTermsFromFilteredQuery(FilteredQuery query, HashSet<WeightedTerm> terms, bool prohibited, string fieldName)
- {
- GetTerms(query.Query, terms, prohibited, fieldName);
- }
- }
+ {
+ GetTerms(query.Query, terms, prohibited, fieldName);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Highlighter/SimpleHTMLFormatter.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Highlighter/SimpleHTMLFormatter.cs b/src/contrib/Highlighter/SimpleHTMLFormatter.cs
index 0013f2a..ea51b05 100644
--- a/src/contrib/Highlighter/SimpleHTMLFormatter.cs
+++ b/src/contrib/Highlighter/SimpleHTMLFormatter.cs
@@ -17,47 +17,47 @@
namespace Lucene.Net.Search.Highlight
{
- /// <summary> Simple <see cref="IFormatter"/> implementation to highlight terms with a pre and post tag</summary>
- /// <author> MAHarwood
- ///
- /// </author>
- public class SimpleHTMLFormatter : IFormatter
- {
- internal System.String preTag;
- internal System.String postTag;
-
-
- public SimpleHTMLFormatter(System.String preTag, System.String postTag)
- {
- this.preTag = preTag;
- this.postTag = postTag;
- }
-
- /// <summary> Default constructor uses HTML: <B> tags to markup terms
- ///
- ///
- /// </summary>
- public SimpleHTMLFormatter()
- {
- this.preTag = "<B>";
- this.postTag = "</B>";
- }
-
- /* (non-Javadoc)
- * <see cref="Lucene.Net.Highlight.Formatter.highlightTerm(java.lang.String, Lucene.Net.Highlight.TokenGroup)"/>
- */
- public virtual System.String HighlightTerm(System.String originalText, TokenGroup tokenGroup)
- {
- System.Text.StringBuilder returnBuffer;
- if (tokenGroup.TotalScore > 0)
- {
- returnBuffer = new System.Text.StringBuilder();
- returnBuffer.Append(preTag);
- returnBuffer.Append(originalText);
- returnBuffer.Append(postTag);
- return returnBuffer.ToString();
- }
- return originalText;
- }
- }
+ /// <summary> Simple <see cref="IFormatter"/> implementation to highlight terms with a pre and post tag</summary>
+ /// <author> MAHarwood
+ ///
+ /// </author>
+ public class SimpleHTMLFormatter : IFormatter
+ {
+ internal System.String preTag;
+ internal System.String postTag;
+
+
+ public SimpleHTMLFormatter(System.String preTag, System.String postTag)
+ {
+ this.preTag = preTag;
+ this.postTag = postTag;
+ }
+
+ /// <summary> Default constructor uses HTML: <B> tags to markup terms
+ ///
+ ///
+ /// </summary>
+ public SimpleHTMLFormatter()
+ {
+ this.preTag = "<B>";
+ this.postTag = "</B>";
+ }
+
+ /* (non-Javadoc)
+ * <see cref="Lucene.Net.Highlight.Formatter.highlightTerm(java.lang.String, Lucene.Net.Highlight.TokenGroup)"/>
+ */
+ public virtual System.String HighlightTerm(System.String originalText, TokenGroup tokenGroup)
+ {
+ System.Text.StringBuilder returnBuffer;
+ if (tokenGroup.TotalScore > 0)
+ {
+ returnBuffer = new System.Text.StringBuilder();
+ returnBuffer.Append(preTag);
+ returnBuffer.Append(originalText);
+ returnBuffer.Append(postTag);
+ return returnBuffer.ToString();
+ }
+ return originalText;
+ }
+ }
}
\ No newline at end of file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Highlighter/TokenSources.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Highlighter/TokenSources.cs b/src/contrib/Highlighter/TokenSources.cs
index dc44bb5..745ac2a 100644
--- a/src/contrib/Highlighter/TokenSources.cs
+++ b/src/contrib/Highlighter/TokenSources.cs
@@ -144,8 +144,8 @@ namespace Lucene.Net.Search.Highlight
/// - reanalyzing the original content - 980 milliseconds
///
/// The re-analyze timings will typically vary depending on -
- /// 1) The complexity of the analyzer code (timings above were using a
- /// stemmer/lowercaser/stopword combo)
+ /// 1) The complexity of the analyzer code (timings above were using a
+ /// stemmer/lowercaser/stopword combo)
/// 2) The number of other fields (Lucene reads ALL fields off the disk
/// when accessing just one document field - can cost dear!)
/// 3) Use of compression on field storage - could be faster due to compression (less disk IO)
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Highlighter/WeightedSpanTerm.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Highlighter/WeightedSpanTerm.cs b/src/contrib/Highlighter/WeightedSpanTerm.cs
index 7d94383..d89b915 100644
--- a/src/contrib/Highlighter/WeightedSpanTerm.cs
+++ b/src/contrib/Highlighter/WeightedSpanTerm.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Queries/BooleanFilter.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Queries/BooleanFilter.cs b/src/contrib/Queries/BooleanFilter.cs
index e964498..de4b8fd 100644
--- a/src/contrib/Queries/BooleanFilter.cs
+++ b/src/contrib/Queries/BooleanFilter.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Queries/BoostingQuery.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Queries/BoostingQuery.cs b/src/contrib/Queries/BoostingQuery.cs
index d2716be..5d57d2c 100644
--- a/src/contrib/Queries/BoostingQuery.cs
+++ b/src/contrib/Queries/BoostingQuery.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Queries/DuplicateFilter.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Queries/DuplicateFilter.cs b/src/contrib/Queries/DuplicateFilter.cs
index 274f8ab..d5f4745 100644
--- a/src/contrib/Queries/DuplicateFilter.cs
+++ b/src/contrib/Queries/DuplicateFilter.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Queries/FilterClause.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Queries/FilterClause.cs b/src/contrib/Queries/FilterClause.cs
index 06f6ef4..f292914 100644
--- a/src/contrib/Queries/FilterClause.cs
+++ b/src/contrib/Queries/FilterClause.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Queries/FuzzyLikeThisQuery.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Queries/FuzzyLikeThisQuery.cs b/src/contrib/Queries/FuzzyLikeThisQuery.cs
index c28d94c..09f1c8c 100644
--- a/src/contrib/Queries/FuzzyLikeThisQuery.cs
+++ b/src/contrib/Queries/FuzzyLikeThisQuery.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Queries/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Queries/Properties/AssemblyInfo.cs b/src/contrib/Queries/Properties/AssemblyInfo.cs
index fd774f2..0938b45 100644
--- a/src/contrib/Queries/Properties/AssemblyInfo.cs
+++ b/src/contrib/Queries/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
*
* Licensed to the Apache Software Foundation (ASF) under one
* or more contributor license agreements. See the NOTICE file
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Queries/Similar/MoreLikeThis.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Queries/Similar/MoreLikeThis.cs b/src/contrib/Queries/Similar/MoreLikeThis.cs
index 7b5f335..62883a8 100644
--- a/src/contrib/Queries/Similar/MoreLikeThis.cs
+++ b/src/contrib/Queries/Similar/MoreLikeThis.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -780,30 +780,30 @@ namespace Lucene.Net.Search.Similar
private void AddTermFrequencies(System.IO.TextReader r, IDictionary<string,Int> termFreqMap, System.String fieldName)
{
TokenStream ts = analyzer.TokenStream(fieldName, r);
- int tokenCount=0;
- // for every token
+ int tokenCount=0;
+ // for every token
ITermAttribute termAtt = ts.AddAttribute<ITermAttribute>();
-
- while (ts.IncrementToken()) {
- string word = termAtt.Term;
- tokenCount++;
- if(tokenCount>maxNumTokensParsed)
- {
- break;
- }
- if(IsNoiseWord(word)){
- continue;
- }
-
- // increment frequency
- Int cnt = termFreqMap[word];
- if (cnt == null) {
+
+ while (ts.IncrementToken()) {
+ string word = termAtt.Term;
+ tokenCount++;
+ if(tokenCount>maxNumTokensParsed)
+ {
+ break;
+ }
+ if(IsNoiseWord(word)){
+ continue;
+ }
+
+ // increment frequency
+ Int cnt = termFreqMap[word];
+ if (cnt == null) {
termFreqMap[word] = new Int();
- }
- else {
- cnt.x++;
- }
- }
+ }
+ else {
+ cnt.x++;
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Queries/Similar/MoreLikeThisQuery.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Queries/Similar/MoreLikeThisQuery.cs b/src/contrib/Queries/Similar/MoreLikeThisQuery.cs
index 7cd4681..ae071c0 100644
--- a/src/contrib/Queries/Similar/MoreLikeThisQuery.cs
+++ b/src/contrib/Queries/Similar/MoreLikeThisQuery.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Queries/Similar/SimilarityQueries.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Queries/Similar/SimilarityQueries.cs b/src/contrib/Queries/Similar/SimilarityQueries.cs
index 8a1f38b..2bbd5d4 100644
--- a/src/contrib/Queries/Similar/SimilarityQueries.cs
+++ b/src/contrib/Queries/Similar/SimilarityQueries.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Queries/TermsFilter.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Queries/TermsFilter.cs b/src/contrib/Queries/TermsFilter.cs
index 263d2f5..3426732 100644
--- a/src/contrib/Queries/TermsFilter.cs
+++ b/src/contrib/Queries/TermsFilter.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Regex/CSharpRegexCapabilities.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Regex/CSharpRegexCapabilities.cs b/src/contrib/Regex/CSharpRegexCapabilities.cs
index 312ec4a..21174a2 100644
--- a/src/contrib/Regex/CSharpRegexCapabilities.cs
+++ b/src/contrib/Regex/CSharpRegexCapabilities.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -19,73 +19,73 @@ using System;
namespace Contrib.Regex
{
- /// <summary>
- /// C# Regex based implementation of <see cref="IRegexCapabilities"/>.
- /// </summary>
- /// <remarks>http://www.java2s.com/Open-Source/Java-Document/Net/lucene-connector/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java.htm</remarks>
- public class CSharpRegexCapabilities : IRegexCapabilities, IEquatable<CSharpRegexCapabilities>
- {
- private System.Text.RegularExpressions.Regex _rPattern;
+ /// <summary>
+ /// C# Regex based implementation of <see cref="IRegexCapabilities"/>.
+ /// </summary>
+ /// <remarks>http://www.java2s.com/Open-Source/Java-Document/Net/lucene-connector/org/apache/lucene/search/regex/JavaUtilRegexCapabilities.java.htm</remarks>
+ public class CSharpRegexCapabilities : IRegexCapabilities, IEquatable<CSharpRegexCapabilities>
+ {
+ private System.Text.RegularExpressions.Regex _rPattern;
- /// <summary>
- /// Called by the constructor of <see cref="RegexTermEnum"/> allowing implementations to cache
- /// a compiled version of the regular expression pattern.
- /// </summary>
- /// <param name="pattern">regular expression pattern</param>
- public void Compile(string pattern)
- {
- _rPattern = new System.Text.RegularExpressions.Regex(pattern,
- System.Text.RegularExpressions.RegexOptions.Compiled);
- }
+ /// <summary>
+ /// Called by the constructor of <see cref="RegexTermEnum"/> allowing implementations to cache
+ /// a compiled version of the regular expression pattern.
+ /// </summary>
+ /// <param name="pattern">regular expression pattern</param>
+ public void Compile(string pattern)
+ {
+ _rPattern = new System.Text.RegularExpressions.Regex(pattern,
+ System.Text.RegularExpressions.RegexOptions.Compiled);
+ }
- /// <summary>
- /// True on match.
- /// </summary>
- /// <param name="s">text to match</param>
- /// <returns>true on match</returns>
- public bool Match(string s)
- {
- return _rPattern.IsMatch(s);
- }
+ /// <summary>
+ /// True on match.
+ /// </summary>
+ /// <param name="s">text to match</param>
+ /// <returns>true on match</returns>
+ public bool Match(string s)
+ {
+ return _rPattern.IsMatch(s);
+ }
- /// <summary>
- /// A wise prefix implementation can reduce the term enumeration (and thus performance)
- /// of RegexQuery dramatically.
- /// </summary>
- /// <returns>static non-regex prefix of the pattern last passed to <see cref="IRegexCapabilities.Compile"/>.
- /// May return null</returns>
- public string Prefix()
- {
- return null;
- }
+ /// <summary>
+ /// A wise prefix implementation can reduce the term enumeration (and thus performance)
+ /// of RegexQuery dramatically.
+ /// </summary>
+ /// <returns>static non-regex prefix of the pattern last passed to <see cref="IRegexCapabilities.Compile"/>.
+ /// May return null</returns>
+ public string Prefix()
+ {
+ return null;
+ }
- /// <summary>
- /// Indicates whether the current object is equal to another object of the same type.
- /// </summary>
- /// <returns>
- /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
- /// </returns>
- /// <param name="other">An object to compare with this object</param>
- public bool Equals(CSharpRegexCapabilities other)
- {
- if (other == null) return false;
- if (this == other) return true;
+ /// <summary>
+ /// Indicates whether the current object is equal to another object of the same type.
+ /// </summary>
+ /// <returns>
+ /// true if the current object is equal to the <paramref name="other"/> parameter; otherwise, false.
+ /// </returns>
+ /// <param name="other">An object to compare with this object</param>
+ public bool Equals(CSharpRegexCapabilities other)
+ {
+ if (other == null) return false;
+ if (this == other) return true;
- if (_rPattern != null ? !_rPattern.Equals(other._rPattern) : other._rPattern != null)
- return false;
+ if (_rPattern != null ? !_rPattern.Equals(other._rPattern) : other._rPattern != null)
+ return false;
- return true;
- }
+ return true;
+ }
- public override bool Equals(object obj)
- {
- if (obj as CSharpRegexCapabilities == null) return false;
- return Equals((CSharpRegexCapabilities) obj);
- }
+ public override bool Equals(object obj)
+ {
+ if (obj as CSharpRegexCapabilities == null) return false;
+ return Equals((CSharpRegexCapabilities) obj);
+ }
- public override int GetHashCode()
- {
- return (_rPattern != null ? _rPattern.GetHashCode() : 0);
- }
- }
+ public override int GetHashCode()
+ {
+ return (_rPattern != null ? _rPattern.GetHashCode() : 0);
+ }
+ }
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Regex/IRegexCapabilities.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Regex/IRegexCapabilities.cs b/src/contrib/Regex/IRegexCapabilities.cs
index 64f71ea..e5225eb 100644
--- a/src/contrib/Regex/IRegexCapabilities.cs
+++ b/src/contrib/Regex/IRegexCapabilities.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -17,32 +17,32 @@
namespace Contrib.Regex
{
- /// <summary>
- /// Defines basic operations needed by <see cref="RegexQuery"/> for a regular expression implementation.
- /// </summary>
- /// <remarks>http://www.java2s.com/Open-Source/Java-Document/Net/lucene-connector/org/apache/lucene/search/regex/RegexCapabilities.java.htm</remarks>
- public interface IRegexCapabilities
- {
- /// <summary>
- /// Called by the constructor of <see cref="RegexTermEnum"/> allowing implementations to cache
- /// a compiled version of the regular expression pattern.
- /// </summary>
- /// <param name="pattern">regular expression pattern</param>
- void Compile(string pattern);
+ /// <summary>
+ /// Defines basic operations needed by <see cref="RegexQuery"/> for a regular expression implementation.
+ /// </summary>
+ /// <remarks>http://www.java2s.com/Open-Source/Java-Document/Net/lucene-connector/org/apache/lucene/search/regex/RegexCapabilities.java.htm</remarks>
+ public interface IRegexCapabilities
+ {
+ /// <summary>
+ /// Called by the constructor of <see cref="RegexTermEnum"/> allowing implementations to cache
+ /// a compiled version of the regular expression pattern.
+ /// </summary>
+ /// <param name="pattern">regular expression pattern</param>
+ void Compile(string pattern);
- /// <summary>
- /// True on match.
- /// </summary>
- /// <param name="s">text to match</param>
- /// <returns>true on match</returns>
- bool Match(string s);
+ /// <summary>
+ /// True on match.
+ /// </summary>
+ /// <param name="s">text to match</param>
+ /// <returns>true on match</returns>
+ bool Match(string s);
- /// <summary>
- /// A wise prefix implementation can reduce the term enumeration (and thus performance)
- /// of RegexQuery dramatically.
- /// </summary>
- /// <returns>static non-regex prefix of the pattern last passed to <see cref="Compile"/>.
- /// May return null</returns>
- string Prefix();
- }
+ /// <summary>
+ /// A wise prefix implementation can reduce the term enumeration (and thus performance)
+ /// of RegexQuery dramatically.
+ /// </summary>
+ /// <returns>static non-regex prefix of the pattern last passed to <see cref="Compile"/>.
+ /// May return null</returns>
+ string Prefix();
+ }
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Regex/IRegexQueryCapable.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Regex/IRegexQueryCapable.cs b/src/contrib/Regex/IRegexQueryCapable.cs
index d9692b6..b65513b 100644
--- a/src/contrib/Regex/IRegexQueryCapable.cs
+++ b/src/contrib/Regex/IRegexQueryCapable.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.
@@ -17,12 +17,12 @@
namespace Contrib.Regex
{
- /// <summary>
- /// Defines methods for regular expression supporting queries to use.
- /// </summary>
- /// <remarks>http://www.java2s.com/Open-Source/Java-Document/Net/lucene-connector/org/apache/lucene/search/regex/RegexQueryCapable.java.htm</remarks>
- public interface IRegexQueryCapable
- {
- IRegexCapabilities RegexImplementation { set; get; }
- }
+ /// <summary>
+ /// Defines methods for regular expression supporting queries to use.
+ /// </summary>
+ /// <remarks>http://www.java2s.com/Open-Source/Java-Document/Net/lucene-connector/org/apache/lucene/search/regex/RegexQueryCapable.java.htm</remarks>
+ public interface IRegexQueryCapable
+ {
+ IRegexCapabilities RegexImplementation { set; get; }
+ }
}
http://git-wip-us.apache.org/repos/asf/lucenenet/blob/62f018ab/src/contrib/Regex/Properties/AssemblyInfo.cs
----------------------------------------------------------------------
diff --git a/src/contrib/Regex/Properties/AssemblyInfo.cs b/src/contrib/Regex/Properties/AssemblyInfo.cs
index 36cbb93..c9ff782 100644
--- a/src/contrib/Regex/Properties/AssemblyInfo.cs
+++ b/src/contrib/Regex/Properties/AssemblyInfo.cs
@@ -1,4 +1,4 @@
-/*
+/*
* Licensed to the Apache Software Foundation (ASF) under one or more
* contributor license agreements. See the NOTICE file distributed with
* this work for additional information regarding copyright ownership.