TODO wsg2010: This should be deprecated in favor of the method below with new labels
425128
public static ArrayList<Word> toUntaggedList(String... words) {
    ArrayList<Word> sent = new ArrayList<Word>();
    for (String str : words) {
      sent.add(new Word(str));
    }
    return sent;
  }
1175509
def replace_label(self, oldLabel, newLabel):
        
        if oldLabel == newLabel:
            return

        tmp = re.compile(r'\b' + oldLabel + r'\b')
        last = 0
        l = len(newLabel)
        while True:
            match = tmp.search(self.asm[last:])
            if not match:
                break

            txt = self.asm
            self.asm = txt[:last + match.start()] + newLabel + txt[last + match.end():]
            last += match.start() + l
364564
def set_labels(self, *labels):
        
        assert all(isinstance(element, (github.Label.Label, str, unicode)) for element in labels), labels
        post_parameters = [label.name if isinstance(label, github.Label.Label) else label for label in labels]
        headers, data = self._requester.requestJsonAndCheck(
            "PUT",
            self.issue_url + "/labels",
            input=post_parameters
        )
385928
function buildPrefixLabelParts(schema, record) {
  if (isRegion(record.layer) &&
    isGeonamesOrWhosOnFirst(record.source) &&
    isInUSAOrCAN(record)) {
    return [];
  }

  if (isCountry(record.layer)) {
    return [];
  }

  if (isInKOR(record)) {
    return [];
  }

  // support name aliases
  if (Array.isArray(record.name.default)) {
    return record.name.default.slice(0,1);
  }

  return [record.name.default];

}
580719
private static String keyToGoWithElementsString(String label, DuplicateGroupedAndTyped elements) {
    /*
     * elements.toString(), which the caller is going to use, includes the homogeneous type (if
     * any), so we don't want to include it here. (And it's better to have it in the value, rather
     * than in the key, so that it doesn't push the horizontally aligned values over too far.)
     */
    return lenientFormat("%s (%s)", label, elements.totalCopies());
  }
396360
function(raw_tag) {

		var tags = raw_tag.content ? Lava.parsers.Common.asBlockType(raw_tag.content, 'tag') : [],
			count = tags.length,
			result = {
				type: 'container_stack',
				value: []
			},
			operations_stack = result.value,
			operation_value,
			used_instructions = {},
			name;

		if (count) {

			if (Lava.schema.DEBUG) {
				if (count > 1) Lava.t("Malformed resources/container definition");
				if (tags[0].name != 'static_properties' && tags[0].name != 'add_properties') Lava.t("Malformed resources/container definition");
				if (!tags[0].attributes || tags[0].content) Lava.t("resources/container: malformed (static/add)_properties tag");
				if (('class' in tags[0].attributes) || ('style' in tags[0].attributes)) Lava.t("resources/container: class and style attributes must be defined separately from properties");
			}

			operations_stack.push({
				name: tags[0].name,
				value: tags[0].attributes
			});
			used_instructions[tags[0].name] = true;

		}

		for (name in raw_tag.attributes) {

			switch (name) {
				case 'remove_classes':
				case 'remove_properties':
				case 'remove_styles':
					if (Lava.schema.DEBUG && !raw_tag.attributes[name].trim()) Lava.t("Codestyle: remove the empty remove_* attributes from resources/container tag");
					operation_value = raw_tag.attributes[name].trim().split(/\s*,\s*/);
					break;
				case 'add_classes':
				case 'static_classes':
					if (Lava.schema.DEBUG && name == 'add_classes' && !raw_tag.attributes[name].trim()) Lava.t("Codestyle: remove the empty add_classes attribute from resources/container tag");
					operation_value = raw_tag.attributes[name].trim().split(/\s+/);
					break;
				case 'add_styles':
				case 'static_styles':
					if (Lava.schema.DEBUG && name == 'add_styles' && !raw_tag.attributes[name].trim()) Lava.t("Codestyle: remove the empty style attribute from resources/container tag");
					operation_value = Lava.parsers.Common.parseStyleAttribute(raw_tag.attributes[name]);
					break;
				case 'path': // the path and name of the resource
					operation_value = null;
					break;
				default:
					Lava.t("Unknown resources/container attribute:" + name);
			}

			if (operation_value) {
				operations_stack.push({
					name: name,
					value: operation_value
				});
				used_instructions[name] = true;
			}

		}

		if (Lava.schema.DEBUG) {

			if (
				('static_styles' in used_instructions && (('add_styles' in used_instructions) || ('remove_styles' in used_instructions)))
				|| ('static_classes' in used_instructions && (('add_classes' in used_instructions) || ('remove_classes' in used_instructions)))
				|| ('static_properties' in used_instructions && (('add_properties' in used_instructions) || ('remove_properties' in used_instructions)))
			)
				Lava.t("resources/container: having add/remove instructions together with 'set' instruction has no sense");

			if (operations_stack.length == 0) Lava.t("Empty resources/container definition");

		}

		return result;

	}
381625
def tr(label, desc = "", tokens = {}, options = {})
      return label if label.tr8n_translated?

      if desc.is_a?(Hash)
        options = desc
        tokens  = options[:tokens] || {}
        desc    = options[:context] || ""
      end

      options.merge!(:caller => caller)
      if request
        options.merge!(:url => request.url)
        options.merge!(:host => request.env['HTTP_HOST'])
      end

      unless Tr8n::Config.enabled?
        return Tr8n::TranslationKey.substitute_tokens(label, tokens, options)
      end

      Tr8n::Config.current_language.translate(label, desc, tokens, options)
    end
130741
static String generateUniqueLabel(String label, Set<String> existingLabels) {
    StringBuilder newLabel = new StringBuilder(label);
    while (existingLabels.contains(newLabel.toString())) {
      newLabel.append(POSTFIX);
    }
    return newLabel.toString();
  }
152200
def _SetWsdlMethod(ns, wsdlName, inputMM):
   
   _wsdlMethodNSs.add(ns)
   curMM = _wsdlMethodMap.get( (ns, wsdlName) )
   # if inputMM is a list
   if isinstance(inputMM, list):
      if curMM is None:
         _wsdlMethodMap[(ns, wsdlName)] = inputMM
         return inputMM
      elif isinstance(curMM, list):
         raise RuntimeError(
                   "Duplicate wsdl method %s %s (new class %s vs existing %s)" % \
                   (ns, wsdlName, inputMM[0], curMM[0]))
      else:
         return curMM
   # if inputMM is a ManagedMethod
   else:
      if curMM is None or isinstance(curMM, list):
         _wsdlMethodMap[(ns, wsdlName)] = inputMM
         return inputMM
      else:
         return curMM
557868
def filter_label(label, replace_by_similar=True):
    
    bad_names = ['celsius', 'degree', 'ohm', 'venus', 'mars', 'astrosun',
                 'fullmoon', 'leftmoon', 'female', 'male', 'checked',
                 'diameter', 'sun', 'Bowtie', 'sqrt',
                 'cong', 'copyright', 'dag', 'parr', 'notin', 'dotsc',
                 'mathds', 'mathfrak']
    if any(label[1:].startswith(bad) for bad in bad_names):
        if label == '\\dag' and replace_by_similar:
            return '\\dagger'
        elif label == '\\diameter' and replace_by_similar:
            return '\\O'
        return label[1:]
    else:
        return label
670504
def AddLabels(self, labels):
    
    for label in labels:
      if not self._VALID_LABEL_REGEX.match(label):
        raise ValueError((
            'Unsupported label: "{0:s}". A label must only consist of '
            'alphanumeric characters or underscores.').format(label))

    for label in labels:
      if label not in self.labels:
        self.labels.append(label)
379288
@java.lang.Deprecated
  public java.util.Map<java.lang.String, java.lang.String> getTags() {
    return getTagsMap();
  }
1346054
def label_set(self, subid, label, params=None):
        ''' 
        '''
        params = update_params(params, {
            'SUBID': subid,
            'label': label
        })
        return self.request('/v1/server/label_set', params, 'POST')
909013
@java.lang.Deprecated
  public java.util.Map<java.lang.String, java.lang.String> getLabel() {
    return getLabelMap();
  }
1163145
private void appendMutableGetters(JMessage message, JField field) throws GeneratorException {
        if (field.field().getDescriptor() instanceof PPrimitive ||
            field.type() == PType.ENUM) {
            // The other fields will have ordinary non-mutable getters.
            appendGetter(field);
            return;
        }

        BlockCommentBuilder comment = new BlockCommentBuilder(writer);
        comment.commentRaw("Get the builder for the contained <code>" + field.name() + "</code> message field.");
        if (field.hasComment()) {
            comment.paragraph()
                   .comment(field.comment());
        }
        comment.newline()
               .return_("The field message builder");
        if (JAnnotation.isDeprecated(field)) {
            String reason = field.field().getAnnotationValue(ThriftAnnotation.DEPRECATED);
            if (reason != null && reason.trim().length() > 0) {
                comment.deprecated_(reason);
            }
        }
        comment.finish();
        if (JAnnotation.isDeprecated(field)) {
            writer.appendln(JAnnotation.DEPRECATED);
        }
        writer.appendln(JAnnotation.NON_NULL);
        switch (field.type()) {
            case MESSAGE: {
                writer.formatln("public %s._Builder %s() {", field.instanceType(), field.mutable())
                      .begin();

                if (message.isUnion()) {
                    writer.formatln("if (%s != _Field.%s) {", UNION_FIELD, field.fieldEnum())
                          .formatln("    %s();", field.resetter())
                          .appendln('}')
                          .formatln("%s = _Field.%s;", UNION_FIELD, field.fieldEnum());
                    writer.appendln("modified = true;");
                } else {
                    writer.formatln("optionals.set(%d);", field.index());
                    writer.formatln("modified.set(%d);", field.index());
                }

                writer.newline()
                      .formatln("if (%s != null) {", field.member())
                      .formatln("    %s_builder = %s.mutate();", field.member(), field.member())
                      .formatln("    %s = null;", field.member())
                      .formatln("} else if (%s_builder == null) {", field.member())
                      .formatln("    %s_builder = %s.builder();", field.member(), field.instanceType())
                      .appendln('}')
                      .formatln("return %s_builder;", field.member());

                writer.end()
                      .appendln('}')
                      .newline();

                // Also add "normal" getter for the message field, which will
                // return the message or the builder dependent on which is set.
                // It will not change the state of the builder.
                comment = new BlockCommentBuilder(writer);
                if (field.hasComment()) {
                    comment.comment(field.comment())
                           .newline();
                }
                comment.return_("The field value");
                if (JAnnotation.isDeprecated(field)) {
                    String reason = field.field().getAnnotationValue(ThriftAnnotation.DEPRECATED);
                    if (reason != null && reason.trim().length() > 0) {
                        comment.deprecated_(reason);
                    }
                }
                comment.finish();
                if (JAnnotation.isDeprecated(field)) {
                    writer.appendln(JAnnotation.DEPRECATED);
                }
                writer.formatln("public %s %s() {", field.instanceType(), field.getter())
                      .begin();

                if (message.isUnion()) {
                    writer.formatln("if (%s != _Field.%s) {", UNION_FIELD, field.fieldEnum())
                          .formatln("    return null;")
                          .appendln('}');
                }

                writer.newline()
                      .formatln("if (%s_builder != null) {", field.member())
                      .formatln("    return %s_builder.build();", field.member())
                      .appendln('}')
                      .formatln("return %s;", field.member());

                writer.end()
                      .appendln('}')
                      .newline();
                break;
            }
            case SET:
            case LIST:
            case MAP:
                comment = new BlockCommentBuilder(writer);
                if (field.hasComment()) {
                    comment.comment(field.comment())
                           .newline();
                }
                comment.return_("The mutable <code>" + field.name() + "</code> container");
                if (JAnnotation.isDeprecated(field)) {
                    String reason = field.field().getAnnotationValue(ThriftAnnotation.DEPRECATED);
                    if (reason != null && reason.trim().length() > 0) {
                        comment.deprecated_(reason);
                    }
                }
                comment.finish();
                if (JAnnotation.isDeprecated(field)) {
                    writer.appendln(JAnnotation.DEPRECATED);
                }
                writer.formatln("public %s %s() {", field.fieldType(), field.mutable())
                      .begin();

                if (message.isUnion()) {
                    writer.formatln("if (%s != _Field.%s) {", UNION_FIELD, field.fieldEnum())
                          .formatln("    %s();", field.resetter())
                          .appendln('}')
                          .formatln("%s = _Field.%s;", UNION_FIELD, field.fieldEnum());
                    writer.appendln("modified = true;");
                } else {
                    writer.formatln("optionals.set(%d);", field.index());
                    writer.formatln("modified.set(%d);", field.index());
                }
                writer.newline()
                      .formatln("if (%s == null) {", field.member())
                      .formatln("    %s = new %s<>();", field.member(), field.builderMutableType())
                      .formatln("} else if (!(%s instanceof %s)) {", field.member(), field.builderMutableType())
                      .formatln("    %s = new %s<>(%s);", field.member(), field.builderMutableType(), field.member())
                      .appendln("}");

                writer.formatln("return %s;", field.member());

                writer.end()
                      .appendln('}')
                      .newline();
                break;
            default:
                throw new GeneratorException("Unexpected field type: " + field.type());
        }
    }
788752
function deprecateRenamedMethod(book, key, instance, oldName, newName, msg) {
    msg = msg || ('"' + oldName + '" is deprecated, use "' + newName + '()" instead');
    var fn = objectPath.get(instance, newName);

    instance[oldName] = deprecateMethod(book, key, fn, msg);
}
175482
def add(self, tag, data=None, indicators=None, **kwargs):
        
        if tag.startswith("00") and (data is None or data == "") and not self.strict:
            return

        if data:
            if indicators:
                raise ValueError(Record.E_NO_INDICATORS)
            if not tag.startswith('00'):
                raise ValueError(Record.E_NO_DATA)
        else:
            if tag.startswith('00'):
                raise ValueError(Record.E_EMPTY)

        if tag.startswith('00') and kwargs:
            raise ValueError(Record.E_NO_SUBFIELDS)

        if indicators is None:
            indicators = [' ', ' ']
        if isinstance(indicators, basestring):
            if len(indicators) == 2:
                indicators = [indicators[0], indicators[1]]
            else:
                raise ValueError(Record.E_INVALID_INDICATOR)

        if data:  # == control field (001 -- 009)
            field = pymarc.Field(tag, data=data)
        else:     # == non-control field (010 -- 999)
            if 'subfields' in kwargs:
                sfs = kwargs['subfields']
                subfields = [v for sl in [(a, b) for a, b in zip(sfs[::2], sfs[1::2]) if b] for v in sl]
            else:
                subfields = []
                for key, value in kwargs.items():
                    if value is None:
                        continue
                    key = key.replace('_', '')
                    if isinstance(value, basestring):
                        if value == "":
                            continue
                        subfields += [key, value]
                    elif isinstance(value, collections.Iterable):
                        for val in value:
                            if not isinstance(val, basestring):
                                raise ValueError('subfield values must be strings')
                            if val:
                                subfields += [key, val]
                    else:
                        raise ValueError('subfield values must be strings')

            if not any(subfields[1::2]):
                if self.strict:
                    raise ValueError('none of the subfields contains a value')
                else:
                    return

            field = pymarc.Field(tag, indicators, subfields=subfields)
        self.add_field(field)