Identify Private Breakouts and One-on-ones¶
In [1]:
import pandas as pd
import numpy as np
import os, re
In [2]:
%matplotlib inline
%load_ext autoreload
%autoreload 2
In [3]:
pd.set_option('display.memory_usage', 'deep')
pd.set_option('display.precision', 2)
pd.set_option('display.width', 200)
pd.set_option('display.max_rows', 300)
pd.set_option('display.max_columns', None)
pd.set_option('display.max_colwidth', 80)
pd.options.display.float_format = '{:,.4f}'.format
In [4]:
from filepath_03 import * # change to reflect input and output file path
Load transcript component data cleaned from previous steps
In [5]:
complong = pd.read_pickle(filepath_complong)
varlist = ['transcriptid','section','seq','par_role','text','nwords']
complong = complong[varlist]
complong = complong.query('text.notnull()')
Identify private breakouts
In [6]:
def identify_breakout_gen(sent):
i_breakout = 0
txt_breakout = ""
reobj_breakout_spec = re.compile(r"\bbreak[\-]{0,1}out\s(?:.{1,15}room|session|meeting)",flags = re.I)
reobj_breakout_excl = re.compile(r"won[\'\’]t.{1,10}break[\-]{0,1}out|do\snot.{1,10}break[\-]{0,1}out|not.{1,5}break[\-]{0,1}out", flags = re.I)
if reobj_breakout_spec.search(sent) and not reobj_breakout_excl.search(sent):
i_breakout = 1
txt_breakout = sent
return i_breakout, txt_breakout
In [7]:
complong[['temp1A','txt1A']]= complong.apply(lambda x: identify_breakout_gen(x['text']), axis=1, result_type="expand")
In [8]:
def identify_breakout_start_end(sent):
i_breakout = 0
txt_breakout = ""
reobj_breakout_gen = re.compile(r"(?<!no\s)\bbreak[\-]{0,1}out\b",flags = re.I)
reobj_breakout_excl = re.compile(r"won[\'\’]t.{1,10}break[\-]{0,1}out|do\snot.{1,10}break[\-]{0,1}out|not.{1,5}break[\-]{0,1}out", flags = re.I)
if reobj_breakout_gen.search(sent) and not reobj_breakout_excl.search(sent):
i_breakout = 1
txt_breakout = sent
return i_breakout, txt_breakout
In [9]:
complong[['temp1B','txt1B']]= complong.apply(lambda x: identify_breakout_start_end(x['text']), axis=1, result_type="expand")
In [10]:
def identify_one_on_one(sent):
i_1on1 = 0
txt_1on1 = ""
reobj_one = re.compile(r"(?<!no\s)one[\-\s]{1}on[\-\s]{1}one|one-to-ones",flags = re.I)
reobj_one_excl = re.compile(r"one\-on\-one\scontract|one\-on\-one\sinteraction|one\-on\-one\scontract", flags = re.I)
if reobj_one.search(sent) and not reobj_one_excl.search(sent):
i_1on1 = 1
txt_1on1 = sent
return i_1on1, txt_1on1
In [11]:
complong[['temp2','txt2']]= complong.apply(lambda x: identify_one_on_one(x['text']), axis=1, result_type="expand")
Identify components at the start or end of a section
In [12]:
complong['start'] = (complong['seq']<=3)*1
complong['end'] = (complong['seq']+2>=complong.groupby(['transcriptid','section'])['seq'].transform('max'))*1
Define components with mentioning of breakout or one-on-one. Differentiate between components at the start, end, or in the middle of a section.
In [13]:
complong['i_breakout'] = np.where((complong['start']==1)| (complong['end']==1),
complong['temp1B'], complong['temp1A'])
complong['txt_breakout'] = np.where((complong['start']==1)| (complong['end']==1),
complong['txt1B'], complong['txt1A'])
complong = complong.rename(columns={'temp2':'i_1on1', 'txt2':'txt_1on1'})
complong = complong.drop(columns=['temp1A','txt1A', 'temp1B', 'txt1B'])
aggregate to transcript level
In [14]:
trans = complong.groupby(['transcriptid'])[['i_1on1','i_breakout']].agg('max').reset_index()
In [15]:
trans.to_pickle(outputpath_priv)
In [ ]:
In [ ]: