mangiucugna / json_repair

A python module to repair invalid JSON, commonly used to parse the output of LLMs
https://pypi.org/project/json-repair/
MIT License
724 stars 41 forks source link

Special invalid json text: no response for a long time #40

Closed dhrbobluo closed 4 months ago

dhrbobluo commented 4 months ago
# test
gpt_content = """```json
{
    "Name": {
        "en": "Jia-Ming Li",
        "zh": "李家明",
        "de": "Jia-Ming Li"
    },
    "Contact": {
        "en": "Phone: 010-62788597\nFax: 010-62788597\nEmail: jmli@tsinghua.edu.cn",
        "zh": "电话:010-62788597\n传真:010-62788597\n电子邮件:jmli@tsinghua.edu.cn",
        "de": "Telefon: 010-62788597\nFax: 010-62788597\nE-Mail: jmli@tsinghua.edu.cn"
    },
    "Language Ability": {
        "en": [
            "English",
            "Chinese"
        ],
        "zh": [
            "英语",
            "中文"
        ],
        "de": [
            "Englisch",
            "Chinesisch"
        ]
    },
    "Province": {
        "en": "Beijing",
        "zh": "北京",
        "de": "Peking"
    },
    "Title": {
        "en": "Professor, Director of the Center for Atomic and Molecular Nanosciences, Tsinghua University",
        "zh": "教授,清华大学原子分子纳米科学研究中心主任",
        "de": "Professor, Direktor des Zentrums für atomare und molekulare Nanowissenschaften, Tsinghua-Universität"
    },
    "Academic Background & Achievements": {
        "en": [
            "1968 - B.S. in Engineering, Taiwan University",
            "1974 - Ph.D., University of Chicago",
            "Academician, Chinese Academy of Sciences"
        ],
        "zh": [
            "1968 - 台湾大学工程学士",
            "1974 - 美国芝加哥大学博士",
            "中国科学院院士"
        ],
        "de": [
            "1968 - B.S. in Ingenieurwissenschaften, Universität Taiwan",
            "1974 - Ph.D., Universität von Chicago",
            "Akademiker, Chinesische Akademie der Wissenschaften"
        ]
    },
    "Work Experience": {
        "en": [
            "1974 - Research Associate, Department of Physics, University of Chicago",
            "1975-1976 - Research Associate, Department of Physics and Astronomy, University of Pittsburgh",
            "1977-1978 - Senior Research Associate, Laser Energy Research Institute, University of Rochester",
            "1979-1982 - Associate Researcher, Institute of Physics, Chinese Academy of Sciences",
            "1983-Present - Researcher, Institute of Physics, Chinese Academy of Sciences",
            "1997-Present - Professor, Director of the Center for Atomic and Molecular Nanosciences, Department of Physics, Tsinghua University",
            "2003-Present - Professor, Department of Physics, Shanghai Jiao Tong University"
        ],
        "zh": [
            "1974 - 美国芝加哥大学物理系,研究助理",
            "1975-1976 - 美国匹兹堡大学物理天文系,研究助理",
            "1977-1978 - 美国罗彻斯特大学激光能量研究所,高级研究助理",
            "1979-1982 - 中国科学院物理研究所,副研究员",
            "1983至今 - 中国科学院物理研究所,研究员",
            "1997至今 - 清华大学物理系,原子分子纳米科学研究中心,教授,中心主任",
            "2003至今 - 上海交通大学物理系,教授"
        ],
        "de": [
            "1974 - Forschungsassistent, Abteilung für Physik, Universität Chicago",
            "1975-1976 - Forschungsassistent, Abteilung für Physik und Astronomie, Universität Pittsburgh",
            "1977-1978 - Senior Research Associate, Laser Energy Research Institute, Universität Rochester",
            "1979-1982 - Associate Researcher, Institut für Physik, Chinesische Akademie der Wissenschaften",
            "1983-heute - Forscher, Institut für Physik, Chinesische Akademie der Wissenschaften",
            "1997-heute - Professor, Direktor des Zentrums für atomare und molekulare Nanowissenschaften, Abteilung für Physik, Tsinghua-Universität",
            "2003-heute - Professor, Abteilung für Physik, Shanghai Jiao Tong Universität"
        ]
    },
    "Awards": {
        "en": [
            "1986 - Kastler Prize, International Centre for Theoretical Physics",
            "1990 - Second Class Prize, Natural Science, Chinese Academy of Sciences",
            "1991 - Outstanding Young Expert, Chinese Academy of Sciences",
            "1992 - Second Class Prize, Natural Science, Chinese Academy of Sciences",
            "1994 - Advanced Individual in Scientific Research under the 863 Program, Ministry of Science and Technology of China",
            "2001 - Advanced Individual Award for the 15th Anniversary of the 863 Program, Ministry of Science and Technology of China"
        ],
        "zh": [
            "1986 - 国际理论物理中心的 Kastler 奖",
            "1990 - 中国科学院自然科学奖二等奖",
            "1991 - 中国科学院有突出贡献的中青年专家",
            "1992 - 中国科学院自然科学奖二等奖",
            "1994 - 国防科学技术工业委员会评为“在863计划科研工作中的先进个人”",
            "2001 - 中国人民解放军总装备部和国家科技部授予“863计划十五周年先进个人奖”"
        ],
        "de": [
            "1986 - Kastler-Preis, Internationales Zentrum für Theoretische Physik",
            "1990 - Zweiter Klasse Preis, Naturwissenschaften, Chinesische Akademie der Wissenschaften",
            "1991 - Herausragender junger Experte, Chinesische Akademie der Wissenschaften",
            "1992 - Zweiter Klasse Preis, Naturwissenschaften, Chinesische Akademie der Wissenschaften",
            "1994 - Fortgeschrittene Einzelperson in der wissenschaftlichen Forschung unter dem 863-Programm, Ministerium für Wissenschaft und Technologie von China",
            "2001 - Fortgeschrittene Einzelperson Auszeichnung zum 15. Jahrestag des 863-Programms, Ministerium für Wissenschaft und Technologie von China"
        ]
    },
    "Areas of Focus": {
        "en": [
            "Atomic and molecular physics",
            "Computational physics",
            "Theoretical physics",
            "Nanoscience"
        ],
        "zh": [
            "原子分子物理",
            "计算物理",
            "理论物理",
            "纳米科学"
        ],
        "de": [
            "Atom- und Molekülphysik",
            "Computational Physik",
            "Theoretische Physik",
            "Nanowissenschaft"
        ]
    },
    "Keywords for Area of Focus": {
        "en": [
            "quantum theory", "computational methods", "atomic properties", "molecular systems", "clusters", "physical properties", "dynamics", "theoretical calculations", "nanotubes", "semiconductors"
        ],
        "zh": [
            "量子理论", "计算方法", "原子属性", "分子系统", "团簇", "物理属性", "动力学", "理论计算", "纳米管", "半导体"
        ],
        "de": [
            "Quantentheorie", "Berechnungsmethoden", "atomare Eigenschaften", "molekulare Systeme", "Cluster", "physikalische Eigenschaften", "Dynamik", "theoretische Berechnungen", "Nanoröhren", "Halbleiter"
        ]
    },
    "Publications": {
        "en": [
            {
                "Title": "Spectroscopy and Collision Theory: The Ar Absorption Spectrum",
                "Author": "C.M.Lee (Jia-Ming Li), K.T.Lu",
                "Publish Date": "1973-01-01"
            },

            {
                "Title": "Variational Calculation of R-matrix: Application to Ar Photoabsorption",
                "Author": "U.Fano, C.M.Lee (Jia-Ming Li)",
                "Publish Date": "1973-01-01"
            },

            {
                "Title": "Spectroscopy and Collision Theory: Atomic Eigenchannel Calculation by a Hartree-Fock-Roothaan Method",
                "Author": "C.M.Lee (Jia-Ming Li)",
                "Publish Date": "1974-01-01"
            },

            {
                "Title": "Spin Polarization and Angular Distribution of Photoelectrons in Jacob-Wick Helicity Formalism: Application to Autoionzation Resonances",
                "Author": "C.M.Lee (Jia-Ming Li)",
                "Publish Date": "1974-01-01"
            },

            {
                "Title": "Multichannel Photodetachment Theory",
                "Author": "C.M.Lee (Jia-Ming Li)",
                "Publish Date": "1975-01-01"
            },

            {
                "Title": "Comment on Structure near the Cut-off Of the Continuous X-ray Spectrum of Lanthanum",
                "Author": "C.M.Lee (Jia-Ming Li), R.H.Pratt",
                "Publish Date": "1975-01-01"
            },

            {
                "Title": "Radiative Capture of High-energy Electrons",
                "Author": "C.M.Lee (Jia-Ming Li), R.H.Pratt",
                "Publish Date": "1975-01-01"
            },

            {
                "Title": "The Electron Bremsstrahlung Spectrum 1---500 keV",
                "Author": "C.M.Lee (Jia-Ming Li), L.Kissel, R.H.Pratt, H.K.Tseng",
                "Publish Date": "1976-01-01"
            },

            {
                "Title": "Radiative Electron Capture by Mo Ions",
                "Author": "C.M.Lee (Jia-Ming Li), R.H.Pratt",
                "Publish Date": "1976-01-01"
            },

            {
                "Title": "Multichannel Dissociative Recombination Theory",
                "Author": "C.M.Lee (Jia-Ming Li)",
                "Publish Date": "1977-01-01"
            },

            {
                "Title": "Application of Low Energy Theorem in Electron Bremsstrahlung",
                "Author": "R.H.Pratt, C.M.Lee (Jia-Ming Li)",
                "Publish Date": "1977-01-01"
            },

            {
                "Title": "Bremsstrahlung Spectrum from Atomic Ions",
                "Author": "C.M.Lee (Jia-Ming Li), R.H.Pratt, H.K.Tseng",
                "Publish Date": "1977-01-01"
            },

            {
                "Title": "Radiative Charge Exchange Process in High-energy Ion-Atom Collisions",
                "Author": "C.M.Lee (Jia-Ming Li)",
                "Publish Date": "1978-01-01"
            },

            {
                "Title": "On the Dispresion Relation for Electron-Atom Scattering",
                "Author": "E.Gerjuoy, C.M.Lee (Jia-Ming Li)",
                "Publish Date": "1978-01-01"
            },

            {
                "Title": "Properties of Matter at High Pressures and Temperatures",
                "Author": "C.M.Lee (Jia-Ming Li), E.Thorsos",
                "Publish Date": "1978-01-01"
            },

            {
                "Title": "Bremsstrahlung Energy Spectra from Electrons of Kinetic Energy 1keV~$\le$~T~$\le$~200~keV incident on Neutral Atoms 2~$\le$~Z~$\le$~92",
                "Author": "R.H.Pratt,H.K.Tseng, C.M.Lee (Jia-Ming Li), L.kissel",
                "Publish Date": "1977-01-01"
            },

            {
                "Title": "Measurement of Compressed Core Density of Laser-imploded Target by X-ray Continuum Edge Shift",
                "Author": "C.M.Lee (Jia-Ming Li), A.Hauer",
                "Publish Date": "1978-01-01"
            },

            {
                "Title": "Electron Bremsstrahlung Angular Distribution in the 1---500 keV Energy Range",
                "Author": "H.K.Tseng, R.H.Pratt, C.M.Lee (Jia-Ming Li)",
                "Publish Date": "1979-01-01"
            },

            {
                "Title": "Explosive-pusher-type Laser Compression Experiment with Neon-filled Microballons",
                "Author": "B.Yaakobi, D.Steel, E.Thorsos, A.Hauer, B.Perry, S.Skupsky, J.Geiger, C.M.Lee (Jia-Ming Li), S.Letzring, J.Rizzo, T.Mukaiyama, E.Lazarus, G.Halpern, H.Deckman, J.Delettrez",
                "Publish Date": "1979-01-01"
            },

            {
                "Title": "Relativistic Random Phase Approximation",
                "Author": "W.R.Johoson, C.D.Lin, K.T.Cheng, C.M.Lee (Jia-Ming Li)",
                "Publish Date": "1980-01-01"
            },

            {
                "Title": "Electronic Impact Excitation of Li-Like Ions",
                "Author": "Jia-Ming Li",
                "Publish Date": "1980-01-01"
            },

            {
                "Title": "Scattering Theory and Specctroscopy: Relativistic Multichannel Quantum Defect Theory",
                "Author": "C.M.Lee (Jia-Ming Li), W.R.Johnson",
                "Publish Date": "1980-01-01"
            },

            {
                "Title": "Systematic Variation of Line-shift of K Radiation from Atomic Ions",
                "Author": "Jia-Ming Li, Zhong-Xin Zhao",
                "Publish Date": "1981-01-01"
            },

            {
                "Title": "Variation in L, M, N Inner-shell Electron Binding Energies of Rare-earth Elements in Valence Transition",
                "Author": "Jia-Ming Li, Zhong-Xin Zhao",
                "Publish Date": "1982-01-01"
            },

            {
                "Title": "Multichannel Inverse Dielectronic Recombination Theory",
                "Author": "Jia-Ming Li",
                "Publish Date": "1983-01-01"
            },

            {
                "Title": "Quantum Defect Theory:Rydberg States of Molecules NO",
                "Author": "Jia-Ming Li, Vo Ky Lan",
                "Publish Date": "1983-01-01"
            },

            {
                "Title": "Generalized Oscillator Strength Density",
                "Author": "Bo-Gang Tian, Jia-Ming Li",
                "Publish Date": "1984-01-01"
            },

            {
                "Title": "Theoretical Calculations of Atomic Two-photon Ionization Processes",
                "Author": "Ying-Jian Wu, Jia-Ming Li",
                "Publish Date": "1985-01-01"
            },

            {
                "Title": "Non-relativistic and Relativistic Atomic Configuration Theory: Excitation Energies and Radiative Transition Probabilities",
                "Author": "Zhong-Xin Zhao, Jia-Ming Li",
                "Publish Date": "1985-01-01"
            },

            {
                "Title": "Minima of Oscillator Strenth Densities for Excited Atoms",
                "Author": "Xiao-Ling Liang, Jia-Ming Li",
                "Publish Date": "1985-01-01"
            },

            {
                "Title": "Scaling Relation of Generlized Oscillator Strength Densities along Isoelectronic Sequence",
                "Author": "Xiao-Chuan Pan, Jia-Ming Li",
                "Publish Date": "1985-01-01"
            },

            {
                "Title": "Eletronic Structure of Atomic Ions With the 4f electrons",
                "Author": "Zhong-Xin Zhao, Jia-Ming Li",
                "Publish Date": "1985-01-01"
            },

            {
                "Title": "Ionization Channels of Superexcited Molecules",
                "Author": "Xiao-Ling Liang, Xiao-Chuan Pan, Jia-Ming Li",
                "Publish Date": "1985-01-01"
            },

            {
                "Title": "Progress Report on Quantum Defect Theory: Dynamics of Excited Atoms and Molecules",
                "Author": "Jia-Ming Li",
                "Publish Date": "1986-01-01"
            },

            {
                "Title": "Eletronic Impact Excitation Cross Sections and Rates: I Spin Allowed Excitation Processes",
                "Author": "Bo-Gang Tian ,Jia-Ming Li",
                "Publish Date": "1986-01-01"
            },

            {
                "Title": "Current Topic in Atomic Physics: Studies on Excited Atoms and Molecules",
                "Author": "Jia-Ming Li",
                "Publish Date": "1986-01-01"
            },

            {
                "Title":"""

decoded_object = json_repair.repair_json(gpt_content, return_objects=True, logging=True)

print(decoded_object)

It doesn't work, no response for a long time.

dhrbobluo commented 4 months ago

Resovled, thanks!