Extract the journal reference from string.

    Extracts the journal reference from string and parses for specific
    journal information.
15659
def extract_journal_reference(line, override_kbs_files=None):
    
    kbs = get_kbs(custom_kbs_files=override_kbs_files)
    references, dummy_m, dummy_c, dummy_co = parse_reference_line(line, kbs)

    for elements in references:
        for el in elements:
            if el['type'] == 'JOURNAL':
                return el
981710
def get_object_references(tb, source, max_string_length=1000):
    
    global obj_ref_regex
    referenced_attr = set()
    for line in source.split('\n'):
        referenced_attr.update(set(re.findall(obj_ref_regex, line)))
    referenced_attr = sorted(referenced_attr)
    info = []
    for attr in referenced_attr:
        v = string_variable_lookup(tb, attr)
        if v is not ValueError:
            ref_string = format_reference(v, max_string_length=max_string_length)
            info.append((attr, ref_string))
    return info
903793
def parse_string(s):
        '''
        
        '''
        matched_obj = SPLIT_URL_RE.match(s)
        if not matched_obj:
            raise URLParseException('Invalid Resource URL: "%s"' % s)

        url_string, arguments_string = matched_obj.groups()
        args_as_strings = URL_ARGUMENTS_RE.findall(arguments_string)

        # Determine args and kwargs
        args = []
        kwargs = {}
        for arg_string in args_as_strings:
            kwarg_match = ARG_RE.match(arg_string)
            if kwarg_match:
                key, value = kwarg_match.groups()
                kwargs[key.strip()] = value.strip()
            else:
                args.append(arg_string.strip())

        # Default to HTTP if url_string has no URL
        if not SCHEME_RE.match(url_string):
            url_string = '%s://%s' % (DEFAULT_SCHEME, url_string)

        return url_string.strip(), args, kwargs
1258297
def from_string(self, string_representation, resource=None):
        
        stream = NativeIO(string_representation)
        return self.from_stream(stream, resource=resource)
578737
function extractRefs(node, refs) {
  	var i, list;

  	if (node.t === REFERENCE) {
  		if (refs.indexOf(node.n) === -1) {
  			refs.unshift(node.n);
  		}
  	}

  	list = node.o || node.m;
  	if (list) {
  		if (isObject(list)) {
  			extractRefs(list, refs);
  		} else {
  			i = list.length;
  			while (i--) {
  				extractRefs(list[i], refs);
  			}
  		}
  	}

  	if (node.x) {
  		extractRefs(node.x, refs);
  	}

  	if (node.r) {
  		extractRefs(node.r, refs);
  	}

  	if (node.v) {
  		extractRefs(node.v, refs);
  	}
  }
43206
def parse_string(contents, name='tmp.cpp', **kwargs):
    
    idx = clang.cindex.Index.create()
    tu = idx.parse(name, unsaved_files=[(name, contents)], **kwargs)
    return _ensure_parse_valid(tu)
193769
def extract_chapter(title)
		title =~ /^((\d+\.)*) (.+)$/
		chapter = $1
		pure_title = $3
		if !chapter.nil? && !chapter.empty? && pure_title && !pure_title.empty?
			return [chapter, pure_title]
		else
			return nil
		end
	end
465744
function extractJavadoc(str) {
  var lines = str
    .replace(/^[ \t]+|[ \t]+$/g, '') // Trim whitespace.
    .split('\n').map(function (line, i) {
      return i ? line.replace(/^\s*\*\s?/, '') : line;
    });
  while (!lines[0]) {
    lines.shift();
  }
  while (!lines[lines.length - 1]) {
    lines.pop();
  }
  return lines.join('\n');
}
1312140
def _read_journal(self):
        """"""
        root = self._filesystem.inspect_get_roots()[0]
        inode = self._filesystem.stat('C:\\$Extend\\$UsnJrnl')['ino']

        with NamedTemporaryFile(buffering=0) as tempfile:
            self._filesystem.download_inode(root, inode, tempfile.name)

            journal = usn_journal(tempfile.name)

            return parse_journal(journal)
1259762
def from_string(string: str):
        

        spec = Spec()
        parse_context = {"current_subpackage": None}
        for line in string.splitlines():
            spec, parse_context = _parse(spec, parse_context, line)
        return spec
1224956
def parse(cls, on_str, force_type=None):  # @ReservedAssignment
        """"""

        on_str_orig = on_str

        if on_str is None:
            return None

        if not on_str:
            raise NotObjectNumberError("Got null input")

        if not isinstance(on_str, string_types):
            raise NotObjectNumberError("Must be a string. Got a {} ".format(type(on_str)))

        # if isinstance(on_str, unicode):
        #     dataset = on_str.encode('ascii')

        if force_type:
            type_ = force_type
        else:
            type_ = on_str[0]

        on_str = on_str[1:]

        if type_ not in list(cls.NDS_LENGTH.keys()):
            raise NotObjectNumberError("Unknown type character '{}' for '{}'".format(type_, on_str_orig))

        ds_length = len(on_str) - cls.NDS_LENGTH[type_]

        if ds_length not in cls.DATASET_LENGTHS:
            raise NotObjectNumberError(
                "Dataset string '{}' has an unfamiliar length: {}".format(on_str_orig, ds_length))

        ds_lengths = cls.DATASET_LENGTHS[ds_length]

        assignment_class = ds_lengths[2]

        try:
            dataset = int(ObjectNumber.base62_decode(on_str[0:ds_lengths[0]]))

            if ds_lengths[1]:
                i = len(on_str) - ds_lengths[1]
                revision = int(ObjectNumber.base62_decode(on_str[i:]))
                on_str = on_str[0:i]  # remove the revision
            else:
                revision = None

            on_str = on_str[ds_lengths[0]:]

            if type_ == cls.TYPE.DATASET:
                return DatasetNumber(dataset, revision=revision, assignment_class=assignment_class)

            elif type_ == cls.TYPE.TABLE:
                table = int(ObjectNumber.base62_decode(on_str))
                return TableNumber(
                    DatasetNumber(dataset, assignment_class=assignment_class), table, revision=revision)

            elif type_ == cls.TYPE.PARTITION:
                partition = int(ObjectNumber.base62_decode(on_str))
                return PartitionNumber(
                    DatasetNumber(dataset, assignment_class=assignment_class), partition, revision=revision)

            elif type_ == cls.TYPE.COLUMN:
                table = int(ObjectNumber.base62_decode(on_str[0:cls.DLEN.TABLE]))
                column = int(ObjectNumber.base62_decode(on_str[cls.DLEN.TABLE:]))

                return ColumnNumber(
                    TableNumber(DatasetNumber(dataset, assignment_class=assignment_class), table),
                    column, revision=revision)

            elif type_ == cls.TYPE.OTHER1 or type_ == cls.TYPE.CONFIG:
                    return GeneralNumber1(on_str_orig[0],
                                          DatasetNumber(dataset, assignment_class=assignment_class),
                                          int(ObjectNumber.base62_decode(on_str[0:cls.DLEN.OTHER1])),
                                          revision=revision)

            elif type_ == cls.TYPE.OTHER2:
                    return GeneralNumber2(on_str_orig[0],
                                          DatasetNumber(dataset, assignment_class=assignment_class),
                                          int(ObjectNumber.base62_decode(on_str[0:cls.DLEN.OTHER1])),
                                          int(ObjectNumber.base62_decode(
                                              on_str[cls.DLEN.OTHER1:cls.DLEN.OTHER1+cls.DLEN.OTHER2])),
                                          revision=revision)

            else:

                raise NotObjectNumberError('Unknown type character: ' + type_ + ' in ' + str(on_str_orig))

        except Base62DecodeError as e:
            raise NotObjectNumberError('Unknown character:  ' + str(e))
926646
def get_bibtex_string(self):
        

        bibtex_keys = {'author': ('_publ_author_name', '_citation_author_name'),
                       'title': ('_publ_section_title', '_citation_title'),
                       'journal': ('_journal_name_full', '_journal_name_abbrev',
                                   '_citation_journal_full', '_citation_journal_abbrev'),
                       'volume': ('_journal_volume', '_citation_journal_volume'),
                       'year': ('_journal_year', '_citation_year'),
                       'number': ('_journal_number', '_citation_number'),
                       'page_first': ('_journal_page_first', '_citation_page_first'),
                       'page_last': ('_journal_page_last', '_citation_page_last'),
                       'doi': ('_journal_DOI', '_citation_DOI')}

        entries = {}

        # TODO: parse '_publ_section_references' when it exists?
        # TODO: CIF specification supports multiple citations.

        for idx, data in enumerate(self._cif.data.values()):

            # convert to lower-case keys, some cif files inconsistent
            data = {k.lower(): v for k, v in data.data.items()}

            bibtex_entry = {}

            for field, tags in bibtex_keys.items():
                for tag in tags:
                    if tag in data:
                        if isinstance(data[tag], list):
                            bibtex_entry[field] = data[tag][0]
                        else:
                            bibtex_entry[field] = data[tag]

            # convert to bibtex author format ('and' delimited)
            if 'author' in bibtex_entry:
                # separate out semicolon authors
                if isinstance(bibtex_entry["author"], str):
                    if ";" in bibtex_entry["author"]:
                        bibtex_entry["author"] = bibtex_entry["author"].split(";")

                if isinstance(bibtex_entry['author'], list):
                    bibtex_entry['author'] = ' and '.join(bibtex_entry['author'])

            # convert to bibtex page range format, use empty string if not specified
            if ('page_first' in bibtex_entry) or ('page_last' in bibtex_entry):
                bibtex_entry['pages'] = '{0}--{1}'.format(bibtex_entry.get('page_first', ''),
                                                          bibtex_entry.get('page_last', ''))
                bibtex_entry.pop('page_first', None)  # and remove page_first, page_list if present
                bibtex_entry.pop('page_last', None)


            # cite keys are given as cif-reference-idx in order they are found
            entries['cif-reference-{}'.format(idx)] = Entry('article', list(bibtex_entry.items()))

        return BibliographyData(entries).to_string(bib_format='bibtex')
1087001
def parse_string(str_, validate=False):
    
    result = pattern.parseString(str_)[0]
    if validate:
        result.validate()
    return result
597246
def parse_references(cls, filename):
        
        references = set()
        for line in open(filename):
            matched = cls.RE_REF.match(line)
            if matched:
                reference = matched.group('path')
                reference_base = os.path.splitext(reference)[0]
                references.add(reference_base)
        return references
1119029
def extract(self, item):
        

        article_candidate = ArticleCandidate()
        article_candidate.extractor = self._name()
        article_candidate.title = self._title(item)
        article_candidate.description = self._description(item)
        article_candidate.text = self._text(item)
        article_candidate.topimage = self._topimage(item)
        article_candidate.author = self._author(item)
        article_candidate.publish_date = self._publish_date(item)
        article_candidate.language = self._language(item)

        return article_candidate
567957
public String extractString(Object val) {
    try {
      return (String) val;
    } catch (ClassCastException cce) {
      logException(cce);
      return null;
    }
  }
721825
def from_string(cls, s):
        

        log.debug("Parsing email from string")
        message = email.message_from_string(s)
        return cls(message)