Java Code Examples for edu.mit.jwi.item.POS#NOUN

The following examples show how to use edu.mit.jwi.item.POS#NOUN . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: POSTag.java    From senti-storm with Apache License 2.0 6 votes vote down vote up
public static POS convertArk(String arkTag) {
  if (arkTag.equals("N") || arkTag.equals("O") || arkTag.equals("^")
      || arkTag.equals("S") || arkTag.equals("Z")) {
    return POS.NOUN;
  }
  if (arkTag.equals("V")) {
    return POS.VERB;
  }
  if (arkTag.equals("A")) {
    return POS.ADJECTIVE;
  }
  if (arkTag.equals("R")) {
    return POS.ADVERB;
  }
  return null;
}
 
Example 2
Source File: Lemmatizer.java    From easyccg with MIT License 6 votes vote down vote up
private static POS getSynsetType(String pos) {
  if (!synsetTypeForPOS.containsKey(pos)) {
    POS result = null;
  
    if (pos.startsWith("NN")) {
      result = POS.NOUN;
    } else if (pos.startsWith("VB")) {
      result = POS.VERB;
    } else if (pos.startsWith("RB")) {
      result = POS.ADVERB;
    } else if (pos.startsWith("JJ")) {
      result = POS.ADJECTIVE;
    }
    
    if (result != null) {
      synsetTypeForPOS.put(pos, result);
    }
  }
  
  return synsetTypeForPOS.get(pos);
}
 
Example 3
Source File: GeneralUtils.java    From ADW with GNU General Public License v3.0 6 votes vote down vote up
/**
 * converts string to {@link POS}
 * @param tag
 * @return
 */
public static POS getTagfromTag(String tag)
{
	if(tag.toLowerCase().startsWith("n"))
		return POS.NOUN;
	
	else
		if(tag.toLowerCase().startsWith("v"))
			return POS.VERB;
	
	else
		if(tag.toLowerCase().startsWith("r") || tag.toLowerCase().startsWith("adv"))
			return POS.ADVERB;
		
	else
		if(tag.toLowerCase().startsWith("j") 
				|| tag.toLowerCase().startsWith("adj") 
				|| tag.toLowerCase().startsWith("a"))
			return POS.ADJECTIVE;
		
	return null;
}
 
Example 4
Source File: GeneralUtils.java    From ADW with GNU General Public License v3.0 6 votes vote down vote up
/**
 * transforms character into part of speech ({@link POS})
 * @param tag
 * @return
 */
public static POS getTagfromTag(char tag)
{
	switch(tag)
	{
		case 'n':
			return POS.NOUN;
		
		case 'v':
			return POS.VERB;
			
		case 'a':
			return POS.ADJECTIVE;
			
		case 'r':
			return POS.ADVERB;
			
		default:
			return null;
	}
}
 
Example 5
Source File: POSTag.java    From senti-storm with Apache License 2.0 5 votes vote down vote up
public static POS parseString(String tag) {
  switch (tag.charAt(0)) {
    case 'n':
      return POS.NOUN;
    case 'v':
      return POS.VERB;
    case 'a':
      return POS.ADJECTIVE;
    case 'r':
      return POS.ADVERB;
    default:
      throw new IllegalStateException("Unknown POS tag '" + tag + "'!");
  }
}
 
Example 6
Source File: POSTag.java    From senti-storm with Apache License 2.0 5 votes vote down vote up
public static POS convertPTB(String pennTag) {
  if (pennTag.startsWith("NN")) { // includes proper nouns
    return POS.NOUN;
  }
  if (pennTag.startsWith("VB")) {
    return POS.VERB;
  }
  if (pennTag.startsWith("JJ")) {
    return POS.ADJECTIVE;
  }
  if (pennTag.startsWith("RB")) {
    return POS.ADVERB;
  }
  return null;
}
 
Example 7
Source File: WordNetUtils.java    From ADW with GNU General Public License v3.0 4 votes vote down vote up
public String getSingularOf(String word, POS pos)
{
// prima cerca tra le eccezioni
IExceptionEntry exc = dictionary.getExceptionEntry(word, pos);
if (exc != null) return exc.getRootForms().get(0);

String suffix = "";
if (pos == POS.NOUN)
{
	// e.g., handsful
	if (word.endsWith("ful"))
	{
		word = word.substring(0, word.length()-3);
		suffix = "ful";
	}
	// e.g., kiss, s
	else if (word.endsWith("ss") || word.length() <= 2) return word;
}

String[] suffixes = null;
String[] replacements = null;

switch(pos)
{
	case NOUN:
		suffixes = new String[] { "s", "ses", "shes", "ches", "zes", "xes", "men", "ies"};
		replacements = new String[] { "", "s", "sh", "ch", "z", "x", "man", "y" };
		break;

	case VERB:
		suffixes = new String[] { "s", "ies", "es", "es", "ed", "ed", "ing", "ing" };
		replacements = new String[] { "", "y", "e", "", "e", "", "e", "" };
		break;

	case ADJECTIVE:
		suffixes = new String[] { "er", "est", "er", "est" };
		replacements = new String[] { "", "", "e", "e" };
		break;

	case ADVERB:
	 	suffixes = new String[] {};
	 	break;
 }

for (int k = 0; k < suffixes.length; k++)
{
	String ret;
	if (word.endsWith(suffixes[k]))
	{
		ret = word.substring(0, word.length()-suffixes[k].length())+replacements[k];

		// se esiste un senso della parola in WordNet
		if (getSenses(ret, pos).size() > 0) return ret+suffix;
	}
}

return word+suffix;
}