SDP_LSTM 数据分析

# -*- codeing = utf-8 -*-
# @Time : 2021/8/17 11:13

import matplotlib.pyplot as plt
import numpy as np

pos_tag_vab=[]#词性标注字典
for line in open(file='D:\\pythonProject1\\CNN\\Relation-Classification-using-Bidirectional-LSTM-Tree-master\\data\\pos_tags.txt'):
    pos_tag_vab.append(line.strip())
print(pos_tag_vab)
depend_vab=[]#依存字典
for line in open(file='D:\\pythonProject1\\CNN\\Relation-Classification-using-Bidirectional-LSTM-Tree-master\\data\\dependency_types.txt'):
    depend_vab.append(line.strip())
relation_vab=[]#关系字典
for line in open(file='D:\\pythonProject1\\CNN\\Relation-Classification-using-Bidirectional-LSTM-Tree-master\\data\\relation_types.txt'):
    relation_vab.append(line.strip())
print(depend_vab,'\n',relation_vab)

import _pickle as pickle
import nltk
#加载语料资源
f = open('D:\\pythonProject1\\CNN\\Relation-Classification-using-Bidirectional-LSTM-Tree-master\\data\\train_pathsv3', 'rb')
words_seq, deps_seq, pos_tags_seq, word_path1, word_path2, dep_path1, dep_path2, pos_tags_path1, pos_tags_path2, pos_path1, pos_path2, childs_path1, childs_path2 = pickle.load(f)
# print(pos_tags_seq)
f.close()

relations = []
for line in open('D:\\pythonProject1\\CNN\\Relation-Classification-using-Bidirectional-LSTM-Tree-master\\data\\train_relationsv3.txt'):
    relations.append(line.strip().split()[1])
#频繁关系
most_commen_rels=nltk.FreqDist(relations).most_common( )
print(most_commen_rels)

#语料中的频繁词性
for i,pos in enumerate(pos_tags_seq):#pos_tag_seq由列表组成的
    if i==0:
        freq_pos=nltk.FreqDist(pos)
        print(freq_pos)
    else:
        freq_pos+=nltk.FreqDist(pos)
        # print(freq_pos)
most_commen_pos=freq_pos.most_common()
print(most_commen_pos)


for i,dep in enumerate(deps_seq):
    if i==0:
        freq_deps=nltk.FreqDist(dep)
    else:
        freq_deps+=nltk.FreqDist(dep)
# print(freq_deps)
most_commen_deps=freq_deps.most_common()
print(most_commen_deps)


deps=[]
freq_deps=[]
for i ,v in most_commen_deps[:25]:
    deps.append(i)
    freq_deps.append(v)
print(deps)
print(freq_deps)

indexes = np.arange(len(freq_deps))

# plt.bar(x=indexes,height=freq_deps,width=0.5,align='center',alpha=0.5,color='b')
# plt.xticks(indexes,deps,rotation='vertical')
width = 5
plt.title('依存句法')
plt.bar(indexes, freq_deps, align='center', alpha=0.5,color='g')
plt.xticks(indexes, deps, rotation='vertical')
plt.show()
print("Dependency Type :",depend_vab)



pos_tag=[]
freq_pos_tags=[]
for i,v in most_commen_pos[:25]:
    pos_tag.append(i)
    freq_pos_tags.append(v)

index=np.arange(len(pos_tag))
plt.bar(x=index,height=freq_pos_tags,width=0.8,align='center',color='g')
plt.xticks(index,pos_tag,rotation='vertical')
print('词性标注全部类型',pos_tag_vab)
plt.show()



rel_tag=[]
freq_rel_tag=[]
for i,v in most_commen_rels[:25]:
    rel_tag.append(i)
    freq_rel_tag.append(v)
index=np.arange(len(rel_tag))
plt.bar(index,height=freq_rel_tag,color='y')
plt.xticks(index,rel_tag,rotation='vertical')
print('关系类型',relation_vab)
plt.show()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
根据您提供的代码,我进行了修改并解释了相应的部分: ```c typedef struct pjmedia_sdp_rtcp_attr { unsigned port; pj_str_t net_type; pj_str_t addr_type; pj_str_t addr; } pjmedia_sdp_rtcp_attr; PJ_DECL(pj_status_t) pjmedia_sdp_attr_get_rtcp(const pjmedia_sdp_attr *attr, pjmedia_sdp_rtcp_attr *rtcp); PJ_DECL(pjmedia_sdp_attr*) pjmedia_sdp_attr_create_rtcp(pj_pool_t *pool, const pj_sockaddr *a); unsigned count = 7; // 属性数组中属性的数量 pjmedia_sdp_attr* attr_array[7]; // 属性数组 pjmedia_sdp_rtcp_attr rtcp_attr; // 要删除的 RTCP 属性实例 // 使用合适的方式为 attr_array 和 rtcp_attr 赋值 // 调用函数进行属性删除 pj_status_t status = PJ_ENOTFOUND; // 初始化为找不到属性,以防删除前没有匹配的属性 for (unsigned i = 0; i < count; i++) { pjmedia_sdp_rtcp_attr rtcp; if (pjmedia_sdp_attr_get_rtcp(attr_array[i], &rtcp) == PJ_SUCCESS) { // 找到 RTCP 属性 if (strcmp(rtcp.addr_type.ptr, "rtp") == 0) { // 删除 RTCP 属性 status = pjmedia_sdp_attr_remove(&count, attr_array, attr_array[i]); break; } } } if (status == PJ_SUCCESS) { // 属性删除成功 printf("RTCP attribute removed successfully.\n"); } else if (status == PJ_ENOTFOUND) { // 找不到要删除的 RTCP 属性 printf("RTCP attribute not found.\n"); } else { // 其他错误状态 printf("Error removing RTCP attribute.\n"); } ``` 在上述示例中,我们遍历属性数组中的每个属性,并将其传递给 `pjmedia_sdp_attr_get_rtcp` 函数来获取相关的 RTCP 属性信息。然后,我们检查获取到的 RTCP 属性的地址类型是否为 "rtp",如果是,则调用 `pjmedia_sdp_attr_remove` 函数删除该属性。请根据实际需求进行适当修改。 希望这可以帮助您!如果还有其他问题,请随时提问。
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

YingJingh

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

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

余额充值