Пример #1
0
		public PorterStemFilter(TokenStream in_Renamed):base(in_Renamed)
		{
			stemmer = new PorterStemmer();
            termAtt = AddAttribute<ITermAttribute>();
		}
Пример #2
0
 public PorterStemFilter(TokenStream in_Renamed) : base(in_Renamed)
 {
     stemmer = new PorterStemmer();
     termAtt = AddAttribute <ITermAttribute>();
 }
Пример #3
0
		public static void  Main(System.String[] args)
		{
			var s = new PorterStemmer();
			
			for (int i = 0; i < args.Length; i++)
			{
				try
				{
					System.IO.Stream in_Renamed = new System.IO.FileStream(args[i], System.IO.FileMode.Open, System.IO.FileAccess.Read);
					var buffer = new byte[1024];

					int bufferLen = in_Renamed.Read(buffer, 0, buffer.Length);
					int offset = 0;
					s.Reset();
					
					while (true)
					{
						int ch;
						if (offset < bufferLen)
							ch = buffer[offset++];
						else
						{
							bufferLen = in_Renamed.Read(buffer, 0, buffer.Length);
							offset = 0;
							if (bufferLen < 0)
								ch = - 1;
							else
								ch = buffer[offset++];
						}
						
						if (Char.IsLetter((char) ch))
						{
							s.Add(Char.ToLower((char) ch));
						}
						else
						{
							s.Stem();
							Console.Out.Write(s.ToString());
							s.Reset();
							if (ch < 0)
								break;
							else
							{
								System.Console.Out.Write((char) ch);
							}
						}
					}
					
					in_Renamed.Close();
				}
				catch (System.IO.IOException)
				{
					Console.Out.WriteLine("error reading " + args[i]);
				}
			}
		}
Пример #4
0
        public static void  Main(System.String[] args)
        {
            var s = new PorterStemmer();

            for (int i = 0; i < args.Length; i++)
            {
                try
                {
                    System.IO.Stream in_Renamed = new System.IO.FileStream(args[i], System.IO.FileMode.Open, System.IO.FileAccess.Read);
                    var buffer = new byte[1024];

                    int bufferLen = in_Renamed.Read(buffer, 0, buffer.Length);
                    int offset    = 0;
                    s.Reset();

                    while (true)
                    {
                        int ch;
                        if (offset < bufferLen)
                        {
                            ch = buffer[offset++];
                        }
                        else
                        {
                            bufferLen = in_Renamed.Read(buffer, 0, buffer.Length);
                            offset    = 0;
                            if (bufferLen < 0)
                            {
                                ch = -1;
                            }
                            else
                            {
                                ch = buffer[offset++];
                            }
                        }

                        if (Char.IsLetter((char)ch))
                        {
                            s.Add(Char.ToLower((char)ch));
                        }
                        else
                        {
                            s.Stem();
                            Console.Out.Write(s.ToString());
                            s.Reset();
                            if (ch < 0)
                            {
                                break;
                            }
                            else
                            {
                                System.Console.Out.Write((char)ch);
                            }
                        }
                    }

                    in_Renamed.Close();
                }
                catch (System.IO.IOException)
                {
                    Console.Out.WriteLine("error reading " + args[i]);
                }
            }
        }