%load_ext autoreload
%autoreload 2
import re
from tf.fabric import Fabric
from tf.app import use
TF = Fabric(locations='~/github/annotation//banks/tf/0.2')
This is Text-Fabric 7.8.2 Api reference : https://annotation.github.io/text-fabric/Api/Fabric/ 10 features found and 0 ignored
allFeatures = TF.explore(silent=True, show=True)
loadableFeatures = allFeatures['nodes'] + allFeatures['edges']
We load all features:
api = TF.load(loadableFeatures)
docs = api.makeAvailableIn(globals())
0.00s loading features ... 0.02s All features loaded/computed - for details use loadLog()
query = '''
line
.number=number. sentence
'''
results = list(S.search(query))
len(results)
6
for (l, s) in results:
print(f'{F.otype.v(l)} {l} has number {F.number.v(l)} = {F.number.v(s)} of {F.otype.v(s)} {s}')
line 103 has number 1 = 1 of sentence 115 line 110 has number 1 = 1 of sentence 115 line 104 has number 2 = 2 of sentence 116 line 111 has number 2 = 2 of sentence 116 line 103 has number 1 = 1 of sentence 117 line 110 has number 1 = 1 of sentence 117
S.exe.qedgesRaw
[(0, '.number=number.', 1)]
TF = Fabric(locations='/Users/dirk/github/annotation/text-fabric/test/generic/tf')
This is Text-Fabric 7.8.2 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
allFeatures = TF.explore(silent=True, show=True)
loadableFeatures = allFeatures['nodes'] + allFeatures['edges']
api = TF.load(loadableFeatures)
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.02s All features loaded/computed - for details use loadLog()
F.namesign.freqList()
(('special', 1), ('ss-peculiar-ss', 1), ('ss-special-ss', 1))
query = '''
part name=s1
.namepart=namesign. sign name=a
'''
results = list(S.search(query))
results
[(11, 1)]
query = '''
sign name=a
.namesign=namepart. part name=s1
'''
results = list(S.search(query))
results
[]
query = '''
sign name=b
.namesign~(^[sp][sp]-)|(-[sp][sp]$)~namepart. part name=s2
'''
r = re.compile(r'(^[sp][sp]-)|(-[sp][sp]$)')
print(F.name.v(2))
print(F.namesign.v(2))
print(r.sub('', F.namesign.v(2)))
print(F.name.v(12))
print(F.namepart.v(12))
print(r.sub('', F.namepart.v(12)))
b ss-special-ss special s2 pp-special-pp special
results = list(S.search(query))
results
[(2, 12)]
query = '''
sign name=b
.namesign=namesign. sign name=b
'''
results = list(S.search(query))
results
[]
query = '''
sign name=b
.namesign~(^[sp]{2}-)|(-[sp]{2}$)~namepart. part name=s2
'''
results = list(S.search(query))
results
[(2, 12)]
query = '''
sign
.number~[A-Z]~name. sign
.number<name. sign
'''
results = list(S.search(query))
results
0 1 sign 2 .number~[A-Z]~name. sign 3 .number<name. sign 4 Feature "name" has wrong type: "str" is the wrong type: line(s) 2 Feature "number" has wrong type: "int" is the wrong type: line(s) 1
[]
query = '''
sign name>3
'''
results = list(S.search(query))
results
0 1 sign name>3 2 Feature "name" has wrong values: "<function _makeLimit.<locals>.<lambda> at 0x7fe28891d378>" is not a number: line(s) 1
[]
F.number.data.items()
dict_items([(1, 1), (2, 2), (3, 3), (4, 4), (11, 1), (12, 2), (13, 3), (14, 4), (15, 5), (16, 6), (17, 7), (18, 8), (19, 9)])
F.name.data.items()
dict_items([(1, 'a'), (2, 'b'), (3, 'c'), (4, 'd'), (5, 'e'), (6, 'f'), (7, 'g'), (8, 'h'), (9, 'i'), (10, 'j'), (11, 's1'), (12, 's2'), (13, 's3'), (14, 's4'), (15, 's5'), (16, 's6'), (17, 's7'), (18, 's8'), (19, 's9'), (20, 's10'), (21, 'ss1'), (22, 'ss2'), (23, 'ss3'), (24, 'ss4'), (25, 'ss5'), (26, 'ss6'), (27, 'ss7'), (28, 'ss8'), (29, 'ss9'), (30, 'ss10'), (31, 'd1'), (32, 'd2'), (33, 'd3'), (34, 'd4'), (35, 'd5'), (36, 't1'), (37, 't2'), (38, 't3'), (39, 't4'), (40, 'q1'), (41, 'q2'), (42, 'q3'), (43, 'u1'), (44, 'u2'), (45, 'lower_a'), (46, 'lower_b'), (47, 'lower_c'), (48, 'upper_a'), (49, 'upper_b'), (50, 'upper_c'), (51, 'lower'), (52, 'upper'), (53, 'odd'), (54, 'even'), (55, 'big'), (56, 'small1'), (57, 'small2'), (58, 'small3'), (59, 'small4'), (60, 'small5'), (61, 'small6'), (62, 'small7'), (63, 'small8'), (64, 'john'), (65, 'mary'), (66, 'fred'), (67, 'jim'), (68, 'jim1'), (69, 'jim2'), (70, 'jim3'), (71, 'tim'), (72, 'tom'), (73, 'tom1n'), (74, 'tom1p'), (75, 'tom2n'), (76, 'tom2p'), (77, 'timb'), (78, 'tomb'), (79, 'tomb1n'), (80, 'tomb1p'), (81, 'tomb2n'), (82, 'tomb2p'), (83, 'time'), (84, 'tome'), (85, 'tome1n'), (86, 'tome1p'), (87, 'tome2n'), (88, 'tome2p'), (89, 'all')])
A = use('bhsa', hoist=globals())
This is Text-Fabric 9.1.5 Api reference : https://annotation.github.io/text-fabric/tf/cheatsheet.html 122 features found and 0 ignored
query = """
verse book=Genesis chapter=1
c1:clause number=2
p1:phrase
c1 .number>number. p1
"""
results = A.search(query)
0.34s 20 results
A.show(results, start=1, end=1)
result 1
query = '''
c:clause
PreGap:phrase_atom
LastPhrase:phrase_atom
:=
Gap:clause_atom
:: word
PreGap < Gap
Gap < LastPhrase
c || Gap
'''
S.study(query)
0.00s Checking search template ... 0.00s Setting up search space for 5 objects ... 0.19s Constraining search space with 8 relations ... 0.64s 2 edges thinned 0.64s Setting up retrieval plan ... 0.65s Ready to deliver results from 454173 nodes Iterate over S.fetch() to get the results See S.showPlan() to interpret the results
S.showPlan(details=True)
Search with 5 objects and 8 relations Results are instantiations of the following objects: node 0-clause ( 88121 choices) node 1-phrase_atom (267541 choices) node 2-phrase_atom ( 88121 choices) node 3-clause_atom ( 5195 choices) node 4-word ( 5195 choices) Performance parameters: yarnRatio = 1.25 tryLimitFrom = 40 tryLimitTo = 40 Instantiations are computed along the following relations: node 3-clause_atom ( 5195 choices) edge 3-clause_atom :: 4-word ( 1.0 choices (thinned)) edge 4-word ]] 3-clause_atom ( 1.0 choices) edge 3-clause_atom < 2-phrase_atom ( 44060.5 choices) edge 2-phrase_atom := 0-clause ( 1.0 choices (thinned)) edge 0-clause [[ 2-phrase_atom ( 1.0 choices) edge 0-clause || 3-clause_atom ( 4675.5 choices) edge 0-clause [[ 1-phrase_atom ( 3.0 choices) edge 1-phrase_atom < 3-clause_atom ( 2597.5 choices) 14s The results are connected to the original search template as follows: 0 1 R0 c:clause 2 R1 PreGap:phrase_atom 3 R2 LastPhrase:phrase_atom 4 := 5 6 R3 Gap:clause_atom 7 R4 :: word 8 9 PreGap < Gap 10 Gap < LastPhrase 11 c || Gap 12
S.count(progress=1, limit=4)
0.00s Counting results per 1 up to 4 ... | 3.76s 1 | 10s 2 | 32s 3 | 33s 4 33s Done: 4 results