-
-
Notifications
You must be signed in to change notification settings - Fork 40
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Label Linkbase instance should have get_label() function #10
Comments
I am working on building a dictionary that maps labels with concept's ids. This is my code so far: def get_label_dict(inst):
label_dict = {}
for lab_linkbase in inst.taxonomy.lab_linkbases:
for extended_link in lab_linkbase.extended_links:
for root_locator in extended_link.root_locators:
for children in root_locator.children:
for label in children.labels:
if label.label_type.split('/')[-1] != 'terseLabel':
continue
concept_id = root_locator.concept_id.split('_')[-1]
label_dict[concept_id] = label.text
return label_dict I want to be able to get the label for a given fact. I know this is not a great solution. Do you have any ideas on how to improve it? |
Yes, the current very deep structure of object instances is quite annoying. In the past I tried to fix this problem by creating a compile method that takes all information from the linkbases and directly associates it with the different concepts. While this is quite easy for the labels, i had issues recreating the hierachical structures of the presentation, definition and calculation linkbases which was the reason why i haven't published it. But in this case it would be sufficient to restrict oneself to the label linkbase for the time being. https://github.com/manusimidt/xbrl_parser/blob/bdc0abd3cbb8885eceabf9288b673d17e97bad5d/xbrl/taxonomy.py#L69-L92 |
But yes, the code you provided is currently the best and only method to get the labels. |
I think storing the label inside the concept would be great. I don't foresee any issues in having the information duplicated. My concerns would be:
Using the nested for loop I shared in my first comment I didn't notice any decrease in performance, I don't think speed is an issue as the bottleneck would not be here. And I don't think adding a new attribute in the concept is a memory issue either. My estimation is:
That is a worst-case scenario estimation of the memory cost. I think this is acceptable, but that is just my opinion. |
Yes, i also think that from a performance perspective this would not be a problem. If we could find a way to also "compile" the information from the relational linkbases and assign it directly to the various concepts, we might not even need the current linkbase structure. |
This change has not yet been sufficiently tested!
After cfd59c3 this is now working quite good for remote submissions. But I still run into some errors when parsing locally saved submissions. |
@manusimidt this is an old issue that is still open. Any chance this would get fixed? |
Would be handy if the label linkbase would return an array of possible labels given the ID of a concept.
The text was updated successfully, but these errors were encountered: