<jupyter_start><jupyter_text>Mendeley SyncScript ini melakukan sinkronisasi data peneliti dari [Mendeley](http://www.mendeley.com) ke website lab berbasis [Yoopa](http://yoopa.readthedocs.io). Prasyarat1. Mendaftarkan App di [Mendeley Developer](http://dev.mendeley.com) dan mendapat API secret.   Untuk http://www.lskk.org, App ID-nya adalah 3301 (dapatkan App Secret dari admin yang berwenang).2. Menginstall [Mendeley Python SDK](https://github.com/Mendeley/mendeley-python-sdk), caranya:        pip install mendeley3. Dapatkan access token dan refresh access token dari https://mendeley-show-me-access-tokens.herokuapp.com/4. Set _environment variables_ `MENDELEY_CLIENT_ID`, `MENDELEY_CLIENT_SECRET`, `MENDELEY_REDIRECT_URI`, `MENDELEY_ACCESS_TOKEN`, dan `MENDELEY_REFRESH_TOKEN` sebelum menjalankan Jupyter/IPython.        set MENDELEY_CLIENT_ID=3301        set MENDELEY_CLIENT_SECRET=4n...        set MENDELEY_REDIRECT_URI=https://www.lskk.org/        set MENDELEY_ACCESS_TOKEN=MS...eXc        set MENDELEY_REFRESH_TOKEN=MS...TlE  Mendapatkan Access Token dan Refresh Token BaruBila belum memiliki access token, Anda harus mendapatkan token baru. Login dulu ke akun Mendeley Anda. Lalu jalankan script berikut:<jupyter_code>import os
from mendeley import Mendeley

# These values should match the ones supplied when registering your application.
mendeley = Mendeley(os.environ['MENDELEY_CLIENT_ID'],
                    client_secret=os.environ['MENDELEY_CLIENT_SECRET'],
                    redirect_uri=os.environ['MENDELEY_REDIRECT_URI'])

auth = mendeley.start_authorization_code_flow()

# The user needs to visit this URL, and log in to Mendeley.
login_url = auth.get_login_url()
print('Silakan buka browser: %s' % login_url)<jupyter_output>Silakan buka browser: https://api.mendeley.com/oauth/authorize?response_type=code&client_id=3301&redirect_uri=https%3A%2F%2Fwww.lskk.org%2F&scope=all&state=IRZIPVC7M0MGFXAMFPMXZBOSKH6ROK<jupyter_text>Buka alamat yang ditampilkan di atas, maka Anda akan di-redirect ke URL tertentu, masukkan URL tersebut di variabel `auth_response` berikut, lalu jalankan scriptnya untuk mendapatkan `session` bertipe [`MendeleySession`](https://mendeley-python.readthedocs.io/en/latest/usage.htmlmendeley.session.MendeleySession).<jupyter_code># After logging in, the user will be redirected to a URL, auth_response.
auth_response = 'https://www.lskk.org/?code=G-73jbo5ezhiJquSzP44M-5aoFU&state=HT6DVX7XOSS3O02CJ5MERWFUZX22CG'
session = auth.authenticate(auth_response)<jupyter_output><empty_output><jupyter_text>Anda dapat menampilkan isi `session.token`. Token tersebut dapat disimpan ke `MENDELEY_ACCESS_TOKEN` dan `MENDELEY_REFRESH_TOKEN`.<jupyter_code>import pprint
pprint.pprint(session.token)<jupyter_output><empty_output><jupyter_text>Membuat MendeleySession dari access token yang sudah adaBila `MENDELEY_ACCESS_TOKEN` dan `MENDELEY_REFRESH_TOKEN` sudah disimpan, maka kita dapat langsung menggunakannya:<jupyter_code>import os
from mendeley.session import MendeleySession
from mendeley.auth import MendeleyAuthorizationCodeTokenRefresher

token = {'access_token': os.environ['MENDELEY_ACCESS_TOKEN'],
 'expires_at': 1467734155.9604628,
 'expires_in': 3600,
 'refresh_token': os.environ['MENDELEY_REFRESH_TOKEN'],
 'scope': ['all'],
 'token_type': 'bearer'}
auth = mendeley.start_authorization_code_flow()
session = MendeleySession(mendeley, token, client=auth.client, refresher=MendeleyAuthorizationCodeTokenRefresher(auth))
session<jupyter_output><empty_output><jupyter_text>Mengakses Documents Dapatkan _documents_ dari user tersebut sebagai [`mendeley.pagination.Page`](https://mendeley-python.readthedocs.io/en/latest/usage.htmlmendeley.pagination.Page):<jupyter_code>docs = session.documents.list(view='all', page_size=20)
pprint.pprint(list(map(lambda d: (d.id, d.title, d.authored, d.json['authors']), docs.items)))<jupyter_output>[('702d88e7-321f-3da4-bd9d-2120d9c46044',
  'Implementation of graph database for OpenCog artificial general '
  'intelligence framework using Neo4j',
  True,
  [{'first_name': 'Hendy', 'last_name': 'Irawan'},
   {'first_name': '<NAME>', 'last_name': 'Prihatmanto'}]),
 ('3dc8b0c2-917c-3ca8-8eed-09a5072230e4',
  'Design and Implementation of Image Processing System for Lumen Social '
  'Robot-Humanoid as an Exhibition Guide for Electrical Engineering Days',
  False,
  [{'first_name': '<NAME>', 'last_name': 'Sya'},
   {'first_name': '<NAME>', 'last_name': 'Prihatmanto'}]),
 ('77bdcaa1-5b77-3438-97ce-4a7f637a16de',
  'Artificial Intelligence Platform and Graph-Based Semantic Reasoning with '
  'Natural Language User Interface for Lumen Robot Friend',
  True,
  [{'first_name': 'Hendy', 'last_name': 'Irawan'},
   {'first_name': '<NAME>', 'last_name': 'Prihatmanto'}]),
 ('400aba71-eddc-382e-9b17-3918657de4a6',
  'Design and Implementation of Audio Communication Sys[...]<jupyter_text>Setiap _document_ berupa [`UserDocument`](https://mendeley-python.readthedocs.io/en/latest/models.htmlmendeley.models.documents.UserDocument) yang dapat kita tampilkan:<jupyter_code>for doc in docs.items:
    pprint.pprint(doc.json)<jupyter_output>{'abstract': 'We create a graph backing store for OpenCog using Neo4j graph '
             'database. The GraphBackingStore API extends the current '
             'BackingStore C++ API. It can take special queries that map '
             'naturally into Cypher queries and simple manipulations of Neo4j '
             'graph traversals. The Neo4j node-relationship structures and '
             'custom indices are optimized for AtomSpace usage and '
             'performance, with considerations for integration with Linked '
             'Data. This makes it easier to integrate projects which use '
             'common Linked Data foundation, such as Lumen Robot Friend. Data '
             'access is using Protocol Buffers-based protocol over ZeroMQ '
             'messaging transport. The initial work for Neo4j Graph Backing '
             'Store for OpenCog was implemented during Google Summer of Code '
             '2015. All source code is open source and available at '
             '[...]
{'fraction_non_alphanumeric': 0.10358890701468189, 'fraction_numerical': 0.02463295269168026, 'mean_word_length': 5.205465587044534, 'pattern_counts': {'":': 0, '<': 26, '<?xml version=': 0, '>': 26, 'https://': 8, 'lorem ipsum': 0, 'www.': 5, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 1, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '319072', 'license': 'Apache-2.0', 'n_tokens_mistral': 2274, 'n_tokens_neox': 2103, 'n_words': 478, 'path': 'mendeley-sync.ipynb', 'repo_name': 'lskk/yoopa-sync', 'size': '6157'}