Ejemplo n.º 1
0
		public PorterStemFilter(TokenStream in_Renamed):base(in_Renamed)
		{
			stemmer = new PorterStemmer();
			termAtt = (TermAttribute) AddAttribute(typeof(TermAttribute));
		}
Ejemplo n.º 2
0
        public static void  Main(System.String[] args)
        {
            PorterStemmer 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);
                    byte[]           buffer = new byte[1024];
                    int bufferLen, offset, ch;

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

                    while (true)
                    {
                        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 (System.Char.IsLetter((char)ch))
                        {
                            s.Add(System.Char.ToLower((char)ch));
                        }
                        else
                        {
                            s.Stem();
                            System.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 e)
                {
                    System.Console.Out.WriteLine("error reading " + args[i]);
                }
            }
        }
Ejemplo n.º 3
0
		public static void  Main(System.String[] args)
		{
			PorterStemmer 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);
					byte[] buffer = new byte[1024];
					int bufferLen, offset, ch;
					
					bufferLen = in_Renamed.Read(buffer, 0, buffer.Length);
					offset = 0;
					s.Reset();
					
					while (true)
					{
						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 (System.Char.IsLetter((char) ch))
						{
							s.Add(System.Char.ToLower((char) ch));
						}
						else
						{
							s.Stem();
							System.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 e)
				{
					System.Console.Out.WriteLine("error reading " + args[i]);
				}
			}
		}
Ejemplo n.º 4
0
 public PorterStemFilter(TokenStream in_Renamed) : base(in_Renamed)
 {
     stemmer = new PorterStemmer();
     termAtt = (TermAttribute)AddAttribute(typeof(TermAttribute));
 }