001/**
002 * Copyright (c) 2011, The University of Southampton and the individual contributors.
003 * All rights reserved.
004 *
005 * Redistribution and use in source and binary forms, with or without modification,
006 * are permitted provided that the following conditions are met:
007 *
008 *   *  Redistributions of source code must retain the above copyright notice,
009 *      this list of conditions and the following disclaimer.
010 *
011 *   *  Redistributions in binary form must reproduce the above copyright notice,
012 *      this list of conditions and the following disclaimer in the documentation
013 *      and/or other materials provided with the distribution.
014 *
015 *   *  Neither the name of the University of Southampton nor the names of its
016 *      contributors may be used to endorse or promote products derived from this
017 *      software without specific prior written permission.
018 *
019 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND
020 * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
021 * WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
022 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR
023 * ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
024 * (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES;
025 * LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
026 * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
027 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS
028 * SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
029 */
030package org.openimaj.text.nlp.textpipe.annotations;
031
032/**
033 * Part of Speech Annotation based on the Penn treebank.
034 * 
035 * @author Laurence Willmore (lgw1e10@ecs.soton.ac.uk)
036 * 
037 */
038public class POSAnnotation extends TextPipeAnnotation {
039
040        /**
041         * Penn Treebank part of speech types.
042         * 
043         * @author Laurence Willmore (lgw1e10@ecs.soton.ac.uk)
044         * 
045         */
046        public enum PartOfSpeech {
047                CC("Coordinating conjunction"),
048                CD("Cardinal number"),
049                DT("Determiner"),
050                EX("Existential there"),
051                FW("Foreign word"),
052                IN("Preposition or subordinating conjunction"),
053                JJ("Adjective"),
054                JJR("Adjective, comparative"),
055                JJS("Adjective, superlative"),
056                LS("List item marker"),
057                MD("Modal"),
058                NN("Noun, singular or mass"),
059                NNS("Noun, plural"),
060                NNP("Proper noun, singular"),
061                NNPS("Proper noun, plural"),
062                PDT("Predeterminer"),
063                POS("Possessive ending"),
064                PRP("Personal pronoun"),
065                PRP$("Possessive pronoun (prolog version PRP-S)"),
066                RB("Adverb"),
067                RBR("Adverb, comparative"),
068                RBS("Adverb, superlative"),
069                RP("Particle"),
070                SYM("Symbol"),
071                TO("to"),
072                UH("Interjection"),
073                VB("Verb, base form"),
074                VBD("Verb, past tense"),
075                VBG("Verb, gerund or present participle"),
076                VBN("Verb, past participle"),
077                VBP("Verb, non-3rd person singular present"),
078                VBZ("Verb, 3rd person singular present"),
079                WDT("Wh-determiner"),
080                WP("Wh-pronoun"),
081                WP$("Possessive wh-pronoun (prolog version WP-S)"),
082                WRB("Wh-adverb"),
083                /**
084                 * This is added for pos with no mapping to penn bank.
085                 */
086                UK("Unknown");
087
088                /**
089                 * Penn Tree Bank short description
090                 */
091                public final String DESCRIPTION;
092
093                PartOfSpeech(String description) {
094                        this.DESCRIPTION = description;
095                }
096
097                /**
098                 * Gets a {@link PartOfSpeech} from a string.
099                 * 
100                 * @param pennAbreviation
101                 * @return PartOfSpeech
102                 */
103                public static PartOfSpeech getPOSfromString(String pennAbreviation) {
104                        for (final PartOfSpeech pos : PartOfSpeech.values()) {
105                                if (pos.toString().equals(pennAbreviation))
106                                        return pos;
107                        }
108                        return PartOfSpeech.UK;
109                }
110        };
111
112        public PartOfSpeech pos;
113
114        public POSAnnotation(PartOfSpeech pos) {
115                super();
116                this.pos = pos;
117        }
118
119}