From 9908e670bc1131a0d10b7454ac1727c88ff0f3e6 Mon Sep 17 00:00:00 2001 From: arthurhughes <71314304+arthurhughes@users.noreply.github.com> Date: Thu, 22 Apr 2021 14:05:51 +0300 Subject: [PATCH 1/6] Update layout_cust.py --- layout_cust.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/layout_cust.py b/layout_cust.py index ba5ec7d..b56dfba 100644 --- a/layout_cust.py +++ b/layout_cust.py @@ -85,12 +85,20 @@ html.P('The custom POS groups you have saved for this session', style={'fontWeight':'bold'}), html.Div(id='cust_pos_groups')])]), dcc.Tab( - label='Other', + label='Relationships', children=[ html.Div( style={'padding': '20px'}, children=[ - html.H5('You can later add other groups as well.')])]) + html.H5('Add a new custom relationship grouping'), + dcc.Input(id="rel_group_name", type="text", placeholder="Name for new group"), + dcc.Input(id="rel_group_tags", type="text", placeholder="Tags for new group as ; separated list", style={'width': '100%'}), + html.Br(), + html.Button('Add group', id='add_rel_group_button', n_clicks = 0), + html.Br(), + html.Br(), + html.P('The custom relationship groups you have saved for this session', style={'fontWeight':'bold'}), + html.Div(id='cust_rel_groups')])]) ]) ]) From 462b900b79fe1a30d977bdc42daeb2281b86837a Mon Sep 17 00:00:00 2001 From: arthurhughes <71314304+arthurhughes@users.noreply.github.com> Date: Thu, 22 Apr 2021 14:22:50 +0300 Subject: [PATCH 2/6] Update layout_cust.py --- layout_cust.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/layout_cust.py b/layout_cust.py index b56dfba..4cf7830 100644 --- a/layout_cust.py +++ b/layout_cust.py @@ -91,14 +91,14 @@ style={'padding': '20px'}, children=[ html.H5('Add a new custom relationship grouping'), - dcc.Input(id="rel_group_name", type="text", placeholder="Name for new group"), - dcc.Input(id="rel_group_tags", type="text", placeholder="Tags for new group as ; separated list", style={'width': '100%'}), + dcc.Input(id="relationship_group_name", type="text", placeholder="Name for new group"), + dcc.Input(id="relationship_group_tags", type="text", placeholder="Tags for new group as ; separated list", style={'width': '100%'}), html.Br(), - html.Button('Add group', id='add_rel_group_button', n_clicks = 0), + html.Button('Add group', id='add_relationship_group_button', n_clicks = 0), html.Br(), html.Br(), html.P('The custom relationship groups you have saved for this session', style={'fontWeight':'bold'}), - html.Div(id='cust_rel_groups')])]) + html.Div(id='cust_relationship_groups')])]) ]) ]) From cdc00670272d17e3d20782d5fa1cf70361b41dae Mon Sep 17 00:00:00 2001 From: arthurhughes <71314304+arthurhughes@users.noreply.github.com> Date: Thu, 22 Apr 2021 14:23:31 +0300 Subject: [PATCH 3/6] Update attribute_categories.py --- attribute_categories.py | 22 ++++++++++++++++------ 1 file changed, 16 insertions(+), 6 deletions(-) diff --git a/attribute_categories.py b/attribute_categories.py index 1ca0c10..827d014 100644 --- a/attribute_categories.py +++ b/attribute_categories.py @@ -32,15 +32,25 @@ relationship_categories = { 'Fine-grained': { - 'Nuclear family': ['FN'], - 'Other family': ['FO'], - 'Family servant': ['FS'], - 'Close friend': ['TC'], - 'Other acquaintance': ['T'] + 'Nuclear Family Member': ['FN'], + 'Other Family Member': ['FO'], + 'Family Servant': ['FS'], + 'Close Friend': ['TC'], + 'Other Acquaintance': ['T'] }, 'Grouped': { 'Family': ['FN', 'FO', 'FS'], 'Friends': ['TC'], 'Other relationships': ['T'] } -} \ No newline at end of file +} + +relationship_labels = { + 'FN' : 'Nuclear Family Members' + 'FO' : 'Other Family Member' + 'FS' : 'Family Servant' + 'TC' : 'Close Friend' + 'T' : 'Other Acquaintance' +} + + From 1cc3674f4eacd6d323fa8bea07c1859a65c2267c Mon Sep 17 00:00:00 2001 From: arthurhughes <71314304+arthurhughes@users.noreply.github.com> Date: Thu, 22 Apr 2021 14:32:34 +0300 Subject: [PATCH 4/6] Update layout_cust.py --- layout_cust.py | 27 +++++++++++++++++++++++++++ 1 file changed, 27 insertions(+) diff --git a/layout_cust.py b/layout_cust.py index 4cf7830..f7f0c60 100644 --- a/layout_cust.py +++ b/layout_cust.py @@ -131,3 +131,30 @@ def view_pos_groups(data): children.append(html.P('{}: {}'.format(n, ', '.join(list(t))))) return children + +@app.callback( + Output('session', 'data'), + Input('add_relationship_group_button', 'n_clicks'), + [State('relationship_group_name', 'value')], + [State('relationship_group_tags', 'value')], + State('session', 'data')) +def add_relationship_group(n_clicks, name, tags, data): + + if n_clicks > 0: + if data is None: + data = dict() + tags = tags.split(';') + data[name] = tags + + return data + +@app.callback( + Output('cust_relationship_groups', 'children'), + Input('session', 'data')) +def view_relationship_groups(data): + if data is not None: + children = [] + for (n, t) in data.items(): + children.append(html.P('{}: {}'.format(n, ', '.join(list(t))))) + + return children From 0e7e64194951080b151066db80881708b1264fa0 Mon Sep 17 00:00:00 2001 From: arthurhughes <71314304+arthurhughes@users.noreply.github.com> Date: Sun, 25 Apr 2021 14:42:55 +0300 Subject: [PATCH 5/6] Update attribute_categories.py --- attribute_categories.py | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) diff --git a/attribute_categories.py b/attribute_categories.py index 827d014..45456b2 100644 --- a/attribute_categories.py +++ b/attribute_categories.py @@ -46,10 +46,10 @@ } relationship_labels = { - 'FN' : 'Nuclear Family Members' - 'FO' : 'Other Family Member' - 'FS' : 'Family Servant' - 'TC' : 'Close Friend' + 'FN' : 'Nuclear Family Members', + 'FO' : 'Other Family Member', + 'FS' : 'Family Servant', + 'TC' : 'Close Friend', 'T' : 'Other Acquaintance' } From 880db6989ac438e5e344cc5175b376e289c142c7 Mon Sep 17 00:00:00 2001 From: arthurhughes <71314304+arthurhughes@users.noreply.github.com> Date: Sun, 25 Apr 2021 14:57:22 +0300 Subject: [PATCH 6/6] Update data_parser.py --- data_parser.py | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/data_parser.py b/data_parser.py index 941710d..f5d36a9 100644 --- a/data_parser.py +++ b/data_parser.py @@ -4,7 +4,7 @@ import plotly.express as px import string from pos_categories import pos_categories, pos_labels, pos_dittos -from attribute_categories import rank_categories, relationship_categories +from attribute_categories import rank_categories, relationship_categories, relationship_labels class DataParser(): df = None @@ -30,6 +30,7 @@ def __init__(self): self.pos_labels = pos_labels self.pos_dittos = pos_dittos self.relationship_categories = relationship_categories + self.relationship_labels = relationship_labels return # Transforms xml-file into a BeautifulSoup-object @@ -196,4 +197,4 @@ def get_name(self, ids): tmp = person[['FirstName','LastName']] names = senders.join(tmp, on='Sender').reset_index(drop=True) - return names \ No newline at end of file + return names