汉语句子语法图

汉语句子语法图

python代码

import graphviz
import os
#os.environ["PATH"] += os.pathsep + r"D:\Software_install\graphviz-2.46.1\Graphviz\bin"
os.environ["Path"] += os.pathsep + r"D:\Software_install\graphviz-2.46.1\Graphviz\bin"

text4cn='''
digraph graph4cn {
    graph [label="汉语句子语法图" fontname="SimSun" charset="utf-8" 
    compound=true fontsize=11 bgcolor="black" rankdir=TB]
    node [fontname="SimSun" shape=box fontcolor="white" color="white"]
    edge [fontname="SimSun" fontcolor="white" color="white"]
    
    "语义类型" [label="" image="image\\semantic_type_4cn.png" style="dashed"]
    "谓词性词语" [label="" image="image\\verbal_words_4cn.png" style="dashed"] 
    "体词性词语(名词性词语)" [label="" image="image\\nominal_words_4cn.png" style="dashed"]
    "从句" [label="" image="image\\clauses_4cn.png" style="dashed"]
    "多层结构" [label="" image="image\\multilayer_structure_4cn.png" style="dashed"]
    
    "汉语句子成分" -> "主语"
    "主语" -> "主语的构成"
    "主语的构成" -> "体词性词语(名词性词语)"
    "主语的构成" -> "谓词性词语"
    "主语的构成" -> "从句"
    "主语" -> "语义类型"
    
    "汉语句子成分" -> "谓语"
    "谓语" -> "谓语的构成"
    "谓语的构成" -> "谓词性词语"
    "谓语的构成" -> "体词性词语(名词性词语)"
    "谓语" -> "语义类型"
    
    "汉语句子成分" -> "述语"
    "述语的构成" [label="" image="image\\descriptive_4cn.png" style="dashed"]
    "述语" -> "述语的构成"
        
    "汉语句子成分" -> "宾语"
    "宾语" -> "宾语的构成"
    "宾语的构成" -> "从句"
    "宾语" -> "语义类型"
    
    "注意" [label="" image="image\\attention_4cn.png" style="dashed"]
    
    "汉语句子成分" -> "定语"
    "定语的构成" [label="" image="image\\attribute_4cn.png" style="dashed"]
    "定语" -> "定语的构成"
    "定语" -> "语义类型"
    "定语" -> "多层结构"
    
    "汉语句子成分" -> "状语"
    "状语的构成" [label="" image="image\\adverbial_modifier_4cn.png" style="dashed"]
    "状语" -> "状语的构成"
    "状语" -> "语义类型"
    "状语" -> "多层结构"
    "状语" -> "从句"
    
    "定语与状语的区别" [label="" image="image\\difference_of_attribute_n_adverbial_modifier_4cn.png" style="dashed"]
    "定语" -> "定语与状语的区别"
    "状语" -> "定语与状语的区别"
    
    "汉语句子成分" -> "补语"
    "补语的构成" [label="" image="image\\complement_4cn.png" style="dashed"]
    "补语" -> "补语的构成"
    "补语" -> "语义类型"

    "补语与宾语的区别" [label="" image="image\\difference_of_complement_n_object_4cn.png" style="dashed"]
    "补语" -> "补语与宾语的区别"
    "宾语" -> "补语与宾语的区别"
    
    "汉语句子成分" -> "中心语"
    "center_4cn" [label="" image="image\\center_4cn.png" style="dashed"]
    "中心语" -> "center_4cn"
    
    "汉语句子成分" -> "独立语"
    "longly_4cn" [label="" image="image\\longly_4cn.png" style="dashed"]
    "独立语" -> "longly_4cn"
    
}
'''

dot = graphviz.Source(text4cn, format="svg")
dot.render(outfile="graph4cn.png")
#dot

结果

图片超过5M无法上传

参考文献

百度百科
https://fanyi.baidu.com/#zh/en/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值