Returns a list of literals
        in the Synset
        read-only
774355
def literals():
        '''
        '''
        def fget(self):
            if self.variants:
                return map(lambda x: x.literal,
                           self.variants)
            else:
                return None
 
        return locals()
1146511
def bracketedList(l, r, sep, expr, allow_missing_close=False):
  
  # We may need to backtrack for lists, because of list comprehension, but not for
  # any of the other lists
  strict = l != '['
  closer = sym(r) if not allow_missing_close else p.Optional(sym(r))
  if strict:
    return sym(l) - listMembers(sep, expr) - closer
  else:
    return sym(l) + listMembers(sep, expr) + closer
1336905
def parse_from_args(synonyms):
    '''
    
    '''

    syns_str = ''.join(synonyms)

    syns_str = syns_str.replace(' ', '')
    
    syn_set = SynonymSet()

    # to check if we are parsing inside the parenthesis
    inside_set = False
    current_syn = ''
    current_syn_set = set()

    for char in syns_str:
        if char == '{':
            inside_set = True
            current_syn_set = set()
            continue

        if char == '}':
            inside_set = False
            current_syn_set.add(current_syn)

            syn_set.add_set(current_syn_set)

            current_syn = ''

            continue

        if not inside_set:
            raise Exception("Incorrect synonyms {}".format(syns_str))

        if char == ',':
            if current_syn == '':
                raise Exception("Incorrect synonyms {}".format(syns_str))

            current_syn_set.add(current_syn)
            current_syn = ''

            continue

        current_syn += char

    return syn_set
1334161
def _get_filtered_stmts(self, lookup_node, node, _stmts, mystmt):
        """"""
        if self is mystmt:
            return _stmts, True
        if self.statement() is mystmt:
            # original node's statement is the assignment, only keep
            # current node (gen exp, list comp)
            return [node], True
        return _stmts, False
696199
private ImmutableList<ParseTree> parseExportSpecifierSet() {
    ImmutableList.Builder<ParseTree> elements;
    elements = ImmutableList.builder();
    eat(TokenType.OPEN_CURLY);
    while (peekIdOrKeyword()) {
      elements.add(parseExportSpecifier());
      if (!peek(TokenType.CLOSE_CURLY)) {
        eat(TokenType.COMMA);
      }
    }
    eat(TokenType.CLOSE_CURLY);
    return elements.build();
  }
285005
def readTupleQuotes(self, symbol, start, end):
        '''  '''
        if end is None:
            end=sys.maxint

        session=self.getReadSession()()
        try:
            rows=session.query(Quote).filter(and_(Quote.symbol == symbol,
                                                       Quote.time >= int(start),
                                                       Quote.time < int(end)))
        finally:
            self.getReadSession().remove()

        return rows
859161
protected List<Map<String, ?>> generateLiterals(Set<String> literals) {
		final List<Map<String, ?>> list = new ArrayList<>();
		if (!literals.isEmpty()) {
			list.add(pattern(it -> {
				it.matches(keywordRegex(literals));
				it.style(LITERAL_STYLE);
				it.comment("SARL Literals and Constants"); //$NON-NLS-1$
			}));
		}
		return list;
	}
42387
def natural_keys(text):
    '''
    
    '''
    return [int(c) if c.isdigit() else c for c in re.split(r'(\d+)', text)]
1038229
def get_literals(self, c, i, depth):
        

        result = ['']
        is_dollar = False

        try:
            while c:
                ignore_brace = is_dollar
                is_dollar = False

                if c == '$':
                    is_dollar = True

                elif c == '\\':
                    c = [self.get_escape(c, i)]

                elif not ignore_brace and c == '{':
                    # Try and get the group
                    index = i.index
                    try:
                        seq = self.get_sequence(next(i), i, depth + 1)
                        if seq:
                            c = seq
                    except StopIteration:
                        # Searched to end of string
                        # and still didn't find it.
                        i.rewind(i.index - index)

                elif self.is_expanding() and c in (',', '}'):
                    # We are Expanding within a group and found a group delimiter
                    # Return what we gathered before the group delimiters.
                    i.rewind(1)
                    return (x for x in result)

                # Squash the current set of literals.
                result = self.squash(result, [c] if isinstance(c, str) else c)

                c = next(i)
        except StopIteration:
            if self.is_expanding():
                return None

        return (x for x in result)
808940
def getLiteral(self):
        ''''''
        # we are on the first non-special character
        chars = u''
        c = self.current()
        while True:
            if c and c == u"\\":
                c = self.next()
                if c:
                    chars += c
                continue
            elif not c or (c in self.meta_chars):
                break
            else:
                chars += c
            if self.lookahead() and self.lookahead() in self.meta_chars:
                break
            c = self.next()
        return StringGenerator.Literal(chars)
486750
def t_LITERAL(self, t):
        ''
        s = t.value[1:-1]
        maps = {
            't': '\t',
            'r': '\r',
            'n': '\n',
            '\\': '\\',
            '\'': '\'',
            '"': '\"'
        }
        i = 0
        length = len(s)
        val = ''
        while i < length:
            if s[i] == '\\':
                i += 1
                if s[i] in maps:
                    val += maps[s[i]]
                else:
                    msg = 'Cannot escape character: %s' % s[i]
                    raise ThriftParserError(msg)
            else:
                val += s[i]
            i += 1

        t.value = val
        return t
298879
public List<String> getLiterals() {
    return this.templateChunks.stream()
        .filter(templateChunk -> Literal.class.isAssignableFrom(templateChunk.getClass()))
        .map(TemplateChunk::toString)
        .filter(Objects::nonNull)
        .collect(Collectors.toList());
  }
1266081
def all_contents(self):
        ''''''
        translations_iterator = chain(*self.translations_lists())
        return chain(translations_iterator,
                     *(pair[i] for pair in self.contents_list_pairs()
                       for i in (0, 1)))
397658
def parse_synset(self, offset=None, debug=False):
        
        if False:
            pass
        else:
            # WORD_INSTANCE
            def _word_instance():
                _synset(True)

            # WORD_MEANING
            def _synset(pn=False):
                if not pn:
                    self.synset = Synset()
                    self.pn = False
                else:
                    self.synset = WordInstance()
                    self.pn = True
                if self.DRN:
                    self.synset.number = self.DRN
                self.targetType = None

            def _variants():
                self.synset.variants = Variants()

            def _literal():
                a = Variant()
                self.synset.variants.append(a)
                self.synset.variants[-1].literal = self.fieldValue

            def _target_literal():
                    self.target_synset.variants.append(Variant())
                    self.target_synset.variants[-1].literal = self.fieldValue

            def _sense():
                self.synset.variants[-1].sense = self.fieldValue

            def _status():
                self.noQuotes = True
                try:
                    self.synset.variants[-1].status = as_unicode(self.fieldValue)
                except:
                    self.synset.variants[-1].status = as_unicode(str(self.fieldValue))
                self.noQuotes = False

            def _target_sense():
                self.target_synset.variants[-1].sense = self.fieldValue
                if self.targetType == 'internal':
                    self.synset.internalLinks[
                        -1].target_concept = self.target_synset
                elif self.targetType == 'ili':
                    self.synset.eqLinks[-1].target_concept = self.target_synset
                elif self.targetType == 'pv':
                    self.synset.propertyValues[-1].value = self.target_synset
                else:
                    print ('BOOOOOOOOO!!') # Error TODO

            def _gloss():
                self.synset.variants[-1].gloss = self.fieldValue
                self.synset.definition = self.fieldValue                            # ADDED BY KOM

            def _translations():
                self.synset.variants[-1].translations = Translations()

            def _translation():
                self.synset.variants[-1].translations.append(
                    Translation(
                        language=self.fieldValue.split(':')[0],
                        translation_value = self.fieldValue.split(':')[1])
                    )

            def _examples():
                self.synset.variants[-1].examples = Examples()
            def _usage_labels():
                self.synset.variants[-1].usage_labels = Usage_Labels()

            def _external_info():
                self.synset.variants[-1].externalInfo = External_Info()

            def _example():
                self.synset.variants[-1].examples.append(
                    Example(self.fieldValue)
                    )

            def _usage_label():
                self.synset.variants[
                    -1].usage_labels.append(
                    Usage_Label(name=self.fieldValue)
                    )

            def _usage_label_value():
                self.synset.variants[
                    -1].usage_labels[-1].usage_label_value = self.fieldValue

            def _source_id():
                if self.targetType == 'internal':
                    self.synset.internalLinks[-1].source_id = self.fieldValue
                    # self.synset.internalLinks[-1].source_ids.append(
                    #     Relation_Source_Id(number=self.fieldValue))
                elif self.targetType == 'ili':
                    self.synset.eqLinks[-1].source_id = self.fieldValue
                    # self.synset.eqLinks[-1].source_ids.append(
                    #     Relation_Source_Id(number=self.fieldValue))

                else:
                    if self.synset.variants[-1].external_info:
                        self.synset.variants[
                            -1].external_info.source_ids.append(
                            Source_Id(number=self.fieldValue)
                            )
                    else:
                        self.synset.variants[-1].external_info = External_Info()
                        self.synset.variants[
                            -1].external_info.source_ids.append(
                            Source_Id(number=self.fieldValue)
                            )

            def _corpus_id():
                if self.targetType == 'internal': # not needed
                    self.synset.internalLinks[-1].corpus_ids.append(
                        Relation_Corpus_Id(number=self.fieldValue))
                else:
                    if self.synset.variants[-1].external_info:
                        self.synset.variants[
                            -1].external_info.corpus_ids.append(
                            Corpus_Id(number=self.fieldValue)
                            )
                    else:
                        self.synset.variants[-1].external_info = External_Info()
                        self.synset.variants[
                            -1].external_info.corpus_ids.append(
                            Corpus_Id(number=self.fieldValue)
                            )

            def _frequency():
                self.synset.variants[
                    -1].external_info.corpus_ids[-1].frequency = self.fieldValue

            def _text_key():
                self.synset.variants[
                    -1].external_info.source_ids[-1].text_key = self.fieldValue

            def _number_key():
                self.synset.variants[
                    -1].external_info.source_ids[
                    -1].number_key = self.fieldValue
            def _pos():
                self.synset.pos = self.fieldValue

            # INTERNAL_LINKS
            def _target_concept():
                self.target_synset = Synset()
                self.target_synset.variants = Variants()
                if self.levelNumber == 3: # and self.fieldValue:
                    self.target_synset.number = int(self.fieldValue or 0)

            def _target_pos():
                self.target_synset.pos = self.fieldValue

            def _internal_links():
                self.synset.internalLinks = InternalLinks()
                self.targetType = 'internal'

            def _relation():
                if self.targetType == 'internal':
                    self.synset.internalLinks.append(Relation())
                    self.synset.internalLinks[-1].name = self.fieldValue
                elif self.targetType == 'ili':
                    self.synset.eqLinks.append(EqLink())
                    self.synset.eqLinks[-1].name = self.fieldValue
                else:
                    print ('BOOOOOOOOO!!') # Error TODO

            def _features():
                if self.targetType == 'internal':
                    self.synset.internalLinks[-1].features = Features()
                else:
                    self.synset.variants[-1].features = Features()
                    self.synset.variants[-1].features.append(Feature())

            def _feature():
                self.synset.variants[-1].features[-1].name = self.fieldValue

            def _feature_value():
                self.synset.variants[
                    -1].features[-1].featureValue = self.fieldValue

            def _reversed():
                self.synset.internalLinks[-1].features.append(Feature())
                self.synset.internalLinks[-1].features[-1].name = self.fieldTag
                self.synset.internalLinks[-1].features[-1].featureValue = True

            def _variant_to_variant():
                self.synset.internalLinks[-1].features.append(Feature())
                self.synset.internalLinks[-1].features[-1].name = self.fieldTag

            def _source_variant():
                self.variant_to_variant_source = self.fieldValue

            def _target_variant():
                self.variant_to_variant_target = self.fieldValue
                self.synset.internalLinks[
                    -1].features[-1].featureValue = (
                    self.variant_to_variant_source,
                    self.variant_to_variant_target)

            # EQ_LINKS
            def _eq_links():
                self.synset.eqLinks = EqLinks()
                self.targetType = 'ili'

            def _wn_offset():
                self.target_synset.wordnet_offset = self.fieldValue
                self.synset.eqLinks[-1].target_concept = self.target_synset

            def _add_on_id():
                self.target_synset.add_on_id = self.fieldValue
                self.synset.eqLinks[-1].target_concept = self.target_synset

            # PROPERTIES
            def _properties():
                self.synset.properties = Properties()

            def _name():
                if self.pn:
                    self.synset.propertyValues.append(
                        PropertyValue(name=self.fieldValue))
                else:
                    self.synset.properties.append(Property(self.fieldValue))

            # PROPERTY_VALUES
            def _property_values():
                self.synset.propertyValues = PropertyValues()

            def _property_value():
                self.synset.propertyValues[-1].value = self.fieldValue
                self.targetType = 'pv'

            def _property_wm():
                pass

            rulez = {
                (0,'WORD_MEANING'): _synset,
                (0,'WORD_INSTANCE'): _word_instance,
                (1,'PART_OF_SPEECH'): _pos,
                (1,'VARIANTS'): _variants,
                (2,'LITERAL'): _literal,
                (3,'SENSE'): _sense,
                (3,'STATUS'): _status,
                (3,'DEFINITION'): _gloss,
                (3,'EXAMPLES'): _examples,
                (3,'USAGE_LABELS'): _usage_labels,
                (4,'USAGE_LABEL'): _usage_label,
                (5,'USAGE_LABEL_VALUE'): _usage_label_value,
                (4,'EXAMPLE'): _example,
                (3,'TRANSLATIONS'): _translations,
                (4,'TRANSLATION'): _translation,
                (3,'EXTERNAL_INFO'): _external_info,
                (4,'SOURCE_ID'): _source_id,
                (4,'CORPUS_ID'): _corpus_id,
                (5,'FREQUENCY'): _frequency,
                (5,'TEXT_KEY'): _text_key,
                (5,'NUMBER_KEY'): _number_key,
                (1,'INTERNAL_LINKS'): _internal_links,
                (2,'RELATION'): _relation,
                (3,'TARGET_CONCEPT'): _target_concept,
                (4,'PART_OF_SPEECH'): _target_pos,
                (4,'LITERAL'): _target_literal,
                (5,'SENSE'): _target_sense,
                (3,'FEATURES'): _features,
                (4,'FEATURE'): _feature,
                (5,'FEATURE_VALUE'): _feature_value,
                (4,'REVERSED'): _reversed,
                (4,'VARIANT_TO_VARIANT'): _variant_to_variant,
                (5,'SOURCE_VARIANT'): _source_variant,
                (5,'TARGET_VARIANT'): _target_variant,
                (3,'SOURCE_ID'): _source_id,
                (1,'EQ_LINKS'): _eq_links,
                (2,'EQ_RELATION'): _relation,
                (3,'TARGET_ILI'): _target_concept,
                (4,'WORDNET_OFFSET'): _wn_offset,
                (4,'ADD_ON_ID'): _add_on_id,
                (1,'PROPERTIES'): _properties,
                (1,'PROPERTY_VALUES'): _property_values,
                (2,'NAME'): _name,
                (3,'VALUE'): _property_value,
                (3,'VALUE_AS_TEXT'): _property_value,
                (3,'VALUE_AS_WORD_MEANING'): _target_concept,
                }

            if not offset:
                offset = self.milestone
            else:
                self.milestone=offset
            if self.file:
                self.file.seek(offset,0)

            line = 'X'
            ili = False
            var = False
            while line.strip():

                offset = self.file.tell()
                self.file.seek(offset,0)

                line = as_unicode(self.file.readline(), self.encoding).strip()
                if debug:
                    print (line.encode('utf-8'))


                self.parse_line(line)
                self.noQuotes = None

                select = (self.levelNumber,self.fieldTag)

                if select in rulez.keys():
                    rulez[select]()
                else:
                    if line:
                        print (self.synset.polarisText)
                        raise ParseError("No parsing rule for '%s'" % line)
        return self.synset
275474
def attrlist(self):
        ''
        keymap = self.config.get('KEY_MAP')
        if keymap:
            # https://github.com/ContinuumIO/flask-ldap-login/issues/11
            # https://continuumsupport.zendesk.com/agent/tickets/393
            return [s.encode('utf-8') for s in keymap.values()]
        else:
            return None
848951
def ls(args):
    
    db = Database(args.db)
    db.create(exists_ok=True)
    in_db = {r[0]: r[1] for r in db.fetchall('select id, version from dataset')}
    # FIXME: how to smartly choose columns?
    table = Table('ID', 'Title')
    cols = OrderedDict([
        (col, {}) for col in args.args if col in [
            'version',
            'location',
            'changes',
            'license',
            'all_lexemes',
            'lexemes',
            'concepts',
            'languages',
            'families',
            'varieties',
            'macroareas',
        ]])
    tl = 40
    if cols:
        tl = 25
        table.columns.extend(col.capitalize() for col in cols)

    for col, sql in [
        ('languages', 'glottocodes_by_dataset'),
        ('concepts', 'conceptsets_by_dataset'),
        ('lexemes', 'mapped_lexemes_by_dataset'),
        ('all_lexemes', 'lexemes_by_dataset'),
        ('macroareas', 'macroareas_by_dataset'),
        ('families', 'families_by_dataset'),
    ]:
        if col in cols:
            cols[col] = {r[0]: r[1] for r in db.fetchall(sql)}
    for ds in args.cfg.datasets:
        row = [
            colored(ds.id, 'green' if ds.id in in_db else 'red'),
            truncate_with_ellipsis(ds.metadata.title or '', width=tl),
        ]
        for col in cols:
            if col == 'version':
                row.append(git_hash(ds.dir))
            elif col == 'location':
                row.append(colored(str(ds.dir), 'green'))
            elif col == 'changes':
                row.append(ds.git_repo.is_dirty())
            elif col == 'license':
                lic = licenses.find(ds.metadata.license or '')
                row.append(lic.id if lic else ds.metadata.license)
            elif col in ['languages', 'concepts', 'lexemes', 'all_lexemes', 'families']:
                row.append(float(cols[col].get(ds.id, 0)))
            elif col == 'macroareas':
                row.append(', '.join(sorted((cols[col].get(ds.id) or '').split(','))))
            else:
                row.append('')

        table.append(row)
    totals = ['zztotal', len(args.cfg.datasets)]
    for i, col in enumerate(cols):
        if col in ['lexemes', 'all_lexemes']:
            totals.append(sum([r[i + 2] for r in table]))
        elif col == 'languages':
            totals.append(float(db.fetchone(
                "SELECT count(distinct glottocode) FROM languagetable")[0]))
        elif col == 'concepts':
            totals.append(float(db.fetchone(
                "SELECT count(distinct concepticon_id) FROM parametertable")[0]))
        elif col == 'families':
            totals.append(float(db.fetchone(
                "SELECT count(distinct family) FROM languagetable")[0]))
        else:
            totals.append('')
    table.append(totals)
    print(table.render(
        tablefmt='simple', sortkey=lambda r: r[0], condensed=False, floatfmt=',.0f'))
758604
def str_lexer(mode):
    
    cast_to_const = ConstStrPool.cast_to_const

    def f_raw(inp_str, pos):
        return cast_to_const(mode) if inp_str.startswith(mode, pos) else None

    def f_collection(inp_str, pos):
        for each in mode:
            if inp_str.startswith(each, pos):
                return cast_to_const(each)
        return None

    if isinstance(mode, str):
        return f_raw

    if len(mode) is 1:
        mode = mode[0]
        return f_raw

    return f_collection