I'm currently working to build chatbot for car faults using car symptoms (Smell, Hear , Feel etc.) and target(title in this .json)using decision tree.
The symptoms i got was in .json file includes nested keys leads to targets, and i want to use this .json file for decision tree used in python.
(For ex: Smell contains multiple symptoms (Smell -> (burning oil)Smell ->("Gasoline"which is attached below as an ex) (Hear contains multiple symptoms as well)......etc.
Long story short. my goal is to make decision tree for All symptoms(Smell,hear,Feel)
i tried to flatten the code but it flatted into 1 row by using json.normalize, i tried 'pd.json_normalize' but it gaves only 1 row. i tried too to loop 'pd.json_normalize' but it was desrible resultss.
also i found here which is similar to my case but unfortunetely as im new in python i can't understand the answer to convert it. any help? here is a sample of the code
{
"childWebPageList" : [
{
"title" : "If you're not sure what the problem is, start by describing the symptoms:",
"childWebPageList" : [
{
"title" : "",
"aidPair" : {
"key" : "Smell - I smell it (i.e. gasoline, rotten eggs, or burning oil)",
"val" : "388"
},
"childWebPageList" : [
{
"title" : "",
"aidPair" : {
"key" : "Gasoline",
"val" : "165"
},
"childWebPageList" : [
{
"title" : "When does the odor occur?",
"aidPair" : {
"key" : "aid",
"val" : "165"
},
"childWebPageList" : [
{
"title" : "",
"aidPair" : {
"key" : "All the time",
"val" : "180"
},
"childWebPageList" : [
{
"title" : "Can you pinpoint where the odor is coming from?",
"aidPair" : {
"key" : "aid",
"val" : "180"
},
"childWebPageList" : [
{
"title" : "",
"aidPair" : {
"key" : "Engine Compartment",
"val" : "24"
},
"childWebPageList" : [ ],
"problemList" : [
{
"title" : "Fuel Rail/Fuel Pressure Regulator Leak",
"description" : "Fuel Leaks within the fuel pressure regualator unit and a dirty fuel system will cause the fuel pressure regulator to fail.",
"inspectionList" : [
"1) Open the hood and locate the fuel pressure regulator. The fuel pressure regulator is commonly found on the fuel rail, which is mounted on top of the engine around the same location as the intake manifold.",
"2) Disable the fuel pump and relieve the fuel system pressure.",
"3) Disconnect the fuel line and install a fuel pressure gauge. Reconnect the fuse to the fuel pump.",
"4) Start the engine and check for leakage around the gauge connections.",
"5) Disconnect the vacuum hose from the fuel pressure regulator and attach a hand held vacuum pump to the port on the fuel pressure regulator.",
"6) Read the fuel pressure gauge when a vacuum is applied to the fuel pressure regulator and when no vacuum is applied. The fuel pressure should decrease as vacuum increases, and increase as vacuum decreases. Compare your readings with the values in the vehicle’s specifications.",
"7) Reconnect the vacuum hose to the regulator and check the fuel pressure at idle, comparing your reading with the value in the vehicle’s specifications. Disconnect the vacuum hose and watch the gauge – the pressure should jump up as soon as the hose is disconnected. If it doesn’t, proceed to step 8.",
"8) If the fuel pressure is low, pinch the fuel return line shut and watch the gauge. If the pressure doesn’t rise, the fuel pump is defective or there is a restriction in the fuel feed line. If the pressure rises sharply, replace the fuel pressure regulator.",
"9) If the fuel pressure is too high, turn the engine off. Disconnect the fuel return line and blow through it to check for a blockage. If there is no blockage, replace the fuel pressure regulator.",
"10) Connect a vacuum gauge to the fuel pressure regulator vacuum hose. Start the engine and check for vacuum. If there isn’t a vacuum present, check for a clogged hose or vacuum port. If the amount of vacuum is adequate, replace the fuel pressure regulator."
]
},
{
"title" : "Fuel Injector Leak",
"description" : "Clogged fuel injectors are caused by dirt in the fuel system. If dirt gets past the fuel filter and into the fuel injectors, they will become plugged and prevent fuel from reaching the combustion chamber.",
"inspectionList" : [
"1) Open the hood and locate the fuel injector rails.",
"2) The fuel injectors are commonly located above the engine block and on the sides. They can be found near the intake manifold or within the same proximity as the spark plugs.",
"3) Hook up the fuel injector tester to the Schrader valve on the fuel line.",
"4) Turn the key to the ON position and allow the fuel pump to build pressure in the system. Do NOT start the vehicle. You will hear the fuel pump run and prime the system.",
"5) Press the “test” button on the fuel injector tester and allow it to pulsate the fuel injector for the needed amount of time.",
"6) Repeat this for each fuel injector and write down the pressure indicated by the tester for each.",
"7) After all the fuel injectors have been tested and you have pressure readings, find the average reading for all the fuel injectors. Add all the readings together, then divide by the number of fuel injectors in the engine.",
"8) Compare each original fuel injector PSI reading to the average PSI reading. If you have fuel injectors that are above OR below 1.5 PSI of the average, they are faulty and will need replacement."
]
}
]
},
{
"title" : "",
"aidPair" : {
"key" : "Rear of the Vehicle",
"val" : "25"
},
"childWebPageList" : [ ],
"problemList" : [
{
"title" : "Fuel Tank Leak",
"description" : "Some fuel tanks are made out of metal and are susceptible to rust and corrosion. They can develop soft spots and begin to leak.",
"inspectionList" : [
"1) Locate the vehicle’s fuel tank. In most vehicles, the fuel tank is located underneath the rear of the vehicle. It is best identified as a large container strapped to the bottom of the vehicle.",
"2) Once the fuel tank is located, use a flashlight and inpsect the entire area underneath the unit. Check for moisture and fuel spots.",
"3) The fuel tank also has fuel lines that are routed to the top. Inspect the fuel lines and make sure they are not leaking.",
"4) If there are leaks suspected, it will be necessary to replace the entire fuel tank unit."
]
},
{
"title" : "Fuel Pump Assembly Failure",
"description" : "Fuel pump assemblies are constantly operating to supply the correct amount of fuel pressure to keep the vehicle running properly. Normal wear shortens the lifespan of the fuel pump assembly. The fuel keeps the fuel pump lubricated and cooled, so running a fuel pump with low or no gas and starving it from fluid may lead to overheating and eventually burn the fuel pump out.",
"inspectionList" : [
"1) Most late model vehicles use an electronic submersible fuel pump; this means it is located inside the fuel tank. The first step to take is remove the gas cap from the vehicle.",
"2) Always check all the fuel lines leading to the engine from the gas tank. Check the gas tank, fuel cap, fuel filter along with the clamps or clips holding the fuel lines in place. Fuel has a strong odor, which may help in pin pointing a fuel leak.",
"3) Next, have an assistant cycle the ignition. Cycling means having them turn the key to the \"ON\" position, which is the last click in the ignition before the vehicle start position.",
"4) While the ignition key is being cycled, listen closely near the gas filler, where the fuel cap was removed. A humming or hissing sound should be heard for about 2-4 seconds, then stop. This sound is the electronic fuel pump sending fuel to the engine. Every time the key is turned to the \"ON\" position a sound should be heard coming from the fuel pump.",
"5) If there is no audible sound coming from the fuel pump, check the fuel pump relay and wiring leading to the unit. Perform a Voltage test as well, which may determine if the pump has failed."
]
},
{
"title" : "Fuel Filter Leak",
"description" : "Fuel filters get dirty and clogged over time. Dirt in the tank, dirty fuel and the natural break down of the fuel lines can clog your fuel filter and obstruct the flow of fuel to your vehicle’s engine.",
"inspectionList" : [
"1) Open the hood and locate the fuel filter. In vehicles with fuel injection the fuel filter could be located near the tank. To locate the fuel filter follow the fuel line from the tank to the engine until you find the fuel filter.",
"2) Inspect the fuel filter to see if it is clogged.",
"3) Since the fuel filter case is not see-through, you will need to remove it from the fuel line and drain the fuel from the fuel filter into a container and inspect the condition of the fuel."
]
}
]
}
],
"problemList" : [ ]
}
],
"problemList" : [ ]
},
{
"title" : "",
"aidPair" : {
"key" : "Only when engine is running, idling.",
"val" : "181"
},
"childWebPageList" : [
{
"title" : "Can you pinpoint where the odor is coming from?",
"aidPair" : {
"key" : "aid",
"val" : "181"
},
"childWebPageList" : [
{
"title" : "",
"aidPair" : {
"key" : "Inside the vehicle when the heat or A/C is turned on.",
"val" : "54"
},
"childWebPageList" : [ ],
"problemList" : [
{
"title" : "Fuel Rail/Fuel Pressure Regulator Leak",
"description" : "Fuel Leaks within the fuel pressure regualator unit and a dirty fuel system will cause the fuel pressure regulator to fail.",
"inspectionList" : [
"1) Open the hood and locate the fuel pressure regulator. The fuel pressure regulator is commonly found on the fuel rail, which is mounted on top of the engine around the same location as the intake manifold.",
"2) Disable the fuel pump and relieve the fuel system pressure.",
"3) Disconnect the fuel line and install a fuel pressure gauge. Reconnect the fuse to the fuel pump.",
"4) Start the engine and check for leakage around the gauge connections.",
"5) Disconnect the vacuum hose from the fuel pressure regulator and attach a hand held vacuum pump to the port on the fuel pressure regulator."
]
},
{
"title" : "Fuel Injector Leak",
"description" : "Clogged fuel injectors are caused by dirt in the fuel system. If dirt gets past the fuel filter and into the fuel injectors, they will become plugged and prevent fuel from reaching the combustion chamber.",
"inspectionList" : [
"1) Open the hood and locate the fuel injector rails.",
"2) The fuel injectors are commonly located above the engine block and on the sides. They can be found near the intake manifold or within the same proximity as the spark plugs.",
"3) Hook up the fuel injector tester to the Schrader valve on the fuel line.",
"4) Turn the key to the ON position and allow the fuel pump to build pressure in the system. Do NOT start the vehicle. You will hear the fuel pump run and prime the system.",
"5) Press the “test” button on the fuel injector tester and allow it to pulsate the fuel injector for the needed amount of time.",
"6) Repeat this for each fuel injector and write down the pressure indicated by the tester for each.",
"7) After all the fuel injectors have been tested and you have pressure readings, find the average reading for all the fuel injectors. Add all the readings together, then divide by the number of fuel injectors in the engine.",
"8) Compare each original fuel injector PSI reading to the average PSI reading. If you have fuel injectors that are above OR below 1.5 PSI of the average, they are faulty and will need replacement."
]
}
]
},
{
"title" : "",
"aidPair" : {
"key" : "Only outside the vehicle.",
"val" : "55"
},
"childWebPageList" : [ ],
"problemList" : [
{
"title" : "Fuel Tank Leak",
"description" : "Some fuel tanks are made out of metal and are susceptible to rust and corrosion. They can develop soft spots and begin to leak.",
"inspectionList" : [
"1) Locate the vehicle’s fuel tank. In most vehicles, the fuel tank is located underneath the rear of the vehicle. It is best identified as a large container strapped to the bottom of the vehicle.",
"2) Once the fuel tank is located, use a flashlight and inpsect the entire area underneath the unit. Check for moisture and fuel spots.",
"3) The fuel tank also has fuel lines that are routed to the top. Inspect the fuel lines and make sure they are not leaking.",
"4) If there are leaks suspected, it will be necessary to replace the entire fuel tank unit."
]
},
{
"title" : "Fuel Pump Assembly Failure",
"description" : "Fuel pump assemblies are constantly operating to supply the correct amount of fuel pressure to keep the vehicle running properly. Normal wear shortens the lifespan of the fuel pump assembly. The fuel keeps the fuel pump lubricated and cooled, so running a fuel pump with low or no gas and starving it from fluid may lead to overheating and eventually burn the fuel pump out.",
"inspectionList" : [
"1) Most late model vehicles use an electronic submersible fuel pump; this means it is located inside the fuel tank. The first step to take is remove the gas cap from the vehicle.",
"2) Always check all the fuel lines leading to the engine from the gas tank. Check the gas tank, fuel cap, fuel filter along with the clamps or clips holding the fuel lines in place. Fuel has a strong odor, which may help in pin pointing a fuel leak.",
"3) Next, have an assistant cycle the ignition. Cycling means having them turn the key to the \"ON\" position, which is the last click in the ignition before the vehicle start position.",
]
},
{
"title" : "Fuel Filter Leak",
"description" : "Fuel filters get dirty and clogged over time. Dirt in the tank, dirty fuel and the natural break down of the fuel lines can clog your fuel filter and obstruct the flow of fuel to your vehicle’s engine.",
"inspectionList" : [
"1) Open the hood and locate the fuel filter. In vehicles with fuel injection the fuel filter could be located near the tank. To locate the fuel filter follow the fuel line from the tank to the engine until you find the fuel filter.",
"2) Inspect the fuel filter to see if it is clogged.",
"3) Since the fuel filter case is not see-through, you will need to remove it from the fuel line and drain the fuel from the fuel filter into a container and inspect the condition of the fuel."
]
}
]
}
],
"problemList" : [ ]
}
],
"problemList" : [ ]
}
],
"problemList" : [ ]
}
],
"problemList" : [ ]
},