Beispiel #1
0
	def query_scholarly(self, author = None, keyword = None, pub = None):
		import scholarly;
		
		RESULTS = {}
		if author is not None and keyword is not None and pub is not None:
			RESULTS['author'] =	scholarly.search_author(author);
			RESULTS['keyword'] = scholarly.search_keyword(keyword);
			RESULTS['pub'] = scholarly.search_pubs_query(pub);
			return RESULTS;
		elif author is not None:
			return scholarly.search_author(author);
		elif keyword is not None:
			return scholarly.search_keyword(keyword);
		elif pub is not None:
			return scholarly.search_pubs_query(pub);
Beispiel #2
0
    def search(self, keyword):
        keyword.lower()
        query = scholarly.search_keyword(keyword)
        d = {}
        for i in range(20):
            try:
                result = next(query)
                author = result.name
                interests = result.interests
                for item in interests:
                    formItem = item.title()
                    if formItem.lower() == keyword.lower():
                        continue
                    elif formItem in d:
                        if author in formItem:
                            d[formItem][author] += 1
                        else:
                            d[formItem][author] = 1
                    else:
                        d[formItem] = {author: 1}
            except:
                print()

            fileName = 'SearchData/' + keyword + '.txt'
            with open(fileName, 'w') as outfile:
                json.dump(d, outfile)
Beispiel #3
0
def searchAndSave(keyword, depth=0):
    if depth <= 1:
        query = scholarly.search_keyword(keyword)
        d = {}
        for i in range(40):
            try:
                result = next(query)
            except:
                print("Excepting", keyword)
            author = result.name
            interests = result.interests
            for item in interests:
                formItem = item.title()
                if formItem == keyword or formItem == keyword.lower():
                    continue
                elif formItem in d:
                    if author in formItem:
                        d[formItem][author] += 1
                    else:
                        d[formItem][author] = 1
                else:
                    d[formItem] = {author: 1}

        fileName = keyword + '.txt'
        with open(fileName, 'w') as outfile:
            json.dump(d, outfile)
Beispiel #4
0
def recommendation(request):
    try:
        temp = request.GET['data']
        result = scholarly.search_keyword(temp)
        my_list = []
        for i in range(1,20):
            temp= next(result)
            for i in temp.interests:
                my_list.append(i.lower())
        counts = Counter(my_list)
        recommendation = []
        counter = 0
        a1_sorted_keys = sorted(counts, key=counts.get, reverse=True)
        for r in a1_sorted_keys:
            if(counter<6):
                print(r, counts[r])
                recommendation.append(r)
            else:
                break
            counter = counter+1
        x = {"data" : recommendation}
        return Response(x)


    except:
        print("Something went wrong")
Beispiel #5
0
 def test_empty_keyword(self):
     ''' As of 2020-04-30, there are  6 individuals that match the name
     'label' '''
     # TODO this seems like undesirable functionality for
     # scholarly.search_keyword() with empty string. Surely, no authors
     # should be returned. Consider modifying the method itself.
     authors = [a for a in scholarly.search_keyword('')]
     self.assertEqual(len(authors), 6)
Beispiel #6
0
def interests(request):
    try:
        temp = request.GET["data"]
        result = scholarly.search_keyword(temp)
        json_content = []
        for i in range(1,20):
            temp = next(result)
            x = {
            "id" : temp.id,
            "name" : temp.name,
            "affiliation" : temp.affiliation,
            "citedby" : temp.citedby,
            "email" : temp.email,
            "interests" : temp.interests,
            "url" : temp.url_picture
            }
            json_content.append(x)
    except:
        print("Something went wrong")
    return Response(json_content)
Beispiel #7
0
 def test_empty_keyword(self):
     ''' Returns 5 individuals with the name 'label' '''
     authors = [a for a in scholarly.search_keyword('')]
     self.assertEqual(len(authors), 4)
Beispiel #8
0
 def test_keyword(self):
     authors = [a.name for a in scholarly.search_keyword('3d_shape')]
     self.assertIsNot(len(authors), 0)
     self.assertIn(u'Steven A. Cholewiak', authors)
Beispiel #9
0
def scholarly_data(request):

    if request.method == 'POST':
        form2 = QueryForm(request.POST)

        if form2.is_valid():
            # query = input('Enter the query to be searched: ')
            query2 = form2.cleaned_data.get("enterUrl")
            #parameter_values_list = [1, 10, '9ipXPomYaSrHLAIuONZfzUGk3t57RcBD']
            #response = requests.get(edited_search_coreAPI(query, parameter_values_list))
            # response = requests.get(edited_search_coreAPI(form.enterUrl, parameter_values_list))
            #content = response.json()
            # print(content)
            #
            search_query = scholarly.search_keyword(query2)
            #print(next(search_query))
            #content = search_query.json()
            #lst = []


            for i in search_query:
                em_author = i.email
                auth_id = i.id
                auth_name = i.name
                print(i.name)



            cr = Crossref()

            x = cr.works(query = query2,filter = {'has_full_text': True})
            print(len(x['message']['items']))
            url_list = []
            crossref_list = []
            lists_urls = x['message']['items']
            # for i in x['message']['items']:
            #     crossref_list.append(paper_details(i['doi'], i['title']))
                #url_list.append(i['link'][0]['URL'])

            # for i in crossref_list:
            #     if()
            temp =[]
            for i in x['message']['items']:
                temp.append(i['title'])
            temp_urls = []

            for i in x['message']['items']:
                temp_urls.append(i['URL'])

            context = {
                'form2': form2,
                'search_query': search_query,
                #'content': content
            }




            #dois = ['10.1186/s13643-018-0740-7']
            # x = cr.works(filter={"doi": ['10.1186/s13643-018-0740-7']})
            # # ,'has_full_text': True
            # for y in x['message']['items']:
            #     auth_URL = y['URL']
            #     print(y['URL'])
            # search_query = scholarly.search_pubs_query('guidelines for snowballing')
            # print(next(search_query))

            messages.success(request, f'Your Url has been generated')
            #return render_to_response(request, {"day_list": ['sunday', 'monday', 'tuesday']})
            # return redirect(request,'users/query.html',{'content' : content})
            zip_lists = list(zip(temp,temp_urls))
            return render(request, 'users/database.html', {'content': zip_lists})
            #return render(request, 'users/query.html',{"content" : content})
            #return render(json.dumps(search_query,sort_keys=True, indent=4),'users/query.html', content_type="application/json")
            #query_serialized = serializers.serialize('json', search_query)
            #return JsonResponse(query_serialized, safe=False)
            #return (HttpResponse(json.dumps(search_query,sort_keys=True, indent=4), content_type="application/json"))
            #return render(request, 'users/scholar.html', {"data": data, "country_list": country_list})

        #return (HttpResponse((search_query), content_type="application/json"))

        else:
            #messages.error(request, f'Wrong Url')
            return render(request, 'users/database.html', {'form2': form2})

    else:
        form2 = QueryForm()
        return render(request, 'users/database.html', {'form2': form2})
Beispiel #10
0
#prints dates,titles,links of all articles searched.
for post in feed.entries:
    date = "(%d/%02d/%02d)" % (post.published_parsed.tm_year,\
        post.published_parsed.tm_mon, \
        post.published_parsed.tm_mday)
    print("post date: " + date)
    print("post title: " + post.title)
    print("post link: " + post.link)

#Search for an author by name and return a generator of Author objects.
search_query = scholarly.search_author('Marty Banks, Berkeley')
print(next(search_query))

#Search by keyword and return a generator of Author objects.
search_query = scholarly.search_keyword('Haptics')
print(next(search_query))

# Search for articles/publications and return generator of Publication objects.
search_query = scholarly.search_pubs_query(
    'Perception of physical stability and center of mass of 3D objects')
print(next(search_query))

# Retrieve the author's data, fill-in, and print
search_query = scholarly.search_author('Steven A Cholewiak')
author = next(search_query).fill()
print(author)

# Print the titles of the author's publications
print([pub.bib['title'] for pub in author.publications])
def query_for_authors(query_phrase):
    return scholarly.search_keyword(query_phrase)
Beispiel #12
0
 def test_empty_keyword(self):
     ''' Returns 5 individuals with the name 'label' '''
     authors = [a for a in scholarly.search_keyword('')]
     self.assertEqual(len(authors), 5)
Beispiel #13
0
######## Google Scholar

import scholarly

search_query_2 = scholarly.search_keyword('thermodynamics')
keyword = next(search_query_2).fill()
title2 = [pub.bib['title'] for pub in keyword.publications]

title3 = [pub for pub in keyword.publications]

################################################################################

import gscholar

gscholar.query("thermodynamics")
Beispiel #14
0
    '''
    Opens up a connection to a sqlite database, iterates through the scholarly generator and extracts the information
    for each author.
    '''

    conn = sqlite3.connect('./kolDB.db') # Connect to the database
#     c = conn.cursor()


    for i in gen:
        var_extract(i.fill())

    # conn.commit() # Commits the SQL queries specified by functions to the sqlite datebase.
    conn.close()

#################################################################
#################################################################

keysearch = input("Enter keyword for network map: ")

conn = sqlite3.connect('./kolDB.db') # Connect to the database

c = conn.cursor() # Create database cursor

# Creates a Scholarly generator object comprised of individual Author objects
cb_search = scholarly.search_keyword(keysearch) #("air_quality")

# Iterate through the generator and extract information from each author
generator_db(cb_search)
Beispiel #15
0
import scholarly
import unicodecsv as csv


search_query = scholarly.search_keyword('digital_humanities')

step = 0
with open('authors.csv', 'wb') as f:
    writer = csv.writer(f)
    writer.writerow(['Name', 'Interests'])
    if search_query != []:
        for i in search_query:
            writer.writerow([i.name, i.interests])
            step += 1
            print (step, i.name, '\n', i.interests)






Beispiel #16
0
import scholarly

author = 'Steven A. Cholewiak'
print("Search author: ", author)
result = next(scholarly.search_author(author)).fill()
print(result)
print()

# Print the titles of the author's publications
print([pub.bib['title'] for pub in result.publications])

# Take a closer look at the first publication
pub = result.publications[0].fill()
print(pub)

# Which papers cited that publication?
print([citation.bib['title'] for citation in pub.get_citedby()])

keyword = 'Haptics'
print("Search keyword: ", keyword)
print(next(scholarly.search_keyword(keyword)))
print()

search = 'Perception of physical stability and center of mass of 3D objects'
print("Search: ", search)
search_query = scholarly.search_pubs_query(search)
print(next(search_query))
print()
Beispiel #17
0
 def test_keyword(self):
     authors = [a.name for a in scholarly.search_keyword('3d_shape')]
     self.assertIsNot(len(authors), 0)
     self.assertIn(u'Steven A. Cholewiak', authors)
Beispiel #18
0
client = ElsClient("688f324bf0bbe4273de2fd6ef18593b3")
keywords = 'SFA + DEA'


def get_search(keywords, client):
    doc_srch = ElsSearch(keywords, 'scopus')
    doc_srch.execute(client, get_all=True)
    print("doc_srch has", len(doc_srch.results), "results.")
    df = doc_srch.results_df
    return (df)


df = get_search(keywords, client)

search_query = scholarly.search_keyword('SFA')


def get_citated_by_list(df):
    pub = []
    for i in range(len(df)):
        search_query = scholarly.search_author(df['dc:creator'][i])
        author = next(search_query).fill()
        pub.append(author.publications[author.publications == df['dc:title']
                                       [i]].fill())
    return (pub)


citations = get_citated_by_list(df)

search_query = scholarly.search_pubs_query(df['dc:title'][0])
Beispiel #19
0
import scholarly


def hello():
    search_query = scholarly.search_author('Steven A Cholewiak')
    author = next(search_query).fill()
    print(author)

    # Print the titles of the author's publications
    print([pub.bib['title'] for pub in author.publications])

    # Take a closer look at the first publication
    pub = author.publications[0].fill()
    print(pub)

    # Which papers cited that publication?
    print([citation.bib['title'] for citation in pub.get_citedby()])


search_query = scholarly.search_keyword('geology')
print(next(search_query))
Beispiel #20
0
 def test_empty_keyword(self):
     ''' Returns 6 individuals with 'label' in their name or affiliation '''
     authors = [a for a in scholarly.search_keyword('')]
     self.assertEqual(len(authors), 6)