Hướng dẫn name matching algorithm python - thuật toán khớp tên python

Ảnh của Romain Vignes trên unplash

Nội dung chính

  • Tìm các chuỗi xấp xỉ khớp với một mẫu trong dữ liệu của bạn bằng Python.
  • Giới thiệu về Fuzzywuzzy trong Python
  • Lập luận mờ
  • Chuỗi mờ khớp
  • Sự kết luận
  • Một trong những thuật toán phù hợp với chuỗi nào sau đây là tốt nhất?
  • Làm thế nào để bạn phù hợp với các chuỗi tương tự trong Python?
  • Các thuật toán phù hợp với chuỗi nào?
  • Python wuzzy mờ là gì?

Tìm các chuỗi xấp xỉ khớp với một mẫu trong dữ liệu của bạn bằng Python.

Giới thiệu về Fuzzywuzzy trong Python

Lập luận mờ

Chuỗi mờ khớp

Sự kết luận

Lập luận mờ

Chuỗi mờ khớp: difficult to perceive; indistinct or vague

-Wikipedia

Sự kết luậnBoolean Logic is a two-valued logic: true or false usually denoted 1 and 0 respectively, that deals with reasoning that is fixed and exact. Fuzzy logic tends to reflect how people think and attempts to model our decision making hence it is now leading to new intelligent systems[expert systems].

Một trong những thuật toán phù hợp với chuỗi nào sau đây là tốt nhất?

Chuỗi mờ khớp

Sự kết luận

Giới thiệu về Fuzzywuzzy trong Python

Lập luận mờ is a python library that uses Levenshtein Distance to calculate the differences between sequences and patterns that was developed and also open-sourced by SeatGeek, a service that finds event tickets from all over the internet and showcase them on one platform. The big problem they were facing was the labeling of the same events as stated on their blog. This is the same as the example I gave at the beginning of the post where an entity such as a person’s name can be labelled differently on different sources.

Chuỗi mờ khớp

Sự kết luận

pip install fuzzywuzzypip install python-Levenshtein

Một trong những thuật toán phù hợp với chuỗi nào sau đây là tốt nhất?

Làm thế nào để bạn phù hợp với các chuỗi tương tự trong Python?

from fuzzywuzzy import fuzz
from fuzzywuzzy import process

Các thuật toán phù hợp với chuỗi nào?

fuzz.ratio["Catherine M Gitau","Catherine Gitau"]#91fuzz.partial_ratio["Catherine M. Gitau","Catherine Gitau"]#100

Python wuzzy mờ là gì? fuzz.partial_ratio[] takes in the shortest string, which in this case is "Catherine Gitau" [length 14] , then matches it with all the sub-strings of length[14] in "Catherine M. Gitau" which means matching with "Catherine Gitau" which gives 100%. You can play around with the strings until you get the gist.

Điều gì sẽ xảy ra nếu chúng ta chuyển hai tên trong một chuỗi? Trong ví dụ sau, tôi đã thay thế cho cái tên là Catherine Gitau, với Gitau Catherine. Hãy để xem điểm số:

fuzz.ratio["Catherine M Gitau","Gitau Catherine"]#55fuzz.partial_ratio["Catherine M. Gitau","Gitau Catherine"]#60

Chúng tôi thấy rằng cả hai phương thức đều đưa ra điểm số thấp, điều này có thể được chỉnh sửa bằng cách sử dụng phương thức token_sort_ratio []. Phương pháp này cố gắng tính toán cho các chuỗi tương tự không có thứ tự. Ví dụ, nếu chúng ta sử dụng lại các chuỗi trên nhưng sử dụng token_sort_ratio [], chúng ta sẽ nhận được như sau:token_sort_ratio[] method. This method attempts to account for similar strings that are out of order. Example, if we used the above strings again but using token_sort_ratio[] we get the following:token_sort_ratio[] method. This method attempts to account for similar strings that are out of order. Example, if we used the above strings again but using token_sort_ratio[] we get the following:

fuzz.token_sort_ratio["Catherine Gitau M.", "Gitau Catherine"]#94

Như bạn có thể thấy, chúng tôi nhận được điểm cao là 94.

Sự kết luận

Bài viết này đã giới thiệu kết hợp chuỗi mờ, một vấn đề nổi tiếng được xây dựng trên khoảng cách Leivenshtein. Từ những gì chúng ta đã thấy, nó tính toán hai chuỗi tương tự như thế nào. Điều này cũng có thể được tính toán bằng cách tìm ra số lượng hoạt động cần thiết để chuyển đổi một chuỗi sang chuỗi kia .e.g với tên là Bar Barack, người ta có thể đánh vần nó là Bar Barac. Chỉ cần một thao tác để sửa điều này, I.E thêm một k ở cuối. Bạn có thể thử điều này bằng cách sử dụng thư viện StringDist trong r như vậy:R as such:R as such:

adist["Barack", "Barac"]
#[1]

Nguồn

//marcobonzanini.com/2015/02/25/fuzzy-string-matching-in-python/

Cho đến thời điểm tiếp theo:]

Một trong những thuật toán phù hợp với chuỗi nào sau đây là tốt nhất?

Kết quả: Thuật toán Boyer-Moore-Horspool đạt được kết quả tổng thể tốt nhất khi được sử dụng với các văn bản y tế. Thuật toán này thường thực hiện nhanh nhất gấp đôi so với các thuật toán khác được kiểm tra. Kết luận: Hiệu suất thời gian của khớp mẫu chính xác có thể được cải thiện rất nhiều nếu sử dụng thuật toán hiệu quả.Boyer-Moore-Horspool algorithm achieves the best overall results when used with medical texts. This algorithm usually performs at least twice as fast as the other algorithms tested. Conclusion: The time performance of exact string pattern matching can be greatly improved if an efficient algorithm is used.Boyer-Moore-Horspool algorithm achieves the best overall results when used with medical texts. This algorithm usually performs at least twice as fast as the other algorithms tested. Conclusion: The time performance of exact string pattern matching can be greatly improved if an efficient algorithm is used.

Làm thế nào để bạn phù hợp với các chuỗi tương tự trong Python?

Chúng ta có thể chỉ cần thực hiện cả hai từ tất cả các trường hợp cấp dưới [hoặc trường hợp trên], sau đó so sánh lại.Chúng ta có thể sử dụng các phương thức chuỗi thấp hơn [] / trên [] trực tiếp trên bất kỳ dữ liệu chuỗi đã cho.make both words all lower cases [or upper cases], then compare again. We can use the String lower[] / upper[] methods directly on any given string data.make both words all lower cases [or upper cases], then compare again. We can use the String lower[] / upper[] methods directly on any given string data.

Các thuật toán phù hợp với chuỗi nào?

Thuật toán khớp chuỗi còn được gọi là "Thuật toán tìm kiếm chuỗi."Đây là một lớp thuật toán chuỗi quan trọng được tuyên bố là "Đây là phương pháp tìm một nơi mà một chuỗi được tìm thấy trong chuỗi lớn hơn."Cho một mảng văn bản, t [1 ..... n], của ký tự n và một mảng mẫu, p [1 ......String Searching Algorithm." This is a vital class of string algorithm is declared as "this is the method to find a place where one is several strings are found within the larger string." Given a text array, T [1.....n], of n character and a pattern array, P [1......String Searching Algorithm." This is a vital class of string algorithm is declared as "this is the method to find a place where one is several strings are found within the larger string." Given a text array, T [1.....n], of n character and a pattern array, P [1......

Python wuzzy mờ là gì?

Fuzzywuzzy là một thư viện Python sử dụng khoảng cách Levenshtein để tính toán sự khác biệt giữa các chuỗi và các mẫu được phát triển và cũng có nguồn gốc mở bởi SeatGeek, một dịch vụ tìm thấy vé sự kiện từ khắp Internet và giới thiệu chúng trên một nền tảng.a python library that uses Levenshtein Distance to calculate the differences between sequences and patterns that was developed and also open-sourced by SeatGeek, a service that finds event tickets from all over the internet and showcase them on one platform.a python library that uses Levenshtein Distance to calculate the differences between sequences and patterns that was developed and also open-sourced by SeatGeek, a service that finds event tickets from all over the internet and showcase them on one platform.

Bài Viết Liên Quan

Chủ Đề