! pip install -U tree-sitter==0.0.5
import function_parser

import pandas as pd

from function_parser.language_data import LANGUAGE_METADATA
from function_parser.process import DataProcessor
from tree_sitter import Language
language = 'python'
DataProcessor.PARSER.set_language(Language(function_parser.__path__[0] + '/tree-sitter-languages.so', language))

processor = DataProcessor(language=language,
                          language_parser=LANGUAGE_METADATA[language]['language_parser'])
dependee = 'keras-team/keras'
definitions = processor.process_dee(dependee, ext=LANGUAGE_METADATA[language]['ext'])
pd.DataFrame(definitions).head()
nwo sha path language identifier parameters argument_list return_statement docstring docstring_summary docstring_tokens function function_tokens url
0 keras-team/keras e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b keras/backend.py python backend () return 'tensorflow' Publicly accessible method for determining the... Publicly accessible method for determining the... [Publicly, accessible, method, for, determinin... def backend():\n """Publicly accessible metho... [def, backend, (, ), :, return, 'tensorflow'] https://github.com/keras-team/keras/blob/e43af...
1 keras-team/keras e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b keras/backend.py python cast_to_floatx (x) return np.asarray(x, dtype=floatx()) Cast a Numpy array to the default Keras float ... Cast a Numpy array to the default Keras float ... [Cast, a, Numpy, array, to, the, default, Kera... def cast_to_floatx(x):\n """Cast a Numpy arra... [def, cast_to_floatx, (, x, ), :, if, isinstan... https://github.com/keras-team/keras/blob/e43af...
2 keras-team/keras e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b keras/backend.py python get_uid (prefix='') return layer_name_uids[prefix] Associates a string prefix with an integer cou... Associates a string prefix with an integer cou... [Associates, a, string, prefix, with, an, inte... def get_uid(prefix=''):\n """Associates a str... [def, get_uid, (, prefix, =, '', ), :, graph, ... https://github.com/keras-team/keras/blob/e43af...
3 keras-team/keras e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b keras/backend.py python reset_uids () Resets graph identifiers. Resets graph identifiers. [Resets, graph, identifiers, .] def reset_uids():\n """Resets graph identifie... [def, reset_uids, (, ), :, PER_GRAPH_OBJECT_NA... https://github.com/keras-team/keras/blob/e43af...
4 keras-team/keras e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b keras/backend.py python clear_session () Resets all state generated by Keras.\n\n Kera... Resets all state generated by Keras. [Resets, all, state, generated, by, Keras, .] def clear_session():\n """Resets all state ge... [def, clear_session, (, ), :, global, _SESSION... https://github.com/keras-team/keras/blob/e43af...
library_candidates = {}
library_candidates[dependee.split('/')[-1]] = definitions
dependent = dependee#'eriklindernoren/Keras-GAN'
calls, edges = processor.process_dent(dependent, ext=LANGUAGE_METADATA[language]['ext'], library_candidates=library_candidates)
edges[-5:]
[('https://github.com/keras-team/keras/blob/e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b/keras/wrappers/scikit_learn.py#L102-L102',
  'https://github.com/keras-team/keras/blob/e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b/keras/utils/generic_utils.py#L474-L489'),
 ('https://github.com/keras-team/keras/blob/e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b/keras/wrappers/scikit_learn.py#L159-L159',
  'https://github.com/keras-team/keras/blob/e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b/keras/losses.py#L1821-L1828'),
 ('https://github.com/keras-team/keras/blob/e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b/keras/wrappers/scikit_learn.py#L161-L161',
  'https://github.com/keras-team/keras/blob/e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b/keras/utils/np_utils.py#L25-L81'),
 ('https://github.com/keras-team/keras/blob/e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b/keras/wrappers/scikit_learn.py#L184-L184',
  'https://github.com/keras-team/keras/blob/e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b/keras/utils/generic_utils.py#L474-L489'),
 ('https://github.com/keras-team/keras/blob/e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b/keras/wrappers/scikit_learn.py#L300-L300',
  'https://github.com/keras-team/keras/blob/e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b/keras/utils/np_utils.py#L25-L81')]
pd.DataFrame(calls).head()
nwo sha path language identifier argument_list url
0 keras-team/keras e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b keras/backend.py python _DummyEagerGraph () https://github.com/keras-team/keras/blob/e43af...
1 keras-team/keras e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b keras/backend.py python get_graph () https://github.com/keras-team/keras/blob/e43af...
2 keras-team/keras e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b keras/backend.py python reset_uids () https://github.com/keras-team/keras/blob/e43af...
3 keras-team/keras e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b keras/backend.py python get_graph () https://github.com/keras-team/keras/blob/e43af...
4 keras-team/keras e43af6c89cd6c4adecc21ad5fc05b21e7fa9477b keras/backend.py python symbolic_learning_phase () https://github.com/keras-team/keras/blob/e43af...
edges