Skip to main content

Hi,

How can I extract TextMark value using u2py?

I got the values of a SVM with this sentence:
total = s.args[0].extract(6,1,7).dcount(u2py.TM)

But when I try to extract the info I got an error because the function only take 3 arguments:
for x in range(1,total):
print (s.args[0].extract(6,1,7,x))
โ€˜โ€™โ€™
Traceback (most recent call last):
File โ€œtest.pyโ€, line 46, in
print (s.args[0].extract(6,1,7,1))
File โ€œ/dasm/bin/u2py.pyโ€, line 163, in extract
return DynArray(super().extract(*args, **kwargs))
TypeError: function takes at most 3 arguments (4 given)
โ€˜โ€™โ€™
Does anyone knows how can I get the TM value in my for loop?
I apreciate your comments.
Regards,
DASM

Hi,

How can I extract TextMark value using u2py?

I got the values of a SVM with this sentence:
total = s.args[0].extract(6,1,7).dcount(u2py.TM)

But when I try to extract the info I got an error because the function only take 3 arguments:
for x in range(1,total):
print (s.args[0].extract(6,1,7,x))
โ€˜โ€™โ€™
Traceback (most recent call last):
File โ€œtest.pyโ€, line 46, in
print (s.args[0].extract(6,1,7,1))
File โ€œ/dasm/bin/u2py.pyโ€, line 163, in extract
return DynArray(super().extract(*args, **kwargs))
TypeError: function takes at most 3 arguments (4 given)
โ€˜โ€™โ€™
Does anyone knows how can I get the TM value in my for loop?
I apreciate your comments.
Regards,
DASM

There are a few ways, this works:
python> import u2py

python> rec = [ 1, 2, 3, 4, 5, [ [ โ€œs1โ€, โ€œs2โ€, โ€œs3โ€, โ€œs4โ€, โ€œs5โ€, โ€œs6โ€, [ โ€œs7t1โ€, โ€œs7t2โ€ ], โ€œs8โ€ ]], 7 ]

python> dyn = u2py.DynArray( rec )

python> dyn

<u2py.DynArray value=bโ€™1\\xfe2\\xfe3\\xfe4\\xfe5\\xfes1\\xfcs2\\xfcs3\\xfcs4\\xfcs5\\xfcs6\\xfcs7t1\\xfbs7t2\\xfcs8\\xfe7โ€™>

python> stuff = dyn.extract(6,1,7)

python> for each_text, delim in stuff:

โ€ฆ print(each_text)

โ€ฆ

s7t1

s7t2