<jupyter_start><jupyter_text>Headers and Functions<jupyter_code>#Import libraries
from matplotlib_venn import venn2, venn2_circles, venn2_unweighted
from matplotlib import pyplot as plt
%matplotlib inline
#default settings for S,P,and M
S_init={'s','sp'};
P_init={'p','sp'};

#Some S is P: nothing to do
def someSisP(s_in,p_in):
    s_out=s_in;
    s_out.add('sp+');
    return [s_out,p_in]

#Some S is not P: nothing to do 
def someSisNotP(s_in,p_in):
    s_in.add('s+');
    return [s_in,p_in]

#All S is P: overwrite the original s_in with just the intersection of s_in and p_in
def allSisP(s_in,p_in):
    s_out=s_in.intersection(p_in);
    return [s_out,p_in]

#No S is P: remove the intersection of s_in and p_in from s_in
def noSisP(s_in,p_in):
    sp_intersection=s_in.intersection(p_in);
    s_in.difference_update(sp_intersection);
    return [s_in,p_in]

#initAandB: initialize subject and predicate sets 
#example: [S,P]=initSandP();
def initSandP():
    s_in=S_init.copy();
    p_in=P_init.copy(); 
    return [s_in,p_in];

#venn2_pretty: 
def venn2_pretty(S,S_label,P,P_label,Title):
  s_flag=0;
  sp_flag=0;
  if 's+' in S:
    s_flag=1;
    S.discard('s+');
  if 'sp+' in S:
    sp_flag=1;
    S.discard('sp+');
  v=venn2_unweighted([S,P],set_labels=(S_label,P_label));
  for t in v.set_labels: t.set_fontsize(25);
  venn2_circles((1,1,1),linewidth=4);
  #color all areas navy and remove the displayed count
  v.get_patch_by_id('01').set_color('w');
  v.get_label_by_id('01').set_text('');
  v.get_patch_by_id('11').set_color('w');
  v.get_label_by_id('11').set_text('');
  v.get_patch_by_id('10').set_color('w');
  v.get_label_by_id('10').set_text('');

  if 's' not in S:
    v.get_patch_by_id('10').set_color('b');
    v.get_patch_by_id('10').set_alpha(1.0);
  if 'sp' not in S:
    v.get_patch_by_id('11').set_color('b');
    v.get_patch_by_id('11').set_alpha(1.0);
  if 'p' not in P:
    v.get_patch_by_id('01').set_color('b');
    v.get_patch_by_id('01').set_alpha(1.0);
  if 'sp' not in P:
    v.get_patch_by_id('11').set_color('b');
    v.get_patch_by_id('11').set_alpha(1.0);
  if s_flag==1:
    v.get_patch_by_id('10').set_color('r');
    v.get_patch_by_id('10').set_alpha(1.0);
    v.get_label_by_id('10').set_text('X');
    v.get_label_by_id('10').set_fontsize(24);
  if sp_flag==1:
    v.get_patch_by_id('11').set_color('r');
    v.get_patch_by_id('11').set_alpha(1.0);
    v.get_label_by_id('11').set_text('X');
    v.get_label_by_id('11').set_fontsize(24);

  plt.title(Title,fontdict={'fontsize': 25});
  return v;<jupyter_output><empty_output><jupyter_text>Examples  All men are mortal Example<jupyter_code>#initialize the subject and predicate sets
[subject,predicate]=initSandP();

#apply All men (S) are mortal (P)
[subject,predicate]=allSisP(subject,predicate);

#Venn diagram of all S is P
venn2_pretty(subject,'Men', predicate, 'Mortal','All Men are Mortal');<jupyter_output><empty_output><jupyter_text>No men are mortal Example<jupyter_code>#initialize the subject and predicate sets
[subject,predicate]=initSandP();

#apply No men (S) are mortal (P)
[subject,predicate]=noSisP(subject,predicate);

#Venn diagram of no S is P
venn2_pretty(subject,'Men', predicate, 'Mortal','No Men are Mortal');<jupyter_output><empty_output><jupyter_text>Some men are mortal Example<jupyter_code>#initialize the subject and predicate sets
[subject,predicate]=initSandP();

#apply Some men (S) are mortal (P)
[subject,predicate]=someSisP(subject,predicate);

#Venn diagram of some S is P
venn2_pretty(subject,'Men', predicate, 'Mortal','Some Men are Mortal');<jupyter_output><empty_output><jupyter_text>Some Men are not Mortal<jupyter_code>#initialize the subject and predicate sets
[subject,predicate]=initSandP();

#apply Some men (S) are not mortal (P)
[subject,predicate]=someSisNotP(subject,predicate);

#Venn diagram of some S is not P
venn2_pretty(subject,'Men', predicate, 'Mortal','Some Men are not Mortal');<jupyter_output><empty_output><jupyter_text>My Venn Diagrams<jupyter_code><jupyter_output><empty_output>
{'fraction_non_alphanumeric': 0.15776458951533134, 'fraction_numerical': 0.02101879327398615, 'mean_word_length': 6.0103986135181975, 'pattern_counts': {'":': 0, '<': 25, '<?xml version=': 0, '>': 25, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'chain_length': '6', 'dir': 'jupyter-structured-clean-dedup', 'id': '327462', 'license': 'MIT', 'n_tokens_mistral': 1725, 'n_tokens_neox': 1661, 'n_words': 318, 'path': '1.14.ipynb', 'repo_name': 'Martian-Mathematics/L5-1.13', 'size': '4044'}