Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Support segmented inputs for ddparser #1351

Merged
merged 8 commits into from
Dec 9, 2021
Merged

Support segmented inputs for ddparser #1351

merged 8 commits into from
Dec 9, 2021

Conversation

linjieccc
Copy link
Contributor

@linjieccc linjieccc commented Nov 23, 2021

PR types

New features

PR changes

APIs

Description

Support segmented inputs for ddparser:

ddp = Taskflow("dependency_parsing")
ddp.from_segments([['9月9日', '上午', '纳达尔', '在', '亚瑟·阿什球场', '击败', '俄罗斯', '球员', '梅德韦杰夫']])
# [{'word': ['9月9日', '上午', '纳达尔', '在', '亚瑟·阿什球场', '击败', '俄罗斯', '球员', '梅德韦杰夫'], 'head': [2, 6, 6, 5, 6, 0, 8, 9, 6], 'deprel': ['ATT', 'ADV', 'SBV', 'MT', 'ADV', 'HED', 'ATT', 'ATT', 'VOB']}]

@@ -141,6 +141,11 @@ ddp("9月9日上午纳达尔在亚瑟·阿什球场击败俄罗斯球员梅德
ddp = Taskflow("dependency_parsing", model="ddparser-ernie-1.0")
ddp("9月9日上午纳达尔在亚瑟·阿什球场击败俄罗斯球员梅德韦杰夫")
>>> [{'word': ['9月9日', '上午', '纳达尔', '在', '亚瑟·阿什球场', '击败', '俄罗斯', '球员', '梅德韦杰夫'], 'head': [2, 6, 6, 5, 6, 0, 8, 9, 6], 'deprel': ['ATT', 'ADV', 'SBV', 'MT', 'ADV', 'HED', 'ATT', 'ATT', 'VOB']}]

# 已分词方式
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已分词输入
我建议对这块的功能,采用文字(譬如API说明)+code block方式来呈现。
不要用整大块code block然后通过注释的方式来呈现,反而不够清晰

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

已修改

@wawltor wawltor closed this Nov 24, 2021
@wawltor wawltor reopened this Nov 24, 2021
@wawltor
Copy link
Collaborator

wawltor commented Nov 24, 2021

这里其实建议不要对forward函数进行特别多的处理,建议的话是在这个Task上新增一个接口来适配这个任务
forward函数就是告诉用户输入原文即可

ddp = Taskflow("dependency_parsing")
ddp.from_segments([['9月9日', '上午', '纳达尔', '在', '亚瑟·阿什球场', '击败', '俄罗斯', '球员', '梅德韦杰夫']])

@linjieccc
Copy link
Contributor Author

linjieccc commented Nov 25, 2021

这里其实建议不要对forward函数进行特别多的处理,建议的话是在这个Task上新增一个接口来适配这个任务 forward函数就是告诉用户输入原文即可

ddp = Taskflow("dependency_parsing") ddp.from_segments([['9月9日', '上午', '纳达尔', '在', '亚瑟·阿什球场', '击败', '俄罗斯', '球员', '梅德韦杰夫']])

@wawltor 已修改

@ZeyuChen ZeyuChen added the taskflow Taskflow label Dec 4, 2021
ddp = Taskflow("dependency_parsing", model="ddparser-ernie-1.0")
ddp("9月9日上午纳达尔在亚瑟·阿什球场击败俄罗斯球员梅德韦杰夫")
>>> [{'word': ['9月9日', '上午', '纳达尔', '在', '亚瑟·阿什球场', '击败', '俄罗斯', '球员', '梅德韦杰夫'], 'head': [2, 6, 6, 5, 6, 0, 8, 9, 6], 'deprel': ['ATT', 'ADV', 'SBV', 'MT', 'ADV', 'HED', 'ATT', 'ATT', 'VOB']}]
```

#### 依存关系可视化
- 已分词输入:
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

使用分词结果来输入:

Copy link
Collaborator

@wawltor wawltor left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM

@linjieccc linjieccc merged commit e27ac6a into PaddlePaddle:develop Dec 9, 2021
@linjieccc linjieccc deleted the up_ddparser branch December 9, 2021 09:28
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
taskflow Taskflow
Projects
None yet
Development

Successfully merging this pull request may close these issues.

[Feture Request]Taskflow dependency parsing task 追加已分词后解析语法树能力
3 participants