/ core / theory_of_mind / __pycache__ / content_analyzer.cpython-314.pyc
content_analyzer.cpython-314.pyc
  1  +
  2  ��fi�=�	���Rt^RIHtHt^RIHt^RIHtHtHtH	t	H
  3  t
  4  ^RIHt^RI
t
^RIHtHtHtHt]!RR44t]!R	R
  5  44t!RR4t]R
8XEd�^RIHtHt]!R4]!RR7t]P3RR.R)O4]P3RR.R*O4]P3RR.R+O4]P5]P6R4]P5]P8R4Rt]!]4t]P?]R4t ]!R]!!] PD4R24]!R4]PG] R^R7F�t$]!R]$PJR 
R!]$PLR",R#24]!R$R%POR&]$PPPS44424]!R']$PTUu.uFqPVNK	up24K�	]!R(4R#R#uupi),a\
  6  Content Analyzer
  7  
  8  Analyzes incoming content (podcasts, articles, conversations) to identify
  9  ideas and predict which will resonate with an operator.
 10  
 11  The analyzer:
 12  1. Parses content into discrete ideas/bullets
 13  2. Tags each idea with metadata (altitude, topic, pattern type)
 14  3. Scores resonance probability based on operator's cognitive fingerprint
 15  )�	dataclass�field)�datetime)�Optional�List�Dict�Any�Tuple)�EnumN)�CognitiveFingerprint�GravityWell�PatternType�PatternPreferencec�a�]tRt^toRtRtRt]!]R7t	]!]R7t
 16  ]!]R7tRtRt
RtRtRtRt]!]R7tRtV3RltRtVtR#)�ContentIdeaza
 17  A discrete idea extracted from content.
 18  
 19  This is the unit of analysis for resonance prediction.
 20  N��default_factoryF��?c�D<�V^8�dQh/S[;R&S[;R&S[S[,;R&S[S[,;R&S[S[,;R&S[S[,;R&S[S[,;R&S[;R&S[;R	&S[;R
 21  &S[;R&S[;R&S[;R
&S[S[S[3,;R&S[S[,;R&#)��idea_id�content�source_location�altitude�topics�
pattern_types�tags�
is_contrarian�is_first_principles�is_narrative�is_quantitative�
is_historical�predicted_resonance�resonance_factors�actually_resonated)�strrrr
�bool�floatr)�format�
__classdict__s"��G/Users/rcerf/repos/Sovereign_OS/core/theory_of_mind/content_analyzer.py�__annotate__�ContentIdea.__annotate__s������L���L���c�]�)���s�m�"��
��I�3����$�B���s�)�1��$��%�&�%�'�(��)�*�!�+�,��-�2�$�3�4�C��J�'�E�5�:!���-�;��)�__name__�
 22  __module__�__qualname__�__firstlineno__�__doc__rrr�listrrrrrrr r!r"�dictr#r$�__annotate_func__�__static_attributes__�__classdictcell__�r)s@r*rrst�����&*�O�#�H��d�3�F�',�T�'B�M��D�1�D� �M� %���L�!�O��M�"%��*/��*E��*.��;�r-rc�a�]tRt^8toRt]!]PR7t]!]	R7t
 23  ]!]	R7t]!]	R7tRt
RtRtV3RltRtVtR#)�ResonancePredictionz/
 24  A prediction about which ideas will resonate.
 25  rNc��<�V^8�dQh/S[;R&S[;R&S[;R&S[S[,;R&S[S[,;R&S[S[,;R&S[S[,;R&S[S[,;R&S[S[,;R	&#)
 26  r�
prediction_id�source_name�
 27  created_at�ideas�
predicted_top�actual_selections�accuracy�	precision�recall)r%rrrrr')r(r)s"�r*r+� ResonancePrediction.__annotate__8s�����
 28  �����
��>�����:����9�:�� �C�y�>�!�&�u�o�$�'�(���%�)�*
�U�O�"�+r-r.)r/r0r1r2r3rr�nowr?r4r@rArBrCrDrEr6r7r8r9s@r*r;r;8sW�����
 29  !����>�J� %�T�:�E� %�T�:�M�$)��#>��!%�H�!%�I�"�F�+�r-r;c�a�]tRt^PtoRtR.ROR.ROR.ROR.RO/t]P.RO]P.RO]P.RO]P.RO]P.RO]P.RO]P.RO/tV3RlRltRV3RlR	lltV3R
 30  lRltV3RlR
ltV3RlRltR V3RlRlltRtVtR#)!�ContentAnalyzerz:
 31  Analyzes content and predicts resonance for an operator.
 32  �
philosophical�	strategic�tactical�operationalc� <�V^8�dQhRS[/#)r�fingerprint)r)r(r)s"�r*r+�ContentAnalyzer.__annotate__�s���

 33  �

 34  �$8�

 35  r-c
���WnVPP4UUUu/uF:wr#Y#Uu.uF(p\P!V\P
 36  4NK*	upbK<	upppVnR#uupiuupppi)zy
 37  Initialize analyzer with operator's cognitive fingerprint.
 38  
 39  Args:
 40      fingerprint: The operator's cognitive fingerprint
 41  N)rO�PATTERN_INDICATORS�items�re�compile�
 42  IGNORECASE�_compiled_patterns)�selfrO�pt�patterns�ps&&   r*�__init__�ContentAnalyzer.__init__�sh��'��
 43  !%� 7� 7� =� =� ?�#
 44  � ?���
�x�@�x�!����A�r�}�}�-�x�@�@� ?�#
 45  ����@��#
 46  s�A6�.A1�A6�1A6c�2<�V^8�dQhRS[RS[RS[RS[/#)rrr>�split_strategy�return)r%r;)r(r)s"�r*r+rP�s3���.
 47  �.
 48  ��.
 49  ��.
 50  ��	.
 51 52  
 53  �.
 54  r-c��VPW4p.p\V4FZwpwrx\VP44^8dK(VP	VR,RVR
2VVR7p	VPV	4K\	VF!p	VP
V	4wV	nV	nK#	\VRRR7p
 55  V
 56  R,U	u.uFq�PNK	pp	\R	\P!4PR
 57  42VVVR7#uup	i)z�
 58  Analyze content and predict resonance.
 59  
 60  Args:
 61      content: Raw content to analyze
 62      source_name: Name of the source
 63      split_strategy: How to split ('paragraph', 'sentence', 'bullet')
 64  
 65  Returns:
 66      ResonancePrediction with all ideas and predictions
 67  :N�N�_�03d)rr�locationc��VP#�N�r"��xs&r*�<lambda>�1ContentAnalyzer.analyze_content.<locals>.<lambda>�s
 68  ��1�3H�3Hr-T��key�reverse�N�
 69  N�pred_z
%Y%m%d_%H%M%S)r=r>r@rA)�_split_content�	enumerate�len�strip�
_analyze_idea�append�_predict_resonancer"r#�sortedrr;rrG�strftime)rXrr>r_�	raw_ideasr@�i�textre�idea�ideas_sortedrAs&&&&        r*�analyze_content�ContentAnalyzer.analyze_content�s��$�'�'��@�	���#,�Y�#7��A����4�:�:�<� �2�%���%�%�&�r�?�+�1�Q�s�G�4��!�&��D�
 70  
�L�L���$8��D��'�'��-�
=�D�$�d�&<��
 71  �e�)H�RV�W��2>�s�2C�D�2C�$���2C�
�D�"�!�(�,�,�.�"9�"9�/�"J�!K�L�#��'�	
 72  �	
 73  ��Es�>Dc	�R<�V^8�dQhRS[RS[RS[S[S[S[3,,/#)rr�strategyr`)r%rr	)r(r)s"�r*r+rP�s6���'�'��'��'�
 74  �e�C��H�o�	�	'r-c�|�VR8Xdb\P!RV4p\V4UUu.uF2wrEVP4'gKVP4RV23NK4	upp#VR8Xdb\P!RV4p\V4UUu.uF2wrGVP4'gKVP4RV23NK4	upp#VR8Xdb\P!RV4p\V4UU	u.uF2wrIV	P4'gKV	P4R	V23NK4	up	p#VR
 75  8Xdb\P!RV4p
 76  \V
 77  4UUu.uF2wrGVP4'gKVP4RV23NK4	upp#VR
3.#uuppiuuppiuup	piuuppi)z+Split content into segments with locations.�	paragraphz\n\n+�para_�sentencez
(?<=[.!?])\s+�sent_�bulletu\n[-*•]\s+|\n\d+\.\s+�bullet_�sectionz\n#{1,3}\s+�section_�full)rT�splitrtrv)rXrr��
 78  paragraphsr}r[�	sentences�s�bullets�b�sectionss&&&        r*rs�ContentAnalyzer._split_content�s����{�"����(�G�4�J�9B�:�9N�\�9N���RS�RY�RY�R[�,�Q�W�W�Y�%��s��,�9N�\�\�
��
#����!1�7�;�I�9B�9�9M�[�9M���QR�QX�QX�QZ�,�Q�W�W�Y�%��s��,�9M�[�[�
��
!��h�h�9�7�C�G�;D�W�;M�[�;M�4�1�QR�QX�QX�QZ�.�Q�W�W�Y�'�!��
�.�;M�[�[�
��
"��x�x���8�H�<E�h�<O�]�<O�D�A�ST�SZ�SZ�S\�/�Q�W�W�Y�(�1�#��/�<O�]�]��f�%�&�&��']��
 79  \��
 80  \��
 81  ^s/�F&�F&�F,�4F,�=F2�F2�%F8�F8c�2<�V^8�dQhRS[RS[RS[RS[/#)rrrrer`)r%r)r(r)s"�r*r+rP�s3���-�-��-��-��	-�
 82  
 83  �-r-c��aa
�\VVVR7pVP4o
/oVPP4FwrV\	V
3RlV44pVSV&K!	\SP
44^8�d&\SP4V3RlR7VnMRVn\P!RV4p\\V44R,Vn
VPP4FCwr�V
 84  F8pVPV4'gKVP P#V	4KA	KE	\$P&VP 9Vn\$P*VP 9Vn\$P.VP 9Vn\$P2VP 9Vn\$P6VP 9VnV#)zAnalyze a single idea.)rrrc3�8<"�TFqS9gK^x�K	R#5i)�Nr.)�.0�kw�
content_lowers& �r*�	<genexpr>�0ContentAnalyzer._analyze_idea.<locals>.<genexpr>�s����D�H�b�m�0C���H�s��
 85  c�<�SV,#rgr.)�k�altitude_scoress&�r*rk�/ContentAnalyzer._analyze_idea.<locals>.<lambda>�s���o�VW�FXr-)rnrLz"\b[A-Z][a-z]+(?:\s+[A-Z][a-z]+)*\brp)r�lower�ALTITUDE_KEYWORDSrS�sum�max�values�keysrrT�findallr4�setrrW�searchrrxr
�
 86  CONTRARIANr�FIRST_PRINCIPLESr�
NARRATIVE_ARCr�QUANTITATIVEr �
 87  HISTORICALr!)rXrrrerr�keywords�score�words�pattern_typerZ�patternr�r�s&&&&        @@r*rw�ContentAnalyzer._analyze_idea�s�������$�
 88  �� �
�
��
���"&�"8�"8�">�">�"@��H��D�H�D�D�E�(-�O�H�%�#A���%�%�'�(�1�,��� 4� 4� 6�<X�Y�D�M�&�D�M��
 89 90  �@�'�J���3�u�:�&�s�+���'+�&=�&=�&C�&C�&E�"�L�#���>�>�'�*�*��&�&�-�-�l�;��$�'F�)�3�3�t�7I�7I�I���#.�#?�#?�4�CU�CU�#U�� �'�5�5��9K�9K�K���*�7�7�4�;M�;M�M���(�3�3�t�7I�7I�I����r-c�R<�V^8�dQhRS[RS[S[S[S[S[3,3,/#)rrr`)rr	r'rr%)r(r)s"�r*r+rPs6���L$�L$��L$�
 91  �u�d�3��:�&�&�	'�L$r-c��a
a�/o
RpVPF)pVPPV4p\W$4pK+	VPPP4FbpVP
4VPP
49gK2\W PPV,P4pKd	VS
R&RpVPFPpWpPP9gK\VVPPV,P4pKR	VS
R&VP'dQVPVPP9d,VPPVP,S
R&MRS
R&RpVPPFCp	V	PVPP
49gK.\W�P4pKE	VS
R&\!R\#VP4R,4p
 92  V
 93  R	,S
R
 94  &VP$'dcVPPP'\(P*\-\(P*44PpVR,S
R&MRS
R&RR
RRRRRRR
 95  RRR/o\/V
V3RlS44p\R\!RV44pVS
3#)zU
 96  Predict resonance probability for an idea.
 97  
 98  Returns (probability, factor_breakdown)
 99  g�gravity_well�
pattern_match�altitude_matchg�?�
trigger_matchg�?i�r�richness�333333�?�contrarian_bonusgffffff�?皙�����?g333333�?g�������?g�������?c3�R<"�TFpSV,SV,,x�K	R#5irgr.)r�r��factors�weightss& ��r*r��5ContentAnalyzer._predict_resonance.<locals>.<genexpr>\s!����C�7�a�'�!�*�w�q�z�1�1�7�s�$')rrO�get_gravity_for_conceptr��
gravity_wellsr�r�r�massr�pattern_preferences�strengthr�altitude_distribution�resonance_triggers�trigger_type�minrur�getr
r�rr�)rXr�max_gravity�topic�gravity�	well_name�
pattern_scorer��
trigger_score�triggerr��contrarian_pref�probabilityr�r�s&&           @@r*ry�"ContentAnalyzer._predict_resonances���������[�[�E��&�&�>�>�u�E�G��k�3�K�!�
100  �)�)�7�7�<�<�>�I���� �D�L�L�$6�$6�$8�8�!�+�/?�/?�/M�/M�i�/X�/]�/]�^��?�#.�����
� �.�.�L��/�/�C�C�C� #�!��$�$�8�8��F�O�O�!�
�/�$1��� ��=�=�=�T�]�]�d�.>�.>�.T�.T�T�(,�(8�(8�(N�(N�t�}�}�(]�G�$�%�(,�G�$�%��
��'�'�:�:�G��#�#�t�|�|�'9�'9�';�;� #�M�3C�3C� D�
�;�$1��� ��s�C����-��3�4��&��n��
101  ������"�.�.�B�B�F�F��&�&�(9�+�:P�:P�(Q���h�
�+:�C�*?�G�&�'�*-�G�&�'�
�D��T��d��T�����

102  ���C�7�C�C���#�s�3��4�5���G�#�#r-c	�B<�V^8�dQhRS[RS[RS[RS[S[,/#)r�
103  prediction�	threshold�	max_countr`)r;r'�intrr)r(r)s"�r*r+rPcs8���*�*�'�*��*��	*�
104  
105  �k�	�*r-c��VPUu.uFpVPV8�gKVNK	ppVPRRR7VRV#uupi)z�
106  Get ideas predicted to resonate above threshold.
107  
108  Args:
109      prediction: The resonance prediction
110      threshold: Minimum resonance probability
111      max_count: Maximum number to return
112  
113  Returns:
114      List of high-resonance ideas
115  c��VP#rgrhris&r*rk�:ContentAnalyzer.get_predicted_highlights.<locals>.<lambda>xs
116  ��!�*?�*?r-TrmN)r@r"�sort)rXr�r�r�r�high_resonances&&&&  r*�get_predicted_highlights�(ContentAnalyzer.get_predicted_highlightscsb��$(�-�-�
117  �-�T��'�'�9�4�
�D�-�	�
118  �	��� ?���N��j�y�)�)��
119  s
120  �A�A)rWrON)�truth�meaning�purpose�fundamental�essence�	principle�wisdom�belief�value�why�
121  philosophy�matters)r��architecture�design�system�	framework�model�approach�visionz	long-term�	structurer�)�decision�choice�option�tradeoff�method�	technique�should�versus�compare�alternative�choose)�step�	implement�build�execute�action�do�task�specific�concretezhow to�exactly)r�zat its corez
boils down tor�zfirst principleszbasic truth�
122  underlying)�interconnect�feedback�	emergencezcomplex systemzsecond.orderz
ripple effect�	ecosystem)�journey�story�hero�struggle�overcome�chapter�	beginning�transformation)�counterintuitivezconventional wisdom�actually�opposite�surprisinglyzcontrary tozmost people think)�likez
123  similar to�analogyzsame asz
reminds me of�parallelz
equivalent to)z\d+xz\d+%�billion�million�ratio�metricz
124  data shows�
125  statistics)�historyzin \d{4}zdecades ago�
126  originally�foundedzlearned from�past)r�)g333333�?rq)r/r0r1r2r3r�r
r��SYSTEMS_THINKINGr�r��
127  ANALOGICALr�r�rRr\r�rsrwryr�r7r8r9s@r*rIrIPs������	�
128  �	�
129  �	�
130  �	�
131  ���*	�$�$�'
132  �	�$�$�'
133  �	�!�!�$
134  �	���!
135  �	���!
136  �	� � �#
137  �	���!
138  �3��>

139  �

140  �.
141  �.
142  �`'�'�<-�-�^L$�L$�\*�*�*r-rI�__main__)rr
z=== Content Analyzer Test ===
143  �rick)�operator_id�survivalg�������?�compoundinggffffff�?r�r�r�a<
144      Optimism always wins. Even when things seem bleak, like in Japan in 1946 after
145      the war, it's rational to be an optimist. Akio Morita and Masaru Ibuka founded
146      Sony in those challenging times and built one of the most iconic companies.
147  
148      Moore's Law tells us that computing power doubles every 18-24 months. This
149      exponential growth means technology can access increasingly larger markets.
150  
151      Jensen Huang's will to survive exceeds everybody else's will to kill him.
152      Nvidia faced immense competition, laying off 70% of the company, but survived
153      through sheer determination and innovation.
154  
155      Let your winners ride. The key insight is not the growth rate in any given
156      year, but how many years of growth do you have left. An astonishing 99.98%
157      of Amazon's growth happened after its IPO.
158  
159      Strength leads to strength. When you acquire new resources, you become more
160      valuable, which allows you to acquire even more resources. This is reflexivity
161      in action.
162  
163      It's never too late. Dr. Morris Chang founded TSMC at 56 years old and built
164      it into one of the most valuable companies in the world.
165  
166      Focus on what makes your beer taste better. Jeff Bezos argued that startups
167      should focus solely on the attributes that customers care about. Everything
168      else should be outsourced.
169      �acquired_playbookz	Analyzed z ideas
170  zTop Predicted Resonators:)r�r�z
171    [�.2fz] :N�PNz...z
    Factors: z, c#�H"�TFwrV^8�gKVRVR
2x�K	R#5i)��=r4Nr.)r�r��vs&  r*r�r��s+���'k�Ca�4�1�ef�ij�ej��1�#�Q�q��g��Ca�s�"�"z    Patterns: z
172  === Test Complete ===)�
173  resilience�will�
determination)�exponential�growth�leverage)r�rZ�systems),r3�dataclassesrrr�typingrrrrr	�enumr
174  rT�cognitive_fingerprintrrr
rrr;rIr/�print�fp�add_gravity_well�update_pattern_preferencer�r��sample_content�analyzerr�r�rur@r�rr"r�joinr#rSr�name)r[s0r*�<module>rMs���
175  �)��3�3��	���
176  �.�.��.�>�#�#��#�.i*�i*�Z	�z��H�	�
177  +�,�
178  �&�	1�B����
179  �C�)P�Q����
�s�,Q�R������-N�O�� � ��!=�!=�s�C�� � ��!7�!7��=��N�:�r�"�H��)�)�.�:M�N�J�	�I�c�*�*�*�+�,�H�
180  5�6�	�
181  %�&��1�1�*��WX�1�Y��
��d�.�.�s�3�2�d�l�l�3�6G�5H��L�M�
�
�d�i�i�'k�4�CY�CY�C_�C_�Ca�'k�k�l�m�n�
���0B�0B�C�0B�1���0B�C�D�E�F�Z�
182  
183184  #�$�m��h Ds�G.