%load_ext autoreload
%autoreload 2
import os
from array import array
from tf.app import use
from tf.fabric import Fabric
TF = Fabric(locations='/Users/dirk/text-fabric-data/etcbc/bhsa/tf/c')
This is Text-Fabric 7.8.2 Api reference : https://annotation.github.io/text-fabric/Api/Fabric/ 114 features found and 0 ignored
api = TF.loadAll()
0.00s loading features ... | 0.00s No structure info in otext, the structure part of the T-API cannot be used 3.62s All features loaded/computed - for details use loadLog() 0.00s loading features ... 7.30s All additional features loaded - for details use loadLog()
TF = Fabric(locations='tf')
TF.clearCache()
This is Text-Fabric 7.8.1 Api reference : https://annotation.github.io/text-fabric/Api/Fabric/ 7 features found and 0 ignored 0.00s Warp feature "otext" not found. Working without Text-API
api = TF.load('name sign')
docs = api.makeAvailableIn(globals())
0.00s loading features ... | 0.00s No section config in otext, the section part of the T-API cannot be used | 0.00s No structure info in otext, the structure part of the T-API cannot be used 0.00s All features loaded/computed - for details use loadLog()
query = '''
sign name=a
== part name=s1
'''
S.study(query)
0.00s Checking search template ... 0.00s Setting up search space for 2 objects ... 0.00s Constraining search space with 1 relations ... 0.00s 0 edges thinned 0.00s Setting up retrieval plan ... 0.00s Ready to deliver results from 2 nodes Iterate over S.fetch() to get the results See S.showPlan() to interpret the results
S.showPlan(details=True)
Search with 2 objects and 1 relations Results are instantiations of the following objects: node 0-sign ( 1 choices) node 1-part ( 1 choices) Performance parameters: yarnRatio = 1.25 tryLimitFrom = 40 tryLimitTo = 40 Instantiations are computed along the following relations: node 0-sign ( 1 choices) edge 0-sign == 1-part ( 1.0 choices) 1.20s The results are connected to the original search template as follows: 0 1 R0 sign name=a 2 R1 == part name=s1 3
results = list(S.search(query))
results
[(1, 11)]
ClevUp = C.levUp.data
Eoslots = E.oslots.data
maxSlot = F.otype.maxSlot
def xx(n):
if n <= maxSlot:
slotN = n
else:
slots = Eoslots[n - maxSlot - 1]
slotN = slots[0] if len(slots) == 1 else None
return (
tuple(m for m in ClevUp[n - 1] if n in ClevUp[m - 1])
+
((slotN, ) if slotN else ())
)
def xx(n):
if n <= maxSlot:
nA = array('I', (n,))
return tuple(m for m in ClevUp[n - 1] if Eoslots[m - maxSlot - 1] == nA) + (n,)
nSlots = Eoslots[n - maxSlot - 1]
if len(nSlots) == 1:
slot1 = nSlots[0]
nA = array('I', (slot1,))
nT = (slot1,)
return tuple(m for m in ClevUp[n - 1] if Eoslots[m - maxSlot - 1] == nA) + (n,) + nT
return tuple(m for m in ClevUp[n - 1] if n in ClevUp[m - 1]) + (n,)
F.name.s('a')
(1,)
F.name.s('s1')
(11,)
xx(1)
(21, 11, 1)
xx(11)
(21, 11, 1)
xx(21)
(11, 21, 1)
L.d(21)
[11, 1]
L.u(21)
array('I', [11, 67, 49, 53, 82, 77, 31, 36, 40, 51, 43, 47, 46, 45, 89])
L.d(11)
[21, 1]
L.d(21)
[11, 1]
for i in (1, 11, 21):
iType = F.otype.v(i)
slots = ((i,) if iType == 'sign' else ()) + L.d(i, otype='sign')
print(f'{iType} {i} has name {F.name.v(i)} and slots {slots}')
sign 1 has name a and slots (1,) part 11 has name s1 and slots (1,) part 21 has name ss1 and slots (1,)
query = '''
part name=s1
.namepart~(^[sp]{2}-)|(-[sp]{2}$)~namepart. part name=s3
'''
results = list(S.search(query))
results
11: nVal=special 11: nValR=special 13: mVal=pp-peculiar-pp 13: mValR=peculiar result 11 == 13: False 11: nVal=special 11: nValR=special 13: mVal=pp-peculiar-pp 13: mValR=peculiar result 11 == 13: False 13: nVal=pp-peculiar-pp 13: nValR=peculiar 11: mVal=special 11: mValR=special result 13 == 11: False 11: nVal=special 11: nValR=special 13: mVal=pp-peculiar-pp 13: mValR=peculiar result 11 == 13: False
[]
print(F.namepart.v(11))
print(F.namepart.v(13))
special pp-peculiar-pp