Example #1
0
import wok_soap
import xml.etree.ElementTree as ET
import csv


csv_file = "DOE grant short list.csv"

# print len(ns)
#
# SID = wok_soap.auth()
# print SID

SID = "2WK3NwAyUj4xxl6RWiM"
UID = "WOS:000283490400005"

submit_search.search_for_citing_articles(UID, SID)


# data = []
# data.append({"__paper list": []})
# data.append({"__paper list": [1,2,3,4]})
# print data
# print data[1]["__paper list"][0]
#
# for grant in data:
#     example_paper = grant["__paper list"]
#     print example_paper
#     if example_paper:
#         break
#
# print "example_paper is " + str(example_paper)
Example #2
0
def citation_analysis(paper, SID, counter):
    UID = paper["UID"]

    cited_refs_output = submit_search.search_for_cited_refs(UID, SID)
    counter += cited_refs_output[1]
    if counter >= 2499:
        SID = wok_soap.auth()
        counter = 0

    paper["__cited references"] = process_cited_refs(cited_refs_output)

    if paper["__cited references"]:
        year_list = [int(ref["Year"]) for ref in paper["__cited references"] if ref["Year"] != ""]
        average_year = sum(year_list) / float(len(year_list))
        paper["Average Age of Reference"] = int(paper["Publication Year"]) - average_year

        journal_list = [ref["Cited Work"] for ref in paper["__cited references"]]
        same_journal_list = [y for y in journal_list if y == paper["Journal Title"]]
        paper["Diversity Index"] = 1 - (len(same_journal_list) / float(len(journal_list)))

    citing_articles_output = submit_search.search_for_citing_articles(UID, SID)
    counter += citing_articles_output[1]
    # if counter >= 2499:
    #     SID = wok_soap.auth()
    #     counter = 0

    paper["__citing articles"] = process_citing_articles(citing_articles_output)

    paper["Times Cited through 12-31-2015"] = len(paper["__citing articles"])

    for year in range(-1, 4):
        key = "Citations in Year " + str(year)

        paper[key] = 0
        citations = [article["Publication Year"] for article in paper["__citing articles"]
                     if int(article["Publication Year"]) - int(paper["Publication Year"]) == year]

        if citations:
            paper["Citations in Year " + str(year)] = len(citations)

    for year in range(4):
        date_format = "%Y-%m-%d"
        key = "Citations in month %s to %s" % (str((year-1)*12), str(year*12))

        paper[key] = 0
        citations_2 = []

        for article in paper["__citing articles"]:
            delta = d.strptime(article["Publication Date"], date_format) - d.strptime(paper["Publication Date"], date_format)
            article["Cite Time"] = delta.days / float(365)
            if year-1 < article["Cite Time"] <= year:
                citations_2.append(article["Publication Date"])

        if citations_2:
            paper[key] = len(citations_2)

    for year in range(2009, 2016):
        key = "Citations in %s" % (str(year))

        paper[key] = 0
        citations_3 = []

        for article in paper["__citing articles"]:
            if int(article["Publication Year"]) == year:
                citations_3.append(article["Publication Year"])

        if citations_3:
            paper[key] = len(citations_3)

    return paper
def citation_analysis(paper, SID, counter):  # should also refine search period
    UID = paper["UID"]

    print("UID = " + str(UID))

    # search for references cited in the paper
    cited_refs_output = submit_search.search_for_cited_refs(UID, SID, counter)
    #print(cited_refs_output[1])
    #print("counter = " + str(counter))
    counter = cited_refs_output[1]

    paper["__cited references"] = process_cited_refs(
        cited_refs_output)  # add key, value pair to paper dict

    if paper["__cited references"]:  #!!!
        year_list = [
            int(ref["Year"]) for ref in paper["__cited references"]
            if ref["Year"] != ""
        ]
        average_year = sum(year_list) / float(len(year_list))
        paper["Average Age of Reference"] = int(
            paper["Publication Year"]) - average_year

        journal_list = [
            ref["Cited Work"] for ref in paper["__cited references"]
        ]
        same_journal_list = [
            y for y in journal_list if y == paper["Journal Title"]
        ]
        paper["Diversity Index"] = 1 - (len(same_journal_list) /
                                        float(len(journal_list)))

    # search for articles that cite the paper
    citing_articles_output = submit_search.search_for_citing_articles(
        UID, SID, counter)
    counter = citing_articles_output[1]

    paper["__citing articles"] = process_citing_articles(
        citing_articles_output)

    paper["Times Cited through " + str(wok_soap.endDate)] = len(
        paper["__citing articles"]
    )  # gets # of papers in __citing articles key
    '''
    # count citations in calendar years relative to the year of publication, up to year 13 inclusive
    for year in range(-1, 14):
        key = "Citations in Year " + str(year)

        paper[key] = 0

        citations = [] # list of articles

        citations = [entry["Publication Year"] for entry in paper["__citing articles"]
                     if int(entry["Publication Year"]) - int(paper["Publication Year"]) == year]

        if citations:
            paper[key] = len(citations)

    # count citations in 12 month periods
    # not as useful
    for year in range(4):
        date_format = "%Y-%m-%d"
        key = "Citations in month %s to %s" % (str((year-1)*12), str(year*12))

        paper[key] = 0
        citations_2 = []

        for article in paper["__citing articles"]: # strptime() converts to date_format
            delta = d.strptime(article["Publication Date"], date_format) - d.strptime(paper["Publication Date"], date_format)
            article["Cite Time"] = delta.days / float(365)
            if year-1 < article["Cite Time"] <= year:
                citations_2.append(article["Publication Date"])

        if citations_2:
            paper[key] = len(citations_2)
    '''

    # count citations in calendar years 2003-2017 inclusive
    for year in range(2003, 2018):
        key = "Citations in %s" % (str(year))

        paper[key] = 0
        citations_3 = []

        for article in paper["__citing articles"]:
            if int(article["Publication Year"]) == year:
                citations_3.append(article["Publication Year"])

        if citations_3:
            paper[key] = len(citations_3)

    return paper
Example #4
0
def citation_analysis(paper, SID, counter):
    UID = paper["UID"]

    # search for references cited in the paper
    cited_refs_output = submit_search.search_for_cited_refs(UID, SID)
    counter += cited_refs_output[1]
    if counter >= 2499:
        SID = wok_soap.auth()
        counter = 0

    paper["__cited references"] = process_cited_refs(cited_refs_output)

    if paper["__cited references"]:
        year_list = [int(ref["Year"]) for ref in paper["__cited references"] if ref["Year"] != ""]
        average_year = sum(year_list) / float(len(year_list))
        paper["Average Age of Reference"] = int(paper["Publication Year"]) - average_year

        journal_list = [ref["Cited Work"] for ref in paper["__cited references"]]
        same_journal_list = [y for y in journal_list if y == paper["Journal Title"]]
        paper["Diversity Index"] = 1 - (len(same_journal_list) / float(len(journal_list)))

    # search for articles that cite the paper
    citing_articles_output = submit_search.search_for_citing_articles(UID, SID)
    counter += citing_articles_output[1]

    paper["__citing articles"] = process_citing_articles(citing_articles_output)

    paper["Times Cited through Search Period"] = len(paper["__citing articles"])

    # count citations in calendar years relative to the year of publication, up to year 13 inclusive
    for year in range(-1, 14):
        key = "Citations in Year " + str(year)

        paper[key] = 0
        citations = []

        citations = [article["Publication Year"] for article in paper["__citing articles"]
                     if int(article["Publication Year"]) - int(paper["Publication Year"]) == year]

        if citations:
            paper[key] = len(citations)

    # count citations in 12 month periods
    for year in range(4):
        date_format = "%Y-%m-%d"
        key = "Citations in month %s to %s" % (str((year-1)*12), str(year*12))

        paper[key] = 0
        citations_2 = []

        for article in paper["__citing articles"]:
            delta = d.strptime(article["Publication Date"], date_format) - d.strptime(paper["Publication Date"], date_format)
            article["Cite Time"] = delta.days / float(365)
            if year-1 < article["Cite Time"] <= year:
                citations_2.append(article["Publication Date"])

        if citations_2:
            paper[key] = len(citations_2)

    # count citations in calendar years 2003-2017 inclusive
    for year in range(2003, 2018):
        key = "Citations in %s" % (str(year))

        paper[key] = 0
        citations_3 = []

        for article in paper["__citing articles"]:
            if int(article["Publication Year"]) == year:
                citations_3.append(article["Publication Year"])

        if citations_3:
            paper[key] = len(citations_3)

    return paper