def SALVIA_P_light(name='SALVIA_P_verbal_guidance', grammar_name='TCG_grammar_VB_main', semantics_name='TCG_semantics_main', grammar_path='./data/grammars/', semantics_path='./data/semantics/'): """ Creates and returns a light version of the SALVIA production model. It bypasses the VisualWM and the Conceptualizer """ # Instantiating all the necessary system schemas scene_perception = ps.SCENE_PERCEPTION() conceptLTM = ls.CONCEPT_LTM() semanticWM = ls.SEMANTIC_WM() grammaticalWM_P = ls.GRAMMATICAL_WM_P() grammaticalLTM = ls.GRAMMATICAL_LTM() cxn_retrieval_P = ls.CXN_RETRIEVAL_P() phonWM_P = ls.PHON_WM_P() control = ls.CONTROL() utter = ls.UTTER() # Defining schema to brain mappings. brain_mappings = { 'Scene_perception': ['Ventral stream'], 'Concept_LTM': [''], 'Semantic_WM': ['left_SFG', 'LIP', 'Hippocampus'], 'Grammatical_WM_P': ['left_BA45', 'leftBA44'], 'Grammatical_LTM': ['left_STG', 'left_MTG'], 'Cxn_retrieval_P': [], 'Phonological_WM_P': ['left_BA6'], 'Utter': [''], 'Control': ['DLPFC'] } schemas = [ scene_perception, conceptLTM, grammaticalLTM, cxn_retrieval_P, semanticWM, grammaticalWM_P, phonWM_P, utter, control ] # Creating model and adding system schemas model = st.MODEL(name) model.add_schemas(schemas) # Defining connections model.add_connection(scene_perception, 'to_semantic_WM', semanticWM, 'from_conceptualizer') model.add_connection(semanticWM, 'to_visual_WM', scene_perception, 'from_semantic_WM') model.add_connection(semanticWM, 'to_cxn_retrieval_P', cxn_retrieval_P, 'from_semantic_WM') model.add_connection(grammaticalLTM, 'to_cxn_retrieval_P', cxn_retrieval_P, 'from_grammatical_LTM') model.add_connection(cxn_retrieval_P, 'to_grammatical_WM_P', grammaticalWM_P, 'from_cxn_retrieval_P') model.add_connection(semanticWM, 'to_grammatical_WM_P', grammaticalWM_P, 'from_semantic_WM') model.add_connection(grammaticalWM_P, 'to_semantic_WM', semanticWM, 'from_grammatical_WM_P') model.add_connection(grammaticalWM_P, 'to_phonological_WM_P', phonWM_P, 'from_grammatical_WM_P') model.add_connection(phonWM_P, 'to_grammatical_WM_P', grammaticalWM_P, 'from_phonological_WM_P') model.add_connection(semanticWM, 'to_control', control, 'from_semantic_WM') model.add_connection(phonWM_P, 'to_utter', utter, 'from_phonological_WM_P') model.add_connection(phonWM_P, 'to_control', control, 'from_phonological_WM_P') model.add_connection(control, 'to_grammatical_WM_P', grammaticalWM_P, 'from_control') model.add_connection(control, 'to_semantic_WM', semanticWM, 'from_control') model.set_input_ports([scene_perception.find_port('from_input')]) model.set_output_ports([ utter.find_port('to_output'), scene_perception.find_port('to_output') ]) # Setting up schema to brain mappings description_brain_mapping = st.BRAIN_MAPPING() description_brain_mapping.schema_mapping = brain_mappings model.brain_mapping = description_brain_mapping # Parameters system_names = model.schemas.keys() model_params = parameters(system_names) model.update_params(model_params) grammaticalLTM.init_act = grammaticalWM_P.params['C2'][ 'confidence_threshold'] # Loading data semantics_file = "%s.json" % semantics_name my_conceptual_knowledge = TCG_LOADER.load_conceptual_knowledge( semantics_file, semantics_path) grammar_file = "%s.json" % grammar_name my_grammar = TCG_LOADER.load_grammar(grammar_file, grammar_path, my_conceptual_knowledge) # Initialize concept LTM content conceptLTM.initialize(my_conceptual_knowledge) # Initialize grammatical LTM content grammaticalLTM.initialize(my_grammar) return model
# Print the cxn with name cxn_name (STR) if it is found in the grammar. # """ # cxn = self.find_construction(cxn_name) # if not(cxn): # print "%s not found..." % cxn_name # else: # print cxn ############################################################################### if __name__=='__main__': from loader import TCG_LOADER # Loading data grammar_name = 'TCG_grammar_VB_main' my_conceptual_knowledge = TCG_LOADER.load_conceptual_knowledge("TCG_semantics_main.json", "./data/semantics/") grammar_file = "%s.json" %grammar_name my_grammar = TCG_LOADER.load_grammar(grammar_file, "./data/grammars/", my_conceptual_knowledge) cxn = my_grammar.constructions[0] cxn2 = my_grammar.constructions[3] (cxn3, c, u_map) = CXN.unify(cxn, cxn.SynForm.form[0], cxn2) # cxn3.SemFrame.draw() # print [f.name for f in cxn3.SynForm.form] # print cxn3.SymLinks.SL cxn3.show()
def TCG_language_system(name='language_system', grammar_name='TCG_grammar_VB_main', semantics_name='TCG_semantics_main', grammar_path='./data/grammars/', semantics_path='./data/semantics/'): """ Creates and returns the TCG language model, including both production and comprehension. """ # Instantiating all the necessary system schemas semanticWM = ls.SEMANTIC_WM() conceptLTM = ls.CONCEPT_LTM() grammaticalLTM = ls.GRAMMATICAL_LTM() grammaticalWM_P = ls.GRAMMATICAL_WM_P() cxn_retrieval_P = ls.CXN_RETRIEVAL_P() grammaticalWM_C = ls.GRAMMATICAL_WM_C() cxn_retrieval_C = ls.CXN_RETRIEVAL_C() phonWM_P = ls.PHON_WM_P() utter = ls.UTTER() phonWM_C = ls.PHON_WM_C() control = ls.CONTROL() # Defining schema to brain mappings. language_mapping = { 'Semantic_WM': ['left_SFG', 'LIP', 'Hippocampus'], 'Grammatical_WM_P': ['left_BA45', 'leftBA44'], 'Grammatical_LTM': ['left_STG', 'left_MTG'], 'Cxn_retrieval_P': [], 'Phonological_WM_P': ['left_BA6'], 'Utter': [''], 'Cxn_retrieval_C': [], 'Phonological_WM_C': ['Wernicke'], 'Grammatical_WM_C': ['lBA44, lBA45'], 'Control': ['DLPFC'], 'Concept_LTM': [''] } # Initializing model model = st.MODEL(name) # Setting up schema to brain mappings language_brain_mapping = st.BRAIN_MAPPING() language_brain_mapping.schema_mapping = language_mapping model.brain_mapping = language_brain_mapping # Setting up language model. language_schemas = [ semanticWM, conceptLTM, grammaticalLTM, cxn_retrieval_P, grammaticalWM_P, phonWM_P, utter, phonWM_C, grammaticalWM_C, cxn_retrieval_C, control ] model.add_schemas(language_schemas) model.add_connection(semanticWM, 'to_cxn_retrieval_P', cxn_retrieval_P, 'from_semantic_WM') model.add_connection(grammaticalLTM, 'to_cxn_retrieval_P', cxn_retrieval_P, 'from_grammatical_LTM') model.add_connection(cxn_retrieval_P, 'to_grammatical_WM_P', grammaticalWM_P, 'from_cxn_retrieval_P') model.add_connection(semanticWM, 'to_grammatical_WM_P', grammaticalWM_P, 'from_semantic_WM') model.add_connection(grammaticalWM_P, 'to_semantic_WM', semanticWM, 'from_grammatical_WM_P') model.add_connection(grammaticalWM_P, 'to_phonological_WM_P', phonWM_P, 'from_grammatical_WM_P') model.add_connection(phonWM_P, 'to_grammatical_WM_P', grammaticalWM_P, 'from_phonological_WM_P') model.add_connection(semanticWM, 'to_control', control, 'from_semantic_WM') model.add_connection(phonWM_P, 'to_control', control, 'from_phonological_WM_P') model.add_connection(phonWM_P, 'to_utter', utter, 'from_phonological_WM_P') model.add_connection(control, 'to_grammatical_WM_P', grammaticalWM_P, 'from_control') model.add_connection(grammaticalLTM, 'to_cxn_retrieval_C', cxn_retrieval_C, 'from_grammatical_LTM') model.add_connection(phonWM_C, 'to_grammatical_WM_C', grammaticalWM_C, 'from_phonological_WM_C') model.add_connection(grammaticalWM_C, 'to_cxn_retrieval_C', cxn_retrieval_C, 'from_grammatical_WM_C') model.add_connection(cxn_retrieval_C, 'to_grammatical_WM_C', grammaticalWM_C, 'from_cxn_retrieval_C') model.add_connection(control, 'to_semantic_WM', semanticWM, 'from_control') model.add_connection(control, 'to_grammatical_WM_C', grammaticalWM_C, 'from_control') model.add_connection(grammaticalWM_C, 'to_semantic_WM', semanticWM, 'from_grammatical_WM_C') model.add_connection(conceptLTM, 'to_semantic_WM', semanticWM, 'from_concept_LTM') model.set_input_ports([phonWM_C.find_port('from_input')]) model.set_output_ports([utter.find_port('to_output')]) # Parameters system_names = model.schemas.keys() model_params = parameters(system_names) model.update_params(model_params) # grammaticalLTM.init_act = grammaticalWM_P.params['C2']['confidence_threshold']*0.5 # Loading data semantics_file = "%s.json" % semantics_name my_conceptual_knowledge = TCG_LOADER.load_conceptual_knowledge( semantics_file, semantics_path) grammar_file = "%s.json" % grammar_name my_grammar = TCG_LOADER.load_grammar(grammar_file, grammar_path, my_conceptual_knowledge) # Initialize conceptual LTM content conceptLTM.initialize(my_conceptual_knowledge) # Initialize grammatical LTM content grammaticalLTM.initialize(my_grammar) return