Code Monkey home page Code Monkey logo

Comments (5)

abaranovskis-redsamurai avatar abaranovskis-redsamurai commented on July 28, 2024

This is how Streamlit (the framework I'm using for UI) makes a server call. Moving between tabs or selecting another annotation will reload the UI, and changes are lost. I recommend pressing Save, before going to another tab or selecting annotation. Save will store your changes in JSON so they will not be lost. Maybe I should add auto-save functionality.

Yes, your suggestion makes sense, I was thinking about this too. This is on my list of enhancements. Also, I plan to add more automation in the future, for example, some of the fields will be pre-populated with the labels (using OpenAI API).

from sparrow.

dani-lu avatar dani-lu commented on July 28, 2024

I forgot to mentioned this, yes I saved multiple times under the ordering window to be sure that the groupings where saved and it keeps doing this behavior. Thats why I think its an issue, but I don't know if its just happening to me or to everybody, I changed the exporting function for it to group rows when a group finishes with "Items", like: Fees_Items, or Credits_Items, and so on, so that you don't have to create a group for each row like Item_1, Item_2, etc. But I don't know if this is creating the behavior I explained before, this is the function I changed, and I didn't change anything else:

 def export_labels(self, model):
        path_from = os.path.join("docs/json/")
        path_to = os.path.join("docs/json/key/")

        files = [f for f in os.listdir(path_from) if not f.startswith('.')]
        for file in files:
            path = os.path.join(path_from, file)
            if os.path.isfile(path):
                with open(path, "r") as f:
                    data = json.load(f)
                    words = data['words']

                    keys = {}

                    key_value_list = [[word['label'], word['value']] for word in words]
                    labels = set([word['label'] for word in words])
                    groups = set([label.split(':')[0] for label in labels])   
                    
                    result = {}
                    

                    for group in groups:
                        result[group] = []

                    for key, value in key_value_list:
                        category, subkey = key.split(':')
                        if category in result:
                            result[category].append((subkey, value))  
                            
                    label_dict = {}

                    for group in groups:
                        for label in labels:
                            if label.startswith(group + ':'):
                                label_dict[label.split(':')[1]] = group
                                
                    for group in groups: 
                        if 'Items' in group:
                            keys[group] = []
                            count = 0
                            item = {}
                            for element in result[group]:
                                for label in labels:
                                    if (label.split(':')[0] == group) and (element[0] == label.split(':')[1]):
                                        count =count+1
                                        item[element[0]] = element[1]
                                    if count == len([label.split(':')[1] for label in labels if label.startswith(group + ':')]):
                                        count=0
                                        keys[group].append(item)
                                        item = {}
                                        
                        else:
                            keys[group] = {}
                            for word in words:
                                for label in label_dict:
                                    if label_dict[word['label'].split(':')[1]] == group:
                                        keys[group][word['label'].split(':')[1]] = word['value']
                    
                    if keys != {}:
                        path = os.path.join(path_to, file)
                        with open(path, "w") as f:
                            json.dump(keys, f, indent=2)

So this function what it does is just appending an item to the groups that has "Items" in their name, and if they don't have, then it does the normal behavior and it just works if all the fields are labeled and grouped, so I don't see how this could affect what I just described above.

Thanks so much!

from sparrow.

abaranovskis-redsamurai avatar abaranovskis-redsamurai commented on July 28, 2024

Our team which does data annotation didnt faced the issue you describe. So, may be it is related to your change. Could you revert your change and try?

from sparrow.

dani-lu avatar dani-lu commented on July 28, 2024

Yes, it's because of the change in this function. I don't really get why this function has anything to do with setting up all the groups, but I'll take a closer look at it. Thanks so much!

from sparrow.

abaranovskis-redsamurai avatar abaranovskis-redsamurai commented on July 28, 2024

Thanks for letting me know.

from sparrow.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.