Skip to content
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
22 changes: 16 additions & 6 deletions attribute_categories.py
Original file line number Diff line number Diff line change
Expand Up @@ -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']
}
}
}

relationship_labels = {
'FN' : 'Nuclear Family Members',
'FO' : 'Other Family Member',
'FS' : 'Family Servant',
'TC' : 'Close Friend',
'T' : 'Other Acquaintance'
}


5 changes: 3 additions & 2 deletions data_parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
return names
39 changes: 37 additions & 2 deletions layout_cust.py
Original file line number Diff line number Diff line change
Expand Up @@ -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="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_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_relationship_groups')])])
])

])
Expand Down Expand Up @@ -123,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