Package: delab-trees
Delab TreesA library to analyze conversation trees.Installationpip install delab_treesGet startedExample data for Reddit and Twitter are available herehttps://github.com/juliandehne/delab-trees/raw/main/delab_trees/data/dataset_[reddit|twitter]_no_text.pkl.
The data is structure only. Ids, text, links, or other information that would break confidentiality of the academic
access have been omitted.The trees are loaded from tables like this:tree_idpost_idparent_idauthor_idtextcreated_at011nanjamesI am James2017-01-01 01:00:001121markI am Mark2017-01-01 02:00:002132stevenI am Steven2017-01-01 03:00:003141johnI am John2017-01-01 04:00:00421nanjamesI am James2017-01-01 01:00:005221markI am Mark2017-01-01 02:00:006232stevenI am Steven2017-01-01 03:00:007243johnI am John2017-01-01 04:00:00This dataset contains two conversational trees with four posts each.Currently, you need to import conversational tables as a pandas dataframe like this:importpandasaspdfromdelab_treesimportTreeManagerd={'tree_id':[1]*4,'post_id':[1,2,3,4],'parent_id':[None,1,2,1],'author_id':["james","mark","steven","john"],'text':["I am James","I am Mark"," I am Steven","I am John"],"created_at":[pd.Timestamp('2017-01-01T01'),pd.Timestamp('2017-01-01T02'),pd.Timestamp('2017-01-01T03'),pd.Timestamp('2017-01-01T04')]}df=pd.DataFrame(data=d)manager=TreeManager(df)# creates one treetest_tree=manager.random()Note that the tree structure is based on the parent_id matching another rows post_id.You can now analyze the reply trees basic metrics:fromdelab_trees.mainimportget_test_treefromdelab_trees.delab_treeimportDelabTreetest_tree:DelabTree=get_test_tree()asserttest_tree.total_number_of_posts()==4asserttest_tree.average_branching_factor()>0A summary of basic metrics can be attained by callingfromdelab_trees.mainimportget_test_treefromdelab_trees.delab_treeimportDelabTreetest_tree:DelabTree=get_test_tree()print(test_tree.get_author_metrics())# >>> removed [] and changed {} (merging subsequent posts of the same author)# >>>{'james': <delab_trees.delab_author_metric.AuthorMetric object at 0x7fa9c5496110>, 'steven': <delab_trees.delab_author_metric.AuthorMetric object at 0x7fa9c5497dc0>, 'john': <delab_trees.delab_author_metric.AuthorMetric object at 0x7fa9c5497a00>, 'mark': <delab_trees.delab_author_metric.AuthorMetric object at 0x7fa9c5497bb0>}More complex metrics that use the full dataset for training can be gotten by the manager:importpandasaspdfromdelab_treesimportTreeManagerd={'tree_id':[1]*4,'post_id':[1,2,3,4],'parent_id':[None,1,2,1],'author_id':["james","mark","steven","john"],'text':["I am James","I am Mark"," I am Steven","I am John"],"created_at":[pd.Timestamp('2017-01-01T01'),pd.Timestamp('2017-01-01T02'),pd.Timestamp('2017-01-01T03'),pd.Timestamp('2017-01-01T04')]}df=pd.DataFrame(data=d)manager=TreeManager(df)# creates one treerb_vision_dictionary:dict["tree_id",dict["author_id","vision_metric"]]=manager.get_rb_vision()The following two complex metrics are implemented:fromdelab_trees.mainimportget_test_managermanager=get_test_manager()rb_vision_dictionary=manager.get_rb_vision()# predict an author having seen a postpb_vision_dictionary=manager.get_pb_vision()# predict an author to write the next postHow to cite@article{dehne_dtrees_23,
    author    ={Dehne, Julian},
    title     ={Delab-Trees: measuring deliberation in online conversations},        
    url ={https://github.com/juliandehne/delab-trees}year      ={2023},}