fafnerzhang
  • NEW!
    NEW!  Connect Ideas Across Notes
    Save time and share insights. With Paragraph Citation, you can quote others’ work with source info built in. If someone cites your note, you’ll see a card showing where it’s used—bringing notes closer together.
    Got it
      • Create new note
      • Create a note from template
        • Sharing URL Link copied
        • /edit
        • View mode
          • Edit mode
          • View mode
          • Book mode
          • Slide mode
          Edit mode View mode Book mode Slide mode
        • Customize slides
        • Note Permission
        • Read
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Write
          • Only me
          • Signed-in users
          • Everyone
          Only me Signed-in users Everyone
        • Engagement control Commenting, Suggest edit, Emoji Reply
      • Invite by email
        Invitee

        This note has no invitees

      • Publish Note

        Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

        Your note will be visible on your profile and discoverable by anyone.
        Your note is now live.
        This note is visible on your profile and discoverable online.
        Everyone on the web can find and read all notes of this public team.

        Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

        Explore these features while you wait
        Complete general settings
        Bookmark and like published notes
        Write a few more notes
        Complete general settings
        Write a few more notes
        See published notes
        Unpublish note
        Please check the box to agree to the Community Guidelines.
        View profile
      • Commenting
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
        • Everyone
      • Suggest edit
        Permission
        Disabled Forbidden Owners Signed-in users Everyone
      • Enable
      • Permission
        • Forbidden
        • Owners
        • Signed-in users
      • Emoji Reply
      • Enable
      • Versions and GitHub Sync
      • Note settings
      • Note Insights New
      • Engagement control
      • Make a copy
      • Transfer ownership
      • Delete this note
      • Save as template
      • Insert from template
      • Import from
        • Dropbox
        • Google Drive
        • Gist
        • Clipboard
      • Export to
        • Dropbox
        • Google Drive
        • Gist
      • Download
        • Markdown
        • HTML
        • Raw HTML
    Menu Note settings Note Insights Versions and GitHub Sync Sharing URL Create Help
    Create Create new note Create a note from template
    Menu
    Options
    Engagement control Make a copy Transfer ownership Delete this note
    Import from
    Dropbox Google Drive Gist Clipboard
    Export to
    Dropbox Google Drive Gist
    Download
    Markdown HTML Raw HTML
    Back
    Sharing URL Link copied
    /edit
    View mode
    • Edit mode
    • View mode
    • Book mode
    • Slide mode
    Edit mode View mode Book mode Slide mode
    Customize slides
    Note Permission
    Read
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Write
    Only me
    • Only me
    • Signed-in users
    • Everyone
    Only me Signed-in users Everyone
    Engagement control Commenting, Suggest edit, Emoji Reply
  • Invite by email
    Invitee

    This note has no invitees

  • Publish Note

    Share your work with the world Congratulations! 🎉 Your note is out in the world Publish Note No publishing access yet

    Your note will be visible on your profile and discoverable by anyone.
    Your note is now live.
    This note is visible on your profile and discoverable online.
    Everyone on the web can find and read all notes of this public team.

    Your account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Your team account was recently created. Publishing will be available soon, allowing you to share notes on your public page and in search results.

    Explore these features while you wait
    Complete general settings
    Bookmark and like published notes
    Write a few more notes
    Complete general settings
    Write a few more notes
    See published notes
    Unpublish note
    Please check the box to agree to the Community Guidelines.
    View profile
    Engagement control
    Commenting
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    • Everyone
    Suggest edit
    Permission
    Disabled Forbidden Owners Signed-in users Everyone
    Enable
    Permission
    • Forbidden
    • Owners
    • Signed-in users
    Emoji Reply
    Enable
    Import from Dropbox Google Drive Gist Clipboard
       Owned this note    Owned this note      
    Published Linked with GitHub
    • Any changes
      Be notified of any changes
    • Mention me
      Be notified of mention me
    • Unsubscribe
    # 基於句法分析與主謂賓三元組的段落抽取規格書 在此段落抽取模組中,我們使用了LTP自然語言解析套件進行開發,說明文件可參閱LTP,主要使用了LTP套件中的詞性標註(pos),依存句法分析(dep),語義角色標註(srl),以下說明此模組的模組流程與元件細節。 ## 模組說明 先前經由tesseract與pdfminer從pdf與其他文件抽取出來的文本會有如表格,標頭,標題,頁首,頁尾,圖片說明…等,使用者不會想看到的東西,這些文本的共同特徵是幾乎都是沒有句子基本結構的短句/詞,因此我們設計此模組,經由套件的輔助抽取出句子的句型結構,並判斷是否有「主語,謂語,賓語」這三個元素存在句子結構中,假如有此句型結構,此段落即為有效段落,否則此段落將被過濾掉,以此達到過濾上述不想要文本的效果。 ## 段落抽取流程 ![](https://i.imgur.com/iZnKtzN.png) 如上圖所示,原始段落會先進入語義角色標註模組進行分析,如取出主謂賓的結構,即為有效段落,否則會進入依存句法分析模組進行解析,如取出主謂賓的結構,即為有效段落,否則此段落便為無效段落,接下來將詳細介紹各模組的主謂賓結構如何判斷。 ### 語義角色標註 - 主謂賓判斷 模組輸入定義如下 | 欄位 | 資料型態 | 說明 | | ---------- | -------- | ------------ | | inputs | String[] | 段落文字 | 範例輸入: `["他叫汤姆去拿外衣。"]` `["他叫汤姆去拿外衣。", "湯姆抓到了貓"]` 模組輸出定義如下 | 欄位 | 資料型態 | 說明 | | ---------- | -------- |:------------------------------ | | node | Tuple[] | 段落中分詞位置的主謂賓剖析結果 | | node[0] | Int | 此節點的段落分詞位置 | | node[1] | Tuple[] | 節點的主謂賓剖析結果 | | node[1][0] | String | 節點的句法關係 | | node[1][1] | Int | 分詞起始位置 | | node[1][2] | Int | 分詞結束位置 | 範例輸出: ``` [ [ (1, [('A0', 0, 0), ('A1', 2, 2), ('A2', 3, 5)]), # 叫 -> [A0: 他, A1: 汤姆, A2: 去拿外衣] (4, [('A0', 2, 2), ('A1', 5, 5)]) # 拿 -> [A0: 汤姆, A1: 外衣] ] ] ``` 主謂賓判斷規則: 1. 假設當前段落節點為node(x),node(x)[1]內的元素同時包含"A0", "A1",此段落即為有效段落 範例程式碼: ``` result = [] srl = ltp.srl([paragraph_1, paragraph_2, ...]) for pagraph in srl: is_valid = False for node in paragraph: relations = [] for relation in node[1]: if relation[0] in ['A0', 'A1']: relations.append(relation[0]) result.append(is_valid) ``` 說明: 段落LTP套件的語義角色標註(srl)後,會產出上述結構,A0代表此詞組為主語,A1代表此分詞為受詞,A2為間接受詞,**在此階段只要段落剖析結果出現A0與A1,即視為擁有主謂賓三元組。** ### 依存句法分析 - 主謂賓判斷 | 关系类型 | Tag | Description | Example | | ----- | --- | --------------------- | ---------------- | | 主谓关系 | SBV | subject-verb | 我送她一束花 (我 <– 送) | | 动宾关系 | VOB | 直接宾语,verb-object | 我送她一束花 (送 –> 花) | | 间宾关系 | IOB | 间接宾语,indirect-object | 我送她一束花 (送 –> 她) | | 前置宾语 | FOB | 前置宾语,fronting-object | 他什么书都读 (书 <– 读) | | 兼语 | DBL | double | 他请我吃饭 (请 –> 我) | | 定中关系 | ATT | attribute | 红苹果 (红 <– 苹果) | | 状中结构 | ADV | adverbial | 非常美丽 (非常 <– 美丽) | | 动补结构 | CMP | complement | 做完了作业 (做 –> 完) | | 并列关系 | COO | coordinate | 大山和大海 (大山 –> 大海) | | 介宾关系 | POB | preposition-object | 在贸易区内 (在 –> 内) | | 左附加关系 | LAD | left adjunct | 大山和大海 (和 <– 大海) | | 右附加关系 | RAD | right adjunct | 孩子们 (孩子 –> 们) | | 独立结构 | IS | independent structure | 两个单句在结构上彼此独立 | | 核心关系 | HED | head | 指整个句子的核心 | 以上為依存句法分析的標籤與對應關係 ```python seg, hidden = ltp.seg(["他叫汤姆去拿外衣。"]) dep = ltp.dep(hidden) # [['他', '叫', '汤姆', '去', '拿', '外衣', '。']] # [ # [ # (1, 2, 'SBV'), # (2, 0, 'HED'), # 叫 --|HED|--> ROOT # (3, 2, 'DBL'), # (4, 2, 'VOB'), # (5, 4, 'COO'), # (6, 5, 'VOB'), # (7, 2, 'WP') # ] # ] # # 他 (1, 2, 'SBV'), # 叫 (2, 0, 'HED'), # 湯姆 (3, 2, 'DBL'), # 去 (4, 2, 'VOB'), # 拿 (5, 4, 'COO'), # 外衣 (6, 5, 'VOB'), # 。 (7, 2, 'WP') ``` 段落經過LTP套件的依存句法分析(dep)後,會產出上述結構(單字位址, 根節點位置, 依存關係),我們以node(x)代表上述資訊,在此主要利用句法分析的標籤位置制定規則進行過濾,以下列出模組內使用到的規則: 1. 主動賓關係 ``` 湯姆 (1, 2, 'SBV') 抓到 (2, 0, 'HED') 了 (3, 2, 'RAD') 貓 (4, 2, 'VOB') ``` 以上例句中 node(抓到),同時是node(湯姆)與node(貓)的根節點,且node(湯姆)與node(抓到)為主謂關係(**SBV**),node(貓)與node(抓到)為動賓關係(**VOB**),因此此段落為有效段落。 2. 含有介賓關係的主謂動補關係 ``` 湯姆 (1, 2, 'SBV') 活躍 (2, 0, 'HED') 在 (3, 2, 'CMP') 米老鼠家 (4, 3, 'POB') ``` 以上例句中 node(活躍)同時是node(湯姆)與node(在)的根節點,且node(湯姆)與node(活躍)為主謂關係(**SBV**),node(在)與node(湯姆)為動補結構(**CMP**),同時node(在)與node(米老鼠家)為介賓關係(**POB**),因此此段落為有效段落。

    Import from clipboard

    Paste your markdown or webpage here...

    Advanced permission required

    Your current role can only read. Ask the system administrator to acquire write and comment permission.

    This team is disabled

    Sorry, this team is disabled. You can't edit this note.

    This note is locked

    Sorry, only owner can edit this note.

    Reach the limit

    Sorry, you've reached the max length this note can be.
    Please reduce the content or divide it to more notes, thank you!

    Import from Gist

    Import from Snippet

    or

    Export to Snippet

    Are you sure?

    Do you really want to delete this note?
    All users will lose their connection.

    Create a note from template

    Create a note from template

    Oops...
    This template has been removed or transferred.
    Upgrade
    All
    • All
    • Team
    No template.

    Create a template

    Upgrade

    Delete template

    Do you really want to delete this template?
    Turn this template into a regular note and keep its content, versions, and comments.

    This page need refresh

    You have an incompatible client version.
    Refresh to update.
    New version available!
    See releases notes here
    Refresh to enjoy new features.
    Your user state has changed.
    Refresh to load new user state.

    Sign in

    Forgot password
    or
    Sign in via Google Sign in via Facebook Sign in via X(Twitter) Sign in via GitHub Sign in via Dropbox Sign in with Wallet
    Wallet ( )
    Connect another wallet

    New to HackMD? Sign up

    By signing in, you agree to our terms of service.

    Help

    • English
    • 中文
    • Français
    • Deutsch
    • 日本語
    • Español
    • Català
    • Ελληνικά
    • Português
    • italiano
    • Türkçe
    • Русский
    • Nederlands
    • hrvatski jezik
    • język polski
    • Українська
    • हिन्दी
    • svenska
    • Esperanto
    • dansk

    Documents

    Help & Tutorial

    How to use Book mode

    Slide Example

    API Docs

    Edit in VSCode

    Install browser extension

    Contacts

    Feedback

    Discord

    Send us email

    Resources

    Releases

    Pricing

    Blog

    Policy

    Terms

    Privacy

    Cheatsheet

    Syntax Example Reference
    # Header Header 基本排版
    - Unordered List
    • Unordered List
    1. Ordered List
    1. Ordered List
    - [ ] Todo List
    • Todo List
    > Blockquote
    Blockquote
    **Bold font** Bold font
    *Italics font* Italics font
    ~~Strikethrough~~ Strikethrough
    19^th^ 19th
    H~2~O H2O
    ++Inserted text++ Inserted text
    ==Marked text== Marked text
    [link text](https:// "title") Link
    ![image alt](https:// "title") Image
    `Code` Code 在筆記中貼入程式碼
    ```javascript
    var i = 0;
    ```
    var i = 0;
    :smile: :smile: Emoji list
    {%youtube youtube_id %} Externals
    $L^aT_eX$ LaTeX
    :::info
    This is a alert area.
    :::

    This is a alert area.

    Versions and GitHub Sync
    Get Full History Access

    • Edit version name
    • Delete

    revision author avatar     named on  

    More Less

    Note content is identical to the latest version.
    Compare
      Choose a version
      No search result
      Version not found
    Sign in to link this note to GitHub
    Learn more
    This note is not linked with GitHub
     

    Feedback

    Submission failed, please try again

    Thanks for your support.

    On a scale of 0-10, how likely is it that you would recommend HackMD to your friends, family or business associates?

    Please give us some advice and help us improve HackMD.

     

    Thanks for your feedback

    Remove version name

    Do you want to remove this version name and description?

    Transfer ownership

    Transfer to
      Warning: is a public team. If you transfer note to this team, everyone on the web can find and read this note.

        Link with GitHub

        Please authorize HackMD on GitHub
        • Please sign in to GitHub and install the HackMD app on your GitHub repo.
        • HackMD links with GitHub through a GitHub App. You can choose which repo to install our App.
        Learn more  Sign in to GitHub

        Push the note to GitHub Push to GitHub Pull a file from GitHub

          Authorize again
         

        Choose which file to push to

        Select repo
        Refresh Authorize more repos
        Select branch
        Select file
        Select branch
        Choose version(s) to push
        • Save a new version and push
        • Choose from existing versions
        Include title and tags
        Available push count

        Pull from GitHub

         
        File from GitHub
        File from HackMD

        GitHub Link Settings

        File linked

        Linked by
        File path
        Last synced branch
        Available push count

        Danger Zone

        Unlink
        You will no longer receive notification when GitHub file changes after unlink.

        Syncing

        Push failed

        Push successfully