CS224N 2019年课程 第三次作业复现

1.代码

2019-CS224n-Assignment3 | 全栈说​​​​​​​2

2.原始数据介绍

Stanford CoreNLP依存关系分析、词性标注及句子主语分析(使用Python) 超详细截图手把手教学,新手友好_Vincent(Hao Li)的博客-CSDN博客_stanfordcorenlp 依存三元组

word

pos  词性

head 

label  语法关系

head 指向word 构成label pos是word的词性

pos 共45个不同取值 词性

{'RBS', 'EX', 'VBP', ':', 'RP', 'IN', 'NNS', 'WRB', 'CC', 'POS', '#', 'FW', 'SYM', 'PRP', '-LRB-', '.', 'VB', 'NN', 'WP$', 'DT', 'NNP', 'VBN', 'NNPS', 'RB', 'JJS', 'CD', ',', 'VBG', 'MD', 'PDT', "''", 'UH', 'VBZ', 'WP', 'RBR', 'WDT', 'PRP$', 'VBD', 'JJ', 'LS', '-RRB-', '``', 'JJR', '$', 'TO'}

[':', '#', 'LRB', '.', ',', "''", 'RRB', '``', '$']不在列表中 其他都在

标记 含义 例子
CC 连词 and,or,but,if,while,although
CD 数词 twenty-four,fourth,1991,14:24
DT 限定词 the,a,some,most,every,no
EX 存在量词 there,there’s
FW 外来词 dolce,ersatz,esprit,quo,maitre
IN 介词连词 on,of,at,with,by,into,under
JJ 形容词 new,good,high,special,big,local
JJR 比较级词语 bleaker,braver,breezier,briefer,brighter,brisker
JJS 最高级词语 calmest,cheapest,choicest,classiest,cleanest,clearest
LS 标记 A,A.
MD 情态动词 can,cannot,could,couldn’t
NN 名词 year,home,
NNS 名词复数 undergraduates
NNP 专有名词 Alison,Africa,April,Washington
NNPS 专有名词复数 Americans,Americas
PDT 前限定词 all,both
POS 所有格标记 ’  ‘s
PRP 人称代词 hers  herself
PRP$ 所有格 her his
RB 副词 occasionally unabatingly
RBR 副词比较级 further  gloomier
RBS 副词最高级 best biggest
RP 虚词 aboard about
SYM 符号
TO 词to to
UH 感叹词 Goodbye  Goody
VB 动词 ask
VBD 动词过去式 dipped pleaded
VBG 动词现在分词 telegraphing stirring
VBN 动词过去分词 multihulled dilapidated
VBP 动词现在式非第三人称时态 predominate wrap
VBZ 动词现在式第三人称时态 bases reconstructs
WDT Wh限定词 who,which,when,what,where,how
WP WH代词 that what whatever
WP$ WH代词所有格 whose
WRB WH副词

(b)label的不同取值有39个 分别是

{'dep', 'root', 'nummod', 'advmod', 'nmod', 'expl', 'acl:relcl', 'nmod:tmod', 'acl', 'cop', 'discourse', 'iobj', 'nmod:npmod', 'cc:preconj', 'aux', 'ccomp', 'punct', 'advcl', 'mwe', 'csubj', 'parataxis', 'nsubj', 'conj', 'compound:prt', 'nsubjpass', 'neg', 'nmod:poss', 'mark', 'compound', 'xcomp', 'det', 'appos', 'det:predet', 'amod', 'auxpass', 'case', 'csubjpass', 'dobj', 'cc'}

其中 'mwe', 'dobj' 不在以下列表中

英语句法依存关系_喵吹吹风的博客-CSDN博客_依存句法分析 英文

​​​​​​​

 3.代码部分详解

Neural Transition-Based Dependency Parsing - 简书

 debug = True
    # debug = False

    assert(torch.__version__ == "1.0.0"),  "Please install torch version 1.0.0"

    print(80 * "=")
    print("INITIALIZING")
    print(80 * "=")
    parser, embeddings, train_data, dev_data, test_data = load_and_preprocess_data(debug)
def load_and_preprocess_data(reduced=True):
    config = Config()

    print("Loading data...",)
    start = time.time()
    #read_conll 讲原文件中的1 4 6 7 单词(word)  词性(pos)  依赖关系(head)  句法关系(label)按照字典放在一个list中  list中每一个元素是一句话中的4列
    #遇到空行  就是新的一句话
    train_set = read_conll(os.path.join(config.data_path, config.train_file),
                           lowercase=config.lowercase)
    #39832
    dev_set = read_conll(os.path.join(config.data_path, config.dev_file),
                         lowercase=config.lowercase)
    #1700
    test_set = read_conll(os.path.join(config.data_path, config.test_file),
             
  • 1
    点赞
  • 1
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值