Ejemplo n.º 1
0
def search_from_reference(text):
    """Convert a raw reference to a search query

    Called by the search engine to convert a raw reference:
    find rawref John, JINST 4 (1994) 45
    is converted to
    journal:"JINST,4,45"
    """
    field = ""
    pattern = ""

    kbs = get_kbs()
    references, dummy_m, dummy_c, dummy_co = parse_reference_line(text, kbs)

    for elements in references:
        for el in elements:
            if el["type"] == "JOURNAL":
                field = "journal"
                pattern = (
                    CFG_JOURNAL_PUBINFO_STANDARD_FORM.replace(CFG_JOURNAL_TAG.replace("%", "p"), el["title"])
                    .replace(CFG_JOURNAL_TAG.replace("%", "v"), el["volume"])
                    .replace(CFG_JOURNAL_TAG.replace("%", "c"), el["page"])
                    .replace(CFG_JOURNAL_TAG.replace("%", "y"), el["year"])
                )
                break
            elif el["type"] == "REPORTNUMBER":
                field = "report"
                pattern = el["report_num"]
                break

    return field, pattern.encode("utf-8")
Ejemplo n.º 2
0
def search_from_reference(text):
    """Convert a raw reference to a search query

    Called by the search engine to convert a raw reference:
    find rawref John, JINST 4 (1994) 45
    is converted to
    journal:"JINST,4,45"
    """
    field = ''
    pattern = ''

    kbs = get_kbs()
    references, dummy_m, dummy_c, dummy_co = parse_reference_line(text, kbs)

    for elements in references:
        for el in elements:
            if el['type'] == 'JOURNAL':
                field = 'journal'
                pattern = CFG_JOURNAL_PUBINFO_STANDARD_FORM \
                    .replace(CFG_JOURNAL_TAG.replace('%', 'p'), el['title']) \
                    .replace(CFG_JOURNAL_TAG.replace('%', 'v'), el['volume']) \
                    .replace(CFG_JOURNAL_TAG.replace('%', 'c'), el['page']) \
                    .replace(CFG_JOURNAL_TAG.replace('%', 'y'), el['year'])
                break
            elif el['type'] == 'REPORTNUMBER':
                field = 'report'
                pattern = el['report_num']
                break

    return field, pattern.encode('utf-8')
Ejemplo n.º 3
0
def search_from_reference(text):
    """Convert a raw reference to a search query

    Called by the search engine to convert a raw reference:
    find rawref John, JINST 4 (1994) 45
    is converted to
    journal:"JINST,4,45"
    """
    field = ''
    pattern = ''

    kbs = get_kbs()
    references, dummy_m, dummy_c, dummy_co = parse_reference_line(text, kbs)

    for elements in references:
        for el in elements:
            if el['type'] == 'JOURNAL':
                field = 'journal'
                pattern = CFG_JOURNAL_PUBINFO_STANDARD_FORM \
                    .replace('773__p', el['title']) \
                    .replace('773__v', el['volume']) \
                    .replace('773__c', el['page']) \
                    .replace('773__y', el['year'])
                break
            elif el['type'] == 'REPORTNUMBER':
                field = 'report'
                pattern = el['report_num']
                break

    return field, pattern.encode('utf-8')
Ejemplo n.º 4
0
def extract_journal_reference(line):
    """Extracts the journal reference from
    MARC field 773 and parses for specific
    journal information.

    Parameter: line - field 773__x, the raw journal ref
    Return: list of tuples with data values"""
    kbs = get_kbs()
    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
Ejemplo n.º 5
0
def extract_journal_reference(line):
    """Extracts the journal reference from
    MARC field 773 and parses for specific
    journal information.

    Parameter: line - field 773__x, the raw journal ref
    Return: list of tuples with data values"""
    tagged_line = tag_reference_line(line, get_kbs(), {})[0]
    if tagged_line is None:
        return None

    elements, dummy_marker, dummy_stats = parse_tagged_reference_line("", tagged_line, [], [])

    for element in elements:
        if element["type"] == "JOURNAL":
            return element
Ejemplo n.º 6
0
def extract_journal_reference(line):
    """Extracts the journal reference from
    MARC field 773 and parses for specific
    journal information.

    Parameter: line - field 773__x, the raw journal ref
    Return: list of tuples with data values"""
    tagged_line = tag_reference_line(line, get_kbs(), {})[0]
    if tagged_line is None:
        return None

    elements, dummy_marker, dummy_stats = parse_tagged_reference_line(
        '', tagged_line, [], [])

    for element in elements:
        if element['type'] == 'JOURNAL':
            return element