Java String Shorten shortenTagString(String longTag)

Here you can find the source of shortenTagString(String longTag)

Description

return short (single letter) form of the tag, covers only nouns, verbs, adjectives, and adverbs

License

Open Source License

Parameter

Parameter Description
longTag a parameter

Declaration

public static String shortenTagString(String longTag) 

Method Source Code

//package com.java2s;
//License from project: Open Source License 

public class Main {
    /**// w w  w . jav  a2  s  .  co  m
     * return short (single letter) form of the tag, covers only nouns, verbs, adjectives, and adverbs 
     * @param longTag
     * @return
     */
    public static String shortenTagString(String longTag) {
        longTag = longTag.toLowerCase();

        if (longTag.startsWith("n"))
            return "n";
        else if (longTag.startsWith("v"))
            return "v";
        else if (longTag.startsWith("adj") || longTag.startsWith("j"))
            return "a";
        else if (longTag.startsWith("adv") || longTag.startsWith("r"))
            return "r";
        else
            return null;
    }
}

Related

  1. shortenString(String string, int minimumLength, int lengthToShortenBy)
  2. shortenString(String string, int targetLength, int maxDeviation)
  3. shortenStringForDisplay(String str, int desiredLen)
  4. shortenStringIfNecessary(String string, int maxLength, String suffixToAppend)
  5. shortenStringsByRemovingVowelsToFit(String s1, String s2, int maximumStringLength)
  6. shortenText(final String text, final int maxLength, final boolean addDots)
  7. shortenText(int maxWidth, String textValue)
  8. shortenText(String originalText, int maxlength)
  9. shortenText(String string, int threshold)