Table of Contents
回复内容:
Home Backend Development PHP Tutorial mmseg算法中的问题

mmseg算法中的问题

Jun 06, 2016 pm 08:28 PM
java php python

mmseg中复杂最大匹配算法没看明白,有人能用一个例子给我解释下吗?

回复内容:

mmseg中复杂最大匹配算法没看明白,有人能用一个例子给我解释下吗?

首先先定義 MMSEG 一個重要概念是 Chunk ,他是一個包含3個詞的詞塊。
MMSEG 算法是基於統計模型的,所以算法的規則也是來自於對語料庫的分析和歸納。

他有四大規則分別為:
規則 1 : 最大匹配 Maximum matching (取詞包含字數最多的chunk)
規則 2 : 最大平均詞彙長度 Largest average word length (取詞的平均字數最多的chunk)
規則 3 : 最小詞方差 Smallest variance of word lengths (取詞的方差最小的chunk)
規則 4 : 最大單字自由度 Largest sum of degree of morphemic freedom of one-character words

<code>    (取詞頻自由度最大的chunk, 也就是chunk中的詞的詞頻取對數後的和,)
</code>
Copy after login

舉的例子比較快了解:
我們用 MMSEG 上的例子 "研究生命起源",但首先先釐清一點,切 Chunk 通常跟你自己的語料庫(詞典)有很大關係,不一定會切出跟下面一樣的 Chunk。

  1. 研 |究 |生 (length = 3)

  2. 研 |究 |生命 (length = 4)

  3. 研究 |生 |命 (length = 4)

  4. 研究 |生命|起 (length = 5)

  5. 研究 |生命|起源 (length = 6)

  6. 研究生|命 |起 (length = 5)

  7. 研究生|命 |起源 (length = 6)

之後依次使用上述四種規則匹配之-

依據規則 1,取length最大的 Chunk

  1. 研究 |生命|起源 (length = 6, average length = 2)

  2. 研究生|命 |起源 (length = 6, average length = 2)

依據規則 2,取average length最大的 Chunk

  1. 研究 |生命|起源 (length = 6, average length = 2, variance = 0 )

  2. 研究生|命 |起源 (length = 6, average length = 2, variance = 4/9)

依據規則 3,取variance最小的 Chunk

  1. 研究 |生命|起源 (length = 6, average length = 2, variance = 0 )

因為剩下一個 Chunk 所以規則 4 就不用再匹配了。
最終結果就是 "研究 | 生命 | 起源"

若需要用到規則 4 ,當中所謂的詞頻,是要你自己在你的辭典先定義辭典裡的每一個詞的在你的資料及的某個時間點知當時的詞頻。
例如 第5號 Chunk : "研究" 詞頻=3 , "生命" 詞頻=5 , "起源" 詞頻=7
取對數的和 = ln3+ln5+ln7
其他 Chunk 也用同樣的算法算出其對數和,
最後所以剩下的 Chunk 比對誰最大就取誰即可。

但是如果最後的匹配四個規則的結果得到不只一個 Chunk ,那麼 MMSEG 就失效了。

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

PHP: An Introduction to the Server-Side Scripting Language PHP: An Introduction to the Server-Side Scripting Language Apr 16, 2025 am 12:18 AM

PHP is a server-side scripting language used for dynamic web development and server-side applications. 1.PHP is an interpreted language that does not require compilation and is suitable for rapid development. 2. PHP code is embedded in HTML, making it easy to develop web pages. 3. PHP processes server-side logic, generates HTML output, and supports user interaction and data processing. 4. PHP can interact with the database, process form submission, and execute server-side tasks.

Why Use PHP? Advantages and Benefits Explained Why Use PHP? Advantages and Benefits Explained Apr 16, 2025 am 12:16 AM

The core benefits of PHP include ease of learning, strong web development support, rich libraries and frameworks, high performance and scalability, cross-platform compatibility, and cost-effectiveness. 1) Easy to learn and use, suitable for beginners; 2) Good integration with web servers and supports multiple databases; 3) Have powerful frameworks such as Laravel; 4) High performance can be achieved through optimization; 5) Support multiple operating systems; 6) Open source to reduce development costs.

Can visual studio code be used in python Can visual studio code be used in python Apr 15, 2025 pm 08:18 PM

VS Code can be used to write Python and provides many features that make it an ideal tool for developing Python applications. It allows users to: install Python extensions to get functions such as code completion, syntax highlighting, and debugging. Use the debugger to track code step by step, find and fix errors. Integrate Git for version control. Use code formatting tools to maintain code consistency. Use the Linting tool to spot potential problems ahead of time.

How to run programs in terminal vscode How to run programs in terminal vscode Apr 15, 2025 pm 06:42 PM

In VS Code, you can run the program in the terminal through the following steps: Prepare the code and open the integrated terminal to ensure that the code directory is consistent with the terminal working directory. Select the run command according to the programming language (such as Python's python your_file_name.py) to check whether it runs successfully and resolve errors. Use the debugger to improve debugging efficiency.

Can vs code run in Windows 8 Can vs code run in Windows 8 Apr 15, 2025 pm 07:24 PM

VS Code can run on Windows 8, but the experience may not be great. First make sure the system has been updated to the latest patch, then download the VS Code installation package that matches the system architecture and install it as prompted. After installation, be aware that some extensions may be incompatible with Windows 8 and need to look for alternative extensions or use newer Windows systems in a virtual machine. Install the necessary extensions to check whether they work properly. Although VS Code is feasible on Windows 8, it is recommended to upgrade to a newer Windows system for a better development experience and security.

PHP and the Web: Exploring its Long-Term Impact PHP and the Web: Exploring its Long-Term Impact Apr 16, 2025 am 12:17 AM

PHP has shaped the network over the past few decades and will continue to play an important role in web development. 1) PHP originated in 1994 and has become the first choice for developers due to its ease of use and seamless integration with MySQL. 2) Its core functions include generating dynamic content and integrating with the database, allowing the website to be updated in real time and displayed in personalized manner. 3) The wide application and ecosystem of PHP have driven its long-term impact, but it also faces version updates and security challenges. 4) Performance improvements in recent years, such as the release of PHP7, enable it to compete with modern languages. 5) In the future, PHP needs to deal with new challenges such as containerization and microservices, but its flexibility and active community make it adaptable.

Is the vscode extension malicious? Is the vscode extension malicious? Apr 15, 2025 pm 07:57 PM

VS Code extensions pose malicious risks, such as hiding malicious code, exploiting vulnerabilities, and masturbating as legitimate extensions. Methods to identify malicious extensions include: checking publishers, reading comments, checking code, and installing with caution. Security measures also include: security awareness, good habits, regular updates and antivirus software.

PHP vs. Python: Use Cases and Applications PHP vs. Python: Use Cases and Applications Apr 17, 2025 am 12:23 AM

PHP is suitable for web development and content management systems, and Python is suitable for data science, machine learning and automation scripts. 1.PHP performs well in building fast and scalable websites and applications and is commonly used in CMS such as WordPress. 2. Python has performed outstandingly in the fields of data science and machine learning, with rich libraries such as NumPy and TensorFlow.

See all articles