segno
segno copied to clipboard
Can't observe support for mixed modes
According to the feature comparison table, segno is supposed to support mixing modes, and documentation further specifies that qr.mode is supposed to return None if mixed modes are used. However, I am unable to find any documented API for manually specifying the segmentation, and I can not observe any automatic segmentation either.
>>> qr = segno.make('THE SQUARE ROOT OF 2 IS 1.41421356237309504880168872420969807856967187537694807317667973799')
>>> qr.mode
'alphanumeric'
>>> qr.designator
'4-L'
Optimal solution would be version 3, with two segments: alphanumeric and numeric.
Thanks for bringing up this issue. Segno supports multiple modes but does optimize the input yet.
>>> qr = segno.make(['THE SQUARE ROOT OF 2 IS 1', '.', '41421356237309504880168872420969807856967187537694807317667973799'])
>>> qr.mode
>>> qr.designator
'3-L'
Result:
>>> qr = segno.make(['THE SQUARE ROOT OF 2 IS 1.', '41421356237309504880168872420969807856967187537694807317667973799'])
>>> qr.mode
>>> qr.designator
'3-L'
Result:
I agree that Segno should recognize the modes and divide the content accordingly, see also #25.
Ah, thanks, that is fair enough. In that case I would redirect this issue to be against incomplete documentation. It would be helpful if it would be mentioned there that manual segmentation is supported by passing an iterable as content, in addition to the listed str, int and bytes.
https://segno.readthedocs.io/en/stable/api.html#segno.make.params.content
@heuer , currently users can not pass mode in str type for different segments. For example, this is invalid input
>>> qr=segno.make([('abcabcabc', 'byte'), ('123123123', 'numeric')])
I have to write
>>> qr=segno.make([('abcabcabc', 4), ('123123123', 1)])
@neycyanshi, sorry for the late response. You're right. The idea was that the user provides an iterable of chunks and Segno detects the "type" of the chunk automatically. I am not happy with the current solution, though. IMO it would be much better if the user provides the content "as it is" and Segno divides the content into optimal chunks, see #25
Yes, it is better to optimize chunks. Are you working on it? I'd like to help if you are busy now.