assume person entity using cnschma person vocabulary, http://cnschema.org/Person
176523
def summarize_entity_person(person):
    
    ret = []
    value = person.get("name")
    if not value:
        return False
    ret.append(value)

    prop = "courtesyName"
    value = json_get_first_item(person, prop)
    if value == u"不详":
        value = ""
    if value:
        ret.append(u'字{}'.format(value))

    value = person.get("alternateName")
    if value:
        #ret.append(u'别名{}'.format(value))
        # Bugged
        pass

    prop = "artName"
    value = json_get_first_item(person, prop)
    if value:
        ret.append(u'号{}'.format(value))

    value = person.get("dynasty")
    if value:
        ret.append(u'{}人'.format(value))

    prop = "ancestralHome"
    value = json_get_first_item(person, prop)
    if value:
        ret.append(u'祖籍{}'.format(value))

    birth_date = person.get("birthDate", "")
    birth_place = person.get("birthPlace", "")

    # Special case for unknown birth date
    if birth_date == u"不详":
        birth_date = ""

    if birth_place:
        ret.append(u'{}出生于{}'.format(birth_date, birth_place))
    elif birth_date:
        ret.append(u'{}出生'.format(birth_date))

    prop = "nationality"
    nationality = json_get_first_item(person, prop)
    prop = "occupation"
    occupation = json_get_first_item(person, prop)
    if occupation:
        if nationality:
            ret.append(u'{}{}'.format(nationality, occupation))
        else:
            ret.append(u'{}'.format(occupation))
    elif nationality:
        ret.append(u'{}人'.format(nationality))

    prop = "authorOf"
    value = json_get_list(person, prop)
    if value:
        logging.info(value)
        value = u"、".join(value)
        ret.append(u'主要作品：{}'.format(value) )

    prop = "accomplishment"
    value = json_get_list(person, prop)
    if value:
        value = u"、".join(value)
        if len(value) < 30:
            # Colon is handled by text reading software
            ret.append( u"主要成就：{}".format(value) )

    ret = u"，".join(ret)

    # Make all commas Chinese
    ret = ret.replace(u',', u'，')
    ret = re.sub(u"，+", u"，", ret) # Removes repeat commas
    # Handles periods at end
    ret = re.sub(ur"[。，]+$", u"", ret)

    # Converts brackets to Chinese
    ret = ret.replace(u'(', u'（')
    ret = ret.replace(u')', u'）')
    # Removes brackets and all contained info
    ret = re.sub(ur"（[^）]*）", u"", ret)

    ret = u''.join([ret, u"。"])

    return ret
1226522
def user_parse(data):
        """"""
        _user = data.get('oauth', {}).get('user', {})
        yield 'id', _user.get('id')
        yield 'username', _user.get('username')
        first_name, _, last_name = _user.get('display_name').partition(' ')
        yield 'first_name', first_name
        yield 'last_name', last_name
628247
private Glyph getCompartment(PhysicalEntity pe) {
		CellularLocationVocabulary cl = pe.getCellularLocation();
		if (cl != null && !cl.getTerm().isEmpty()) {
			String name = null;
			// get a cv term,
			// ignoring IDs (should not be there but happens)
			for(String term : cl.getTerm()) {
				term = term.toLowerCase();
				if(!term.matches("(go|so|mi|bto|cl|pato|mod):")) {
				 name = term;
				 break;
				}
			}
			return getCompartment(name);
		} else
			return null;
	}
1184151
def user_parse(data):
        """"""
        _user = data.get('user_info', {})
        _id = _user.get('id') or _user.get('uid')
        yield 'id', _id
        yield 'locale', _user.get('default_lang')
        yield 'username', _user.get('display_name')
        first_name, _, last_name = _user.get('full_name', '').partition(' ')
        yield 'first_name', first_name
        yield 'last_name', last_name
        yield 'picture', 'http://avatars.plurk.com/{0}-big2.jpg'.format(_id)
        city, country = map(lambda s: s.strip(),
                            _user.get('location', ',').split(','))
        yield 'city', city
        yield 'country', country
491191
def _find_entity(self, entity):
        ''' '''
        if entity in self.entities:
            return self.entities[entity]
        _ent = [e for e in self.entities.values() if e.name == entity]
        if len(_ent) > 1:
            raise ValueError("Entity name '%s' matches %d entities. To "
                             "avoid ambiguity, please prefix the entity "
                             "name with its domain (e.g., 'bids.%s'." %
                             (entity, len(_ent), entity))
        if _ent:
            return _ent[0]

        raise ValueError("No entity '%s' found." % entity)
39500
def get(self, user_id):
        """"""
        path = '/'.join(['person', user_id])
        return self.rachio.get(path)
1214594
def _parse_entities(self):
        
        entities = list()

        for result in self._data:
            entity = dict()
            char_fragment = result.get('charFragment')
            start = char_fragment.get('start')
            end = char_fragment.get('end')
            entity['start'] = start
            entity['end'] = end
            entity['text'] = self._text[start: end+1]
            if sys.version < '3' and isinstance(entity['text'], str):
                entity['text'] = entity['test'].decode('utf-8')
            entity['isEntity'] = True
            for key, value in result.items():
                entity[key] = value
            entities.append(entity)
        self._entities = entities
397602
def individual(self, ind_id):
        """"""
        ind_obj = self.query(Individual).filter_by(ind_id=ind_id).first()
        if ind_obj is None:
            ind_obj = BaseIndividual(ind_id='unknown')
        return ind_obj
330183
def apply(self, tokens):
        
        # Note: we could also scan for patterns, e.g.,
        # "my|his|her name is|was *" => NNP-PERS.
        i = 0
        while i < len(tokens):
            w = tokens[i][0].lower()
            if RE_ENTITY1.match(w) \
            or RE_ENTITY2.match(w) \
            or RE_ENTITY3.match(w):
                tokens[i][1] = self.tag
            if w in self:
                for e in self[w]:
                    # Look ahead to see if successive words match the named entity.
                    e, tag = (e[:-1], "-"+e[-1].upper()) if e[-1] in self._cmd else (e, "")
                    b = True
                    for j, e in enumerate(e):
                        if i + j >= len(tokens) or tokens[i+j][0].lower() != e:
                            b = False; break
                    if b:
                        for token in tokens[i:i+j+1]:
                            token[1] = token[1] if token[1].startswith(self.tag) else self.tag
                            token[1] += tag
                        i += j
                        break
            i += 1
        return tokens
1197271
async def _replace_with_mention(self, entities, i, user):
        
        try:
            entities[i] = types.InputMessageEntityMentionName(
                entities[i].offset, entities[i].length,
                await self.get_input_entity(user)
            )
            return True            
        except (ValueError, TypeError):
            return False
341630
def _resolve_entity (mo):
    
    ent = mo.group("entity")
    s = mo.group()
    if s.startswith('&#'):
        if s[2] in 'xX':
            radix = 16
        else:
            radix = 10
        try:
            num = int(ent, radix)
        except (ValueError, OverflowError):
            return u''
    else:
        num = name2codepoint.get(ent)
    if num is None or num < 0:
        # unknown entity -> ignore
        return u''
    try:
        return unichr(num)
    except ValueError:
        return u''
1075402
def process_synonyms(self, entity: List[dict]) -> List[dict]:
        
        label = entity['label']
        for synonym in entity['synonyms']:
            # these are internal errors and users should never see them
            if 'literal' not in synonym:
                raise ValueError(f'Synonym not given a literal for label: {label}')
            elif len(synonym) > 1:
                raise ValueError(f'Too many keys in synonym for label: {label}')
        return entity
1269788
@RequestMapping("/head")
    public final String person(
            @RequestParam(value = "db",
                required = false,
                defaultValue = "schoeller") final String dbName,
            final Model model) {
        logger.debug("Entering head");

        final RenderingContext context = createRenderingContext();

        final Head head = fetchHead(dbName);

        final String filename = gedbrowserHome + "/" + dbName + ".ged";
        model.addAttribute("filename", filename);
        model.addAttribute("model", headRenderer(context, head));
        model.addAttribute("appInfo", appInfo);

        return "head";
    }
71259
def from_dict(d):
        """"""
        query_params_match = d.get('@query_params_match')
        sources = [Source.from_dict(source) for source in d.get('sources', [])]
        fields = Person.fields_from_dict(d)
        return Person(fields=fields, sources=sources,
                      query_params_match=query_params_match)
663793
def nb_persons(self, role = None):
        
        if role:
            if role.subroles:
                role_condition = np.logical_or.reduce([self.members_role == subrole for subrole in role.subroles])
            else:
                role_condition = self.members_role == role
            return self.sum(role_condition)
        else:
            return np.bincount(self.members_entity_id)
1299176
def human_name
      @human_name ||= begin
        str = controller_path
        single = str.singularize
        I18n.t(         "activerecord.models.#{model.to_s.underscore}",
          default:      I18n.t("controller.#{str}",
            default:    I18n.t(single,
              default:  single.camelize)))
      end
    end
21702
def InferUserAndSubjectFromUrn(self):
    """"""
    _, client_id, user, _ = self.urn.Split(4)
    return (user, rdf_client.ClientURN(client_id))