Returns the POS tag of a given word based on the regular expression over
word string. Returns null if no match.
965043
public static PennTreebankPOS tag(String word) {
        for (int i = 0; i < REGEX.length; i++) {
            if (REGEX[i].matcher(word).matches()) {
                return REGEX_POS[i];
            }
        }

        return null;
    }
526712
def pos_tags(self):
        
        return [(Word(word, pos_tag=t), unicode(t))
                for word, t in self.pos_tagger.tag(self.raw)
                # new keyword PatternTagger(include_punc=False)
                # if not PUNCTUATION_REGEX.match(unicode(t))
                ]
294973
String getTagValue(Collection<Tag> tags, String key) {
        for (Tag tag : tags) {
            if (tag.getKey().toLowerCase(Locale.ENGLISH).equals(key.toLowerCase(Locale.ENGLISH))) {
                return tag.getValue();
            }
        }
        return null;
    }
449299
def null_term(str):
    ''''''
    idx = str.find("\0")
    if idx != -1:
        str = str[:idx]
    return str
1108064
def _get_pos_name(pos_code, names='parent', english=True, pos_map=POS_MAP):
    """"""
    pos_code = pos_code.lower()  # Issue #10
    if names not in ('parent', 'child', 'all'):
        raise ValueError("names must be one of 'parent', 'child', or "
                         "'all'; not '{}'".format(names))
    logger.debug("Getting {} POS name for '{}' formatted as '{}'.".format(
                 'English' if english else 'Chinese', pos_code, names))
    for i in range(1, len(pos_code) + 1):
        try:
            pos_key = pos_code[0:i]
            pos_entry = pos_map[pos_key]
            break
        except KeyError:
            if i == len(pos_code):
                logger.warning("part of speech not recognized: '{}'".format(
                               pos_code))
                return None  # Issue #20
    pos = (pos_entry[1 if english else 0], )
    if names == 'parent':
        logger.debug("Part of speech name found: '{}'".format(pos[0]))
        return pos[0]
    if len(pos_entry) == 3 and pos_key != pos_code:
        sub_map = pos_entry[2]
        logger.debug("Found parent part of speech name '{}'. Descending to "
                     "look for child name for '{}'".format(
                         pos_entry[1], pos_code))
        sub_pos = _get_pos_name(pos_code, names, english, sub_map)

        if names == 'all':
            # sub_pos can be None sometimes (e.g. for a word '甲')
            pos = pos + sub_pos if sub_pos else pos
        else:
            pos = (sub_pos, )

    name = pos if names == 'all' else pos[-1]
    logger.debug("Part of speech name found: '{}'".format(name))
    return name
1350666
def parse_singular_string(t, tag_name):
    ''''''
    pos = t.getElementsByTagName(tag_name)
    assert(len(pos) == 1)
    pos = pos[0]
    assert(len(pos.childNodes) == 1)
    return pos.childNodes[0].data
298358
private void seekNonWs(final String pattern, final ParsePosition pos) {
        int len = 0;
        final char[] buffer = pattern.toCharArray();
        do {
            len = StrMatcher.splitMatcher().isMatch(buffer, pos.getIndex());
            pos.setIndex(pos.getIndex() + len);
        } while (len > 0 && pos.getIndex() < pattern.length());
    }
659775
def _extract_word(self, source, position):
        
        boundry = re.search('{{|{|\s|$', source[:position][::-1])
        start_offset = boundry.end() if boundry.group(0).startswith('{') else boundry.start()

        boundry = re.search('}}|}|\s|$', source[position:])
        end_offset = boundry.end() if boundry.group(0).startswith('}') else boundry.start()

        return source[position - start_offset:position + end_offset]
49350
@Nullable
  public AnalyzedTokenReadings lookup(String word) throws IOException {
    List<AnalyzedTokenReadings> result = tag(Collections.singletonList(word), false);
    AnalyzedTokenReadings atr = result.get(0);
    if (atr.getAnalyzedToken(0).getPOSTag() == null) {
      return null;
    }
    return atr;
  }
596331
public String tag(final String word, final String postag) {
    // lookup postag as value of the map
    String newPosTag = this.dictMap.get(word.toLowerCase());
    if (newPosTag == null) {
      newPosTag = postag;
    }
    return newPosTag;
  }
1281883
function(re) {
  var match = re.exec(this.subject.slice(this.pos));
  if (match) {
    this.pos += match.index + match[0].length;
    return match[0];
  } else {
    return null;
  }
}
984274
def _match_tag_regex(self, event_tag, search_tag):
        '''
        
        '''
        return self.cache_regex.get(search_tag).search(event_tag) is not None
278363
public boolean checkPosConstraint(Sentence s, String posConstraint, MatchResult m, JCas jcas) {
		Pattern paConstraint = Pattern.compile("group\\(([0-9]+)\\):(.*?):");
		for (MatchResult mr : Toolbox.findMatches(paConstraint,posConstraint)) {
			int groupNumber = Integer.parseInt(mr.group(1));
			int tokenBegin = s.getBegin() + m.start(groupNumber);
			int tokenEnd   = s.getBegin() + m.end(groupNumber);
			String pos = mr.group(2);
			String pos_as_is = getPosFromMatchResult(tokenBegin, tokenEnd ,s, jcas);
			if (pos_as_is.matches(pos)) {
				Logger.printDetail("POS CONSTRAINT IS VALID: pos should be "+pos+" and is "+pos_as_is);
			} else {
				return false;
			}
		}
		return true;
	}
1309639
private static Tag readTagFromBuffer(BufferedReader br, boolean close) {
    int id = 0;
    String name = "", forceDescription = null;
    ArrayList<String> types = new ArrayList<>();
    String cardinality = "";
    String defaultValue = "";
    String typedef = null;
    String description = null;
    String[] valueCodes = null;
    String[] valueDescriptions = null;

    try {
      String sCurrentLine;
      boolean readingTypes = false;
      while ((sCurrentLine = br.readLine()) != null) {
        if (sCurrentLine.contains("\"id\"")) {
          String sid = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace(",", "").trim();
          id = Integer.parseInt(sid);
        } else if (sCurrentLine.contains("\"name\"")) {
          String sval = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace("\"", "").replace(",", "").trim();
          name = sval;
        } else if (sCurrentLine.contains("\"forceDescription\"")) {
          String sval = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace("\"", "").replace(",", "").trim();
          forceDescription = sval;
        } else if (sCurrentLine.contains("\"cardinality\"")) {
          String sval = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace("\"", "").replace(",", "").trim();
          cardinality = sval;
        } else if (sCurrentLine.contains("\"defaultValue\"")) {
          String sval = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace("\"", "").replace(",", "").trim();
          defaultValue = sval;
        } else if (sCurrentLine.contains("\"valueCodes\"")) {
          sCurrentLine = br.readLine();
          valueCodes = sCurrentLine.split(",");
        } else if (sCurrentLine.contains("\"description\"")) {
          description = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace("\"", "").replace(",", "").trim();
        } else if (sCurrentLine.contains("\"valueDescriptions\"")) {
          sCurrentLine = br.readLine();
          valueDescriptions = sCurrentLine.split(",");
        } else if (sCurrentLine.contains("\"typedef\"")) {
          String sval = sCurrentLine.substring(sCurrentLine.indexOf(":") + 1).replace("\"", "").replace(",", "").trim();
          typedef = sval;
        } else if (sCurrentLine.contains("\"type\"")) {
          readingTypes = true;
        } else if (sCurrentLine.contains("],")) {
          readingTypes = false;
        } else if (readingTypes) {
          String sval = sCurrentLine.replace("\"", "").replace(",", "").trim();
          types.add(sval);
        }
      }
    } catch (IOException e) {
      e.printStackTrace();
    } finally {
      try {
        //br.reset();
        if (br != null && close) br.close();
      } catch (IOException ex) {
        ex.printStackTrace();
      }
    }

    Tag tag = new Tag(id, name, types, cardinality, defaultValue, typedef, forceDescription);
    tag.setDescription(description);
    tag.createValuesDictionary();
    if (valueCodes != null && valueDescriptions != null && valueCodes.length == valueDescriptions.length) {
      HashMap<String, String> values = new HashMap<String, String>();
      for (int i=0;i<valueCodes.length;i++) {
        values.put(valueCodes[i].trim(), valueDescriptions[i].trim().replace("\"", ""));
      }
      tag.setValues(values);
    }

    tagMap.put(tag.getId(), tag);
    tagNames.put(tag.getName(), tag);
    return tag;
  }
1169337
public String[] getTags(String word) {
    if (caseSensitive) {
      return (String[]) dictionary.get(word);
    }
    else {
      //System.err.println(java.util.Arrays.asList((String[]) dictionary.get(word.toLowerCase())));
      return (String[]) dictionary.get(word.toLowerCase());
    }
  }
1238409
private String parseExemplarLocation(String text, ParsePosition pos) {
        int startIdx = pos.getIndex();
        int parsedPos = -1;
        String tzID = null;

        EnumSet<NameType> nameTypes = EnumSet.of(NameType.EXEMPLAR_LOCATION);
        Collection<MatchInfo> exemplarMatches = _tznames.find(text, startIdx, nameTypes);
        if (exemplarMatches != null) {
            MatchInfo exemplarMatch = null;
            for (MatchInfo match : exemplarMatches) {
                if (startIdx + match.matchLength() > parsedPos) {
                    exemplarMatch = match;
                    parsedPos = startIdx + match.matchLength();
                }
            }
            if (exemplarMatch != null) {
                tzID = getTimeZoneID(exemplarMatch.tzID(), exemplarMatch.mzID());
                pos.setIndex(parsedPos);
            }
        }
        if (tzID == null) {
            pos.setErrorIndex(startIdx);
        }

        return tzID;
    }
130251
public String getTagValue(String tagName) {
        String value = null;

        if (mReadMethod != null) {
            value = mReadMethod.getTagValue(tagName);
        }
        if (value == null && mWriteMethod != null) {
            value = mWriteMethod.getTagValue(tagName);
        }

        return value;
    }