File tree Expand file tree Collapse file tree
examples/pbe/transduction/knowledge_graph Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -181,15 +181,23 @@ def filter_constants(constants: List[str]) -> List[str]:
181181 print ("\t Found no path for relationship level" , d )
182182 print ()
183183
184- constants_in = task .metadata .get ("constants_in" , None ) or filter_constants (
185- find_constants (
186- [
187- pbe .examples [i ].inputs [0 ]
188- for i in range (min (MAX_EXAMPLES_ANALYSED , len (pbe .examples )))
189- ]
190- )
191- )
192- if task .metadata .get ("constants_in" , None ) is None :
184+ constants_in = task .metadata .get ("constants_in" , None )
185+ if constants_in is None :
186+ all_possibles = [
187+ filter_constants (
188+ find_constants (
189+ [
190+ pbe .examples [i + k ].inputs [0 ]
191+ for i in range (
192+ min (MAX_EXAMPLES_ANALYSED , len (pbe .examples ))
193+ )
194+ ]
195+ )
196+ )
197+ for k in range (max (1 , len (pbe .examples ) - MAX_EXAMPLES_ANALYSED ))
198+ ]
199+ t = sorted ([(len (l ), l ) for l in all_possibles ])
200+ constants_in = t [0 ][1 ]
193201 task .metadata ["constants_in" ] = constants_in
194202 dataset .save (dataset_file )
195203 print ("Constants Input:" , constants_in )
You can’t perform that action at this time.
0 commit comments