~ubuntu-branches/ubuntu/jaunty/beagle/jaunty-security

« back to all changes in this revision

Viewing changes to beagled/Lucene.Net/Analysis/PorterStemFilter.cs

  • Committer: Bazaar Package Importer
  • Author(s): Stefan Ebner
  • Date: 2008-05-04 00:31:32 UTC
  • mfrom: (1.1.21 upstream)
  • Revision ID: james.westby@ubuntu.com-20080504003132-2tkm5o8moo5952ri
Tags: 0.3.7-2ubuntu1
 * Merge from Debian unstable. (LP: #225746) Remaining Ubuntu changes:
  - debian/control:
    + Rename ice{weasel,dove}-beagle to {mozilla,thunderbird}-beagle and
      and update the dependencies accordingly.
    + Change Maintainer to Ubuntu Mono Team.
  - debian/rules:
    + Install the mozilla-beagle and thunderbird-beagle extensions.
  - ice{dove,weasel}.dirs:
    + Renamed to {mozilla,thunderbird}-beagle.dirs.
    + Fixed paths to point to usr/lib/{firefox,thunderbird}

Show diffs side-by-side

added added

removed removed

Lines of Context:
1
1
/*
2
 
 * Copyright 2004 The Apache Software Foundation
3
 
 * 
4
 
 * Licensed under the Apache License, Version 2.0 (the "License");
5
 
 * you may not use this file except in compliance with the License.
6
 
 * You may obtain a copy of the License at
 
2
 * Licensed to the Apache Software Foundation (ASF) under one or more
 
3
 * contributor license agreements.  See the NOTICE file distributed with
 
4
 * this work for additional information regarding copyright ownership.
 
5
 * The ASF licenses this file to You under the Apache License, Version 2.0
 
6
 * (the "License"); you may not use this file except in compliance with
 
7
 * the License.  You may obtain a copy of the License at
7
8
 * 
8
9
 * http://www.apache.org/licenses/LICENSE-2.0
9
10
 * 
19
20
namespace Lucene.Net.Analysis
20
21
{
21
22
        
22
 
        /// <summary>Transforms the token stream as per the Porter stemming algorithm.
23
 
        /// Note: the input to the stemming filter must already be in lower case,
24
 
        /// so you will need to use LowerCaseFilter or LowerCaseTokenizer farther
25
 
        /// down the Tokenizer chain in order for this to work properly!
26
 
        /// <P>
27
 
        /// To use this filter with other analyzers, you'll want to write an
28
 
        /// Analyzer class that sets up the TokenStream chain as you want it.
29
 
        /// To use this with LowerCaseTokenizer, for example, you'd write an
30
 
        /// analyzer like this:
31
 
        /// <P>
32
 
        /// <PRE>
33
 
        /// class MyAnalyzer extends Analyzer {
34
 
        /// public final TokenStream tokenStream(String fieldName, Reader reader) {
35
 
        /// return new PorterStemFilter(new LowerCaseTokenizer(reader));
36
 
        /// }
37
 
        /// }
38
 
        /// </PRE>
39
 
        /// </summary>
40
 
        public sealed class PorterStemFilter : TokenFilter
41
 
        {
42
 
                private PorterStemmer stemmer;
43
 
                
44
 
                public PorterStemFilter(TokenStream in_Renamed) : base(in_Renamed)
45
 
                {
46
 
                        stemmer = new PorterStemmer();
47
 
                }
48
 
                
49
 
                /// <summary>Returns the next input Token, after being stemmed </summary>
50
 
                public override Token Next()
51
 
                {
52
 
                        Token token = input.Next();
53
 
                        if (token == null)
54
 
                                return null;
55
 
                        else
56
 
                        {
57
 
                                System.String s = stemmer.Stem(token.termText);
58
 
                                if ((System.Object) s != (System.Object) token.termText)
59
 
                                // Yes, I mean object reference comparison here
60
 
                                        token.termText = s;
61
 
                                return token;
62
 
                        }
63
 
                }
64
 
        }
 
23
    /// <summary>Transforms the token stream as per the Porter stemming algorithm.
 
24
    /// Note: the input to the stemming filter must already be in lower case,
 
25
    /// so you will need to use LowerCaseFilter or LowerCaseTokenizer farther
 
26
    /// down the Tokenizer chain in order for this to work properly!
 
27
    /// <P>
 
28
    /// To use this filter with other analyzers, you'll want to write an
 
29
    /// Analyzer class that sets up the TokenStream chain as you want it.
 
30
    /// To use this with LowerCaseTokenizer, for example, you'd write an
 
31
    /// analyzer like this:
 
32
    /// <P>
 
33
    /// <PRE>
 
34
    /// class MyAnalyzer extends Analyzer {
 
35
    /// public final TokenStream tokenStream(String fieldName, Reader reader) {
 
36
    /// return new PorterStemFilter(new LowerCaseTokenizer(reader));
 
37
    /// }
 
38
    /// }
 
39
    /// </PRE>
 
40
    /// </summary>
 
41
    public sealed class PorterStemFilter : TokenFilter
 
42
    {
 
43
        private PorterStemmer stemmer;
 
44
                
 
45
        public PorterStemFilter(TokenStream in_Renamed) : base(in_Renamed)
 
46
        {
 
47
            stemmer = new PorterStemmer();
 
48
        }
 
49
                
 
50
        /// <summary>Returns the next input Token, after being stemmed </summary>
 
51
        public override Token Next()
 
52
        {
 
53
            Token token = input.Next();
 
54
            if (token == null)
 
55
                return null;
 
56
            else
 
57
            {
 
58
                System.String s = stemmer.Stem(token.termText);
 
59
                if ((System.Object) s != (System.Object) token.termText)
 
60
                    // Yes, I mean object reference comparison here
 
61
                    token.termText = s;
 
62
                return token;
 
63
            }
 
64
        }
 
65
    }
65
66
}
 
 
b'\\ No newline at end of file'