hestiaAI / Argonodes

JSON and its Argonodes!
https://hestiaai.github.io/Argonodes/
Other
3 stars 1 forks source link

Fix #19: Requested feature: Ability to collect all distinct values for a given node/path #41

Closed Amustache closed 2 years ago

Amustache commented 2 years ago

Alright @alexbfree I finished that feature, and I think I have a lot of things that I can improve (cf. #40 for instance), but it is already working. Before going further, would you kindly review it?

It works basically like this:

import json
from argonodes.nodes import Tree
from argonodes.applies import DistinctValues

json_data = ...  # Your raw data in JSON format
tree = Tree(json_data)

distinctvalues = DistinctValues()
tree.apply(distinctvalues)

or

distinctvalues = DistinctValues()
distinctvalues(tree)

And now, the distinctvalues object is holding every distinct values, can be used to explore and tag them, and can be expanded to add more sorcelery to the process.

More:

...  # previous steps
all_as_dict = distinctvalues.data
all_values = distinctvalues.get_found_values()
recurring_values_only = distinctvalues.get_recurring_values()
liste = distinctvalues.to_list()

Result example (distinctvalues.data):

{
   "$":{
      "description":"",
      "children":{
         "$.timelineObjects":1
      },
      "data":{}
   },
   "$.timelineObjects":{
      "description":"",
      "children":{
         "$.timelineObjects[*]":77
      },
      "data":{}
   },
   "$.timelineObjects[*].placeVisit.placeConfidence":{
      "description":"",
      "children":{},
      "data":{
         "HIGH_CONFIDENCE":19,
         "MEDIUM_CONFIDENCE":14,
         "LOW_CONFIDENCE":3,
         "USER_CONFIRMED":2
      }
   }
}

Before going further, I'll let you take a look!

alexbfree commented 2 years ago

i've just been testing this and couldn't get the import to work (I git cloned latest code)

Screenshot 2022-06-06 at 16 40 00

Amustache commented 2 years ago

@alexbfree

i've just been testing this and couldn't get the import to work (I git cloned latest code)

Screenshot 2022-06-06 at 16 40 00

from argonodes.appliers import DistinctValues *

I believe I forgot to edit the Wiki, it is now done.