Java String Tokenize isPOSTag(String token)

Here you can find the source of isPOSTag(String token)

Description

Very simple way of testing whether something is a part of speech tag.

License

Open Source License

Declaration

public static boolean isPOSTag(String token) 

Method Source Code

//package com.java2s;
/**// w ww . j a v  a  2s.  co  m
 * This software is released under the University of Illinois/Research and Academic Use License. See
 * the LICENSE file in the root folder for details. Copyright (c) 2016
 *
 * Developed by: The Cognitive Computation Group University of Illinois at Urbana-Champaign
 * http://cogcomp.cs.illinois.edu/
 */

import java.util.*;

public class Main {
    private static Set<String> posTagSet;
    public static final List<String> allPOS = Arrays.asList("#", "$", "``",
            "''", ",", "-LRB-", "-RRB-", ".", ":", "CC", "CD", "DT", "EX",
            "FW", "IN", "JJ", "JJR", "JJS", "LS", "MD", "NN", "NNP",
            "NNPS", "NNS", "PDT", "POS", "PRP", "PRP$", "RB", "RBR", "RBS",
            "RP", "SYM", "TO", "UH", "VB", "VBD", "VBG", "VBN", "VBP",
            "VBZ", "WDT", "WP", "WP$", "WRB");

    /**
     * Very simple way of testing whether something is a part of speech tag. Just look up a list of
     * allowed POS tags and see if the label is in it.
     */
    public static boolean isPOSTag(String token) {
        if (posTagSet == null) {
            initializePOSTagSet();

        }
        return posTagSet.contains(token);
    }

    private static void initializePOSTagSet() {
        posTagSet = new HashSet<>();
        for (String str : allPOS) {
            posTagSet.add(str);
        }

        posTagSet.add("AUX");

    }
}

Related

  1. getTokens(String value)
  2. getTokens(String vbt)
  3. getTokenTypes(CommonTree tree)
  4. getUnitType(String typeToken)
  5. hasSuffix(String _token)
  6. isStringFunction(String token)
  7. isToken(String sentence, String searchWord)
  8. maxTokenLength(String s)
  9. parseNMTokens(String nmTokens)