{"id":13705754,"url":"https://github.com/eulerto/pg_similarity","last_synced_at":"2025-04-05T08:06:54.967Z","repository":{"id":138908946,"uuid":"1458923","full_name":"eulerto/pg_similarity","owner":"eulerto","description":"set of functions and operators for executing similarity queries","archived":false,"fork":false,"pushed_at":"2024-07-31T13:20:36.000Z","size":168,"stargazers_count":374,"open_issues_count":17,"forks_count":41,"subscribers_count":15,"default_branch":"master","last_synced_at":"2025-03-29T07:05:09.098Z","etag":null,"topics":["cosine","jaccard","jaro-winkler","levenshtein","postgres","postgresql-extension","similarity","soundex"],"latest_commit_sha":null,"homepage":"","language":"C","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"bsd-3-clause","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/eulerto.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2011-03-09T12:40:12.000Z","updated_at":"2025-03-27T00:37:33.000Z","dependencies_parsed_at":null,"dependency_job_id":"c1514960-f340-43a2-8509-96fc00432c9f","html_url":"https://github.com/eulerto/pg_similarity","commit_stats":null,"previous_names":[],"tags_count":1,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eulerto%2Fpg_similarity","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eulerto%2Fpg_similarity/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eulerto%2Fpg_similarity/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/eulerto%2Fpg_similarity/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/eulerto","download_url":"https://codeload.github.com/eulerto/pg_similarity/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":247305934,"owners_count":20917208,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["cosine","jaccard","jaro-winkler","levenshtein","postgres","postgresql-extension","similarity","soundex"],"created_at":"2024-08-02T22:00:47.364Z","updated_at":"2025-04-05T08:06:54.933Z","avatar_url":"https://github.com/eulerto.png","language":"C","funding_links":[],"categories":["C"],"sub_categories":[],"readme":"[![Coverity Scan Build Status](https://scan.coverity.com/projects/4830/badge.svg)](https://scan.coverity.com/projects/pg_similarity)\n\nIntroduction\n============\n\n**pg\\_similarity** is an extension to support similarity queries on [PostgreSQL](http://www.postgresql.org/). The implementation is tightly integrated in the RDBMS in the sense that it defines operators so instead of the traditional operators (= and \u003c\u003e) you can use ~~~ and ~!~ (any of these operators represents a similarity function).\n\n**pg\\_similarity** has three main components:\n\n - **Functions**: a set of functions that implements similarity algorithms available in the literature. These functions can be used as UDFs and, will be the base for implementing the similarity operators;\n - **Operators**: a set of operators defined at the top of similarity functions. They use similarity functions to obtain the similarity threshold and, compare its value to a user-defined threshold to decide if it is a match or not;\n - **Session Variables**: a set of variables that store similarity function parameters. Theses variables can be defined at run time.\n\nInstallation\n============\n\n**pg\\_similarity** is supported on [those platforms](http://www.postgresql.org/docs/current/static/supported-platforms.html) that PostgreSQL is. The installation steps depend on your operating system.\n\nYou can also keep up with the latest fixes and features cloning the Git repository.\n\n```\n$ git clone https://github.com/eulerto/pg_similarity.git\n```\n\nUNIX based Operating Systems\n----------------------------\n\nBefore you are able to use your extension, you should build it and load it at the desirable database.\n\n```\n$ tar -zxf pg_similarity-1.0.tgz\n$ cd pg_similarity-1.0\n$ $EDITOR Makefile # edit PG_CONFIG iif necessary\n$ make\n$ make install\n$ psql mydb\npsql (13.0)\nType \"help\" for help.\n\nmydb=# CREATE EXTENSION pg_similarity;\nCREATE EXTENSION\n```\n\nThe typical usage is to copy a sample file at tarball (*pg_similarity.conf.sample*) to PGDATA (as *pg_similarity.conf*) and include the following line in *postgresql.conf*:\n\n```\ninclude 'pg_similarity.conf'\n```\n\nWindows\n-------\n\nSorry, never tried^H^H^H^H^H Actually I tried that but it is not that easy as on UNIX. :( There are two ways to build PostgreSQL on Windows: (i) MingW and (ii) MSVC. The former is supported but it is not widely used and the latter is popular because Windows binaries (officially distributed) are built using MSVC. If you choose to use Mingw, just follow the UNIX instructions above to build pg_similarity. Otherwise, the MSVC steps are below:\n\n- Edit `pg_similarity.vcxproj` replacing `c:\\postgres\\pg130` with PostgreSQL prefix directory;\n- Open this project file in MS Visual Studio and build it;\n- Copy `pg_similarity.dll` to `pg_config --pkglibdir`;\n- Copy `pg_similarity.control` and `pg_similarity--*.sql` to `SHAREDIR/extension` (SHAREDIR is `pg_config --sharedir`).\n\nFunctions and Operators\n=======================\n\nThis extension supports a set of similarity algorithms. The most known algorithms are covered by this extension. You must be aware that each algorithm is suited for a specific domain. The following algorithms are provided.\n\n - L1 Distance (as known as City Block or Manhattan Distance);\n - Cosine Distance;\n - Dice Coefficient;\n - Euclidean Distance;\n - Hamming Distance;\n - Jaccard Coefficient;\n - Jaro Distance;\n - Jaro-Winkler Distance;\n - Levenshtein Distance;\n - Matching Coefficient;\n - Monge-Elkan Coefficient;\n - Needleman-Wunsch Coefficient;\n - Overlap Coefficient;\n - Q-Gram Distance;\n - Smith-Waterman Coefficient;\n - Smith-Waterman-Gotoh Coefficient;\n - Soundex Distance.\n\n\u003ctable\u003e\n  \u003ctr\u003e\n    \u003cth\u003eAlgorithm\u003c/th\u003e\n    \u003cth\u003eFunction\u003c/th\u003e\n    \u003cth\u003eOperator\u003c/th\u003e\n\t\u003cth\u003eUse Index?\u003c/th\u003e\n    \u003cth\u003eParameters\u003c/th\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eL1 Distance\u003c/td\u003e\n    \u003ctd\u003eblock(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~++\u003c/td\u003e\n\t\u003ctd\u003eyes\u003c/td\u003e\n    \u003ctd\u003e\n        pg_similarity.block_tokenizer (enum)\u003cbr/\u003e\n        pg_similarity.block_threshold (float8)\u003cbr/\u003e\n        pg_similarity.block_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eCosine Distance\u003c/td\u003e\n    \u003ctd\u003ecosine(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~##\u003c/td\u003e\n\t\u003ctd\u003eyes\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.cosine_tokenizer (enum)\u003cbr/\u003e\n      pg_similarity.cosine_threshold (float8)\u003cbr/\u003e\n      pg_similarity.cosine_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eDice Coefficient\u003c/td\u003e\n    \u003ctd\u003edice(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~-~\u003c/td\u003e\n\t\u003ctd\u003eyes\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.dice_tokenizer (enum)\u003cbr/\u003e\n      pg_similarity.dice_threshold (float8)\u003cbr/\u003e\n      pg_similarity.dice_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eEuclidean Distance\u003c/td\u003e\n    \u003ctd\u003eeuclidean(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~!!\u003c/td\u003e\n\t\u003ctd\u003eyes\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.euclidean_tokenizer (enum)\u003cbr/\u003e\n      pg_similarity.euclidean_threshold (float8)\u003cbr/\u003e\n      pg_similarity.euclidean_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eHamming Distance\u003c/td\u003e\n    \u003ctd\u003ehamming(bit varying, bit varying) returns float8\u003cbr/\u003e\n    hamming_text(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~@~\u003c/td\u003e\n\t\u003ctd\u003eno\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.hamming_threshold (float8)\u003cbr/\u003e\n      pg_similarity.hamming_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eJaccard Coefficient\u003c/td\u003e\n    \u003ctd\u003ejaccard(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~??\u003c/td\u003e\n\t\u003ctd\u003eyes\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.jaccard_tokenizer (enum)\u003cbr/\u003e\n      pg_similarity.jaccard_threshold (float8)\u003cbr/\u003e\n      pg_similarity.jaccard_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eJaro Distance\u003c/td\u003e\n    \u003ctd\u003ejaro(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~%%\u003c/td\u003e\n\t\u003ctd\u003eno\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.jaro_threshold (float8)\u003cbr/\u003e\n      pg_similarity.jaro_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eJaro-Winkler Distance\u003c/td\u003e\n    \u003ctd\u003ejarowinkler(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~@@\u003c/td\u003e\n\t\u003ctd\u003eno\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.jarowinkler_threshold (float8)\u003cbr/\u003e\n      pg_similarity.jarowinkler_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eLevenshtein Distance\u003c/td\u003e\n    \u003ctd\u003elev(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~==\u003c/td\u003e\n\t\u003ctd\u003eno\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.levenshtein_threshold (float8)\u003cbr/\u003e\n      pg_similarity.levenshtein_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eMatching Coefficient\u003c/td\u003e\n    \u003ctd\u003ematchingcoefficient(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~^^\u003c/td\u003e\n\t\u003ctd\u003eyes\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.matching_tokenizer (enum)\u003cbr/\u003e\n      pg_similarity.matching_threshold (float8)\u003cbr/\u003e\n      pg_similarity.matching_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eMonge-Elkan Coefficient\u003c/td\u003e\n    \u003ctd\u003emongeelkan(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~||\u003c/td\u003e\n\t\u003ctd\u003eno\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.mongeelkan_tokenizer (enum)\u003cbr/\u003e\n      pg_similarity.mongeelkan_threshold (float8)\u003cbr/\u003e\n      pg_similarity.mongeelkan_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eNeedleman-Wunsch Coefficient\u003c/td\u003e\n    \u003ctd\u003eneedlemanwunsch(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~#~\u003c/td\u003e\n\t\u003ctd\u003eno\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.nw_threshold (float8)\u003cbr/\u003e\n      pg_similarity.nw_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eOverlap Coefficient\u003c/td\u003e\n    \u003ctd\u003eoverlapcoefficient(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~**\u003c/td\u003e\n\t\u003ctd\u003eyes\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.overlap_tokenizer (enum)\u003cbr/\u003e\n      pg_similarity.overlap_threshold (float8)\u003cbr/\u003e\n      pg_similarity.overlap_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eQ-Gram Distance\u003c/td\u003e\n    \u003ctd\u003eqgram(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~~~\u003c/td\u003e\n\t\u003ctd\u003eyes\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.qgram_threshold (float8)\u003cbr/\u003e\n      pg_similarity.qgram_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eSmith-Waterman Coefficient\u003c/td\u003e\n    \u003ctd\u003esmithwaterman(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~=~\u003c/td\u003e\n\t\u003ctd\u003eno\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.sw_threshold (float8)\u003cbr/\u003e\n      pg_similarity.sw_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eSmith-Waterman-Gotoh Coefficient\u003c/td\u003e\n    \u003ctd\u003esmithwatermangotoh(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~!~\u003c/td\u003e\n\t\u003ctd\u003eno\u003c/td\u003e\n    \u003ctd\u003e\n      pg_similarity.swg_threshold (float8)\u003cbr/\u003e\n      pg_similarity.swg_is_normalized (bool)\n    \u003c/td\u003e\n  \u003c/tr\u003e\n  \u003ctr\u003e\n    \u003ctd\u003eSoundex Distance\u003c/td\u003e\n    \u003ctd\u003esoundex(text, text) returns float8\u003c/td\u003e\n    \u003ctd\u003e~*~\u003c/td\u003e\n\t\u003ctd\u003eno\u003c/td\u003e\n    \u003ctd\u003e\n    \u003c/td\u003e\n  \u003c/tr\u003e\n\u003c/table\u003e\n\nThe several parameters control the behavior of the pg\\_similarity functions and operators. I don't explain in detail each parameter because they can be classified in three classes: **tokenizer**, **threshold**, and **normalized**.\n\n - **tokenizer**: controls how the strings are tokenized. The valid values are **alnum**, **gram**, **word**, and **camelcase**. All tokens are lowercase (this option can be set at compile time; see PGS\\_IGNORE\\_CASE at source code). Default is **alnum**;\n   - **alnum**: delimiters are any non-alphanumeric characters. That means that only alphabetic characters in the standard C locale and digits (0-9) are accepted in tokens. For example, the string \"Euler\\_Taveira\\_de\\_Oliveira 22/02/2011\" is tokenized as \"Euler\", \"Taveira\", \"de\", \"Oliveira\", \"22\", \"02\", \"2011\";\n   - **gram**: an n-gram is a subsequence of length n. Extracting n-grams from a string can be done by using the sliding-by-one technique, that is, sliding a window of length n through out the string by one character. For example, the string \"euler taveira\" (using n = 3) is tokenized as \"eul\", \"ule\", \"ler\", \"er \", \"r t\", \" ta\", \"tav\", \"ave\", \"vei\", \"eir\", and \"ira\". There are some authors that consider n-grams adding \"  e\", \" eu\", \"ra \", and \"a  \" to the set of tokens, that is called full n-grams (this option can be set at compile time; see PGS\\_FULL\\_NGRAM at source code);\n   - **word**: delimiters are white space characters (space, form-feed, newline, carriage return, horizontal tab, and vertical tab). For example, the string \"Euler Taveira de Oliveira 22/02/2011\" is tokenized as \"Euler\", \"Taveira\", \"de\", \"Oliveira\", and \"22/02/2011\";\n   - **camelcase**: delimiters are capitalized characters but they are also included as first token characters. For example, the string \"EulerTaveira de Oliveira\" is tokenized as \"Euler\", \"Taveira de \", and \"Oliveira\".\n - **threshold**: controls how flexible will be the result set. These values are used by operators to match strings. For each pair of strings, if the calculated value (using the corresponding similarity function) is greater or equal the threshold value, there is a match. The values range from **0.0** to **1.0**. Default is **0.7**;\n - **normalized**: controls whether the similarity coefficient/distance is normalized (between 0.0 and 1.0) or not. Normalized values are used automatically by operators to match strings, that is, this parameter only makes sense if you are using similarity functions. Default is **true**.\n\nExamples\n========\n\nSet parameters at run time.\n\n```\nmydb=# show pg_similarity.levenshtein_threshold;\n pg_similarity.levenshtein_threshold\n-------------------------------------\n 0.7\n(1 row)\n\nmydb=# set pg_similarity.levenshtein_threshold to 0.5;\nSET\nmydb=# show pg_similarity.levenshtein_threshold;\n pg_similarity.levenshtein_threshold\n-------------------------------------\n 0.5\n(1 row)\n\nmydb=# set pg_similarity.cosine_tokenizer to camelcase;\nSET\nmydb=# set pg_similarity.euclidean_is_normalized to false;\nSET\n```\n\nSimple tables for examples.\n\n```\nmydb=# create table foo (a text);\nCREATE TABLE\nmydb=# insert into foo values('Euler'),('Oiler'),('Euler Taveira de Oliveira'),('Maria Taveira dos Santos'),('Carlos Santos Silva');\nINSERT 0 5\nmydb=# create table bar (b text);\nCREATE TABLE\nmydb=# insert into bar values('Euler T. de Oliveira'),('Euller'),('Oliveira, Euler Taveira'),('Sr. Oliveira');\nINSERT 0 4\n```\n\n*Example 1*: Using similarity functions **cosine**, **jaro**, and **euclidean**.\n\n```\nmydb=# select a, b, cosine(a,b), jaro(a, b), euclidean(a, b) from foo, bar;\n             a             |            b            |  cosine  |   jaro   | euclidean\n---------------------------+-------------------------+----------+----------+-----------\n Euler                     | Euler T. de Oliveira    |      0.5 |     0.75 |  0.579916\n Euler                     | Euller                  |        0 | 0.944444 |         0\n Euler                     | Oliveira, Euler Taveira |  0.57735 | 0.605797 |  0.552786\n Euler                     | Sr. Oliveira            |        0 | 0.505556 |  0.225403\n Oiler                     | Euler T. de Oliveira    |        0 | 0.472222 |  0.457674\n Oiler                     | Euller                  |        0 |      0.7 |         0\n Oiler                     | Oliveira, Euler Taveira |        0 | 0.672464 |  0.367544\n Oiler                     | Sr. Oliveira            |        0 | 0.672222 |  0.225403\n Euler Taveira de Oliveira | Euler T. de Oliveira    |     0.75 |  0.79807 |      0.75\n Euler Taveira de Oliveira | Euller                  |        0 | 0.677778 |  0.457674\n Euler Taveira de Oliveira | Oliveira, Euler Taveira | 0.866025 | 0.773188 |       0.8\n Euler Taveira de Oliveira | Sr. Oliveira            | 0.353553 | 0.592222 |  0.552786\n Maria Taveira dos Santos  | Euler T. de Oliveira    |        0 |  0.60235 |       0.5\n Maria Taveira dos Santos  | Euller                  |        0 | 0.305556 |  0.457674\n Maria Taveira dos Santos  | Oliveira, Euler Taveira | 0.288675 | 0.535024 |  0.552786\n Maria Taveira dos Santos  | Sr. Oliveira            |        0 | 0.634259 |  0.452277\n Carlos Santos Silva       | Euler T. de Oliveira    |        0 | 0.542105 |   0.47085\n Carlos Santos Silva       | Euller                  |        0 | 0.312865 |  0.367544\n Carlos Santos Silva       | Oliveira, Euler Taveira |        0 | 0.606662 |   0.42265\n Carlos Santos Silva       | Sr. Oliveira            |        0 | 0.507728 |  0.379826\n(20 rows)\n```\n\n*Example 2*: Using operator **levenshtein** (~==) and changing its threshold at run time.\n\n```\nmydb=# show pg_similarity.levenshtein_threshold;\n pg_similarity.levenshtein_threshold\n-------------------------------------\n 0.7\n(1 row)\n\nmydb=# select a, b, lev(a,b) from foo, bar where a ~== b;\n             a             |          b           |   lev\n---------------------------+----------------------+----------\n Euler                     | Euller               | 0.833333\n Euler Taveira de Oliveira | Euler T. de Oliveira |     0.76\n(2 rows)\n\nmydb=# set pg_similarity.levenshtein_threshold to 0.5;\nSET\nmydb=# select a, b, lev(a,b) from foo, bar where a ~== b;\n             a             |          b           |   lev\n---------------------------+----------------------+----------\n Euler                     | Euller               | 0.833333\n Oiler                     | Euller               |      0.5\n Euler Taveira de Oliveira | Euler T. de Oliveira |     0.76\n(3 rows)\n```\n\n*Example 3*: Using operator **qgram** (~~~) and changing its threshold at run time.\n\n```\nmydb=# set pg_similarity.qgram_threshold to 0.7;\nSET\nmydb=# show pg_similarity.qgram_threshold;\n pg_similarity.qgram_threshold\n-------------------------------\n 0.7\n(1 row)\n\nmydb=# select a, b,qgram(a, b) from foo, bar where a ~~~ b;\n             a             |            b            |  qgram\n---------------------------+-------------------------+----------\n Euler                     | Euller                  |      0.8\n Euler Taveira de Oliveira | Euler T. de Oliveira    |  0.77551\n Euler Taveira de Oliveira | Oliveira, Euler Taveira | 0.807692\n(3 rows)\n\nmydb=# set pg_similarity.qgram_threshold to 0.35;\nSET\nmydb=# select a, b,qgram(a, b) from foo, bar where a ~~~ b;\n             a             |            b            |  qgram\n---------------------------+-------------------------+----------\n Euler                     | Euler T. de Oliveira    | 0.413793\n Euler                     | Euller                  |      0.8\n Oiler                     | Euller                  |      0.4\n Euler Taveira de Oliveira | Euler T. de Oliveira    |  0.77551\n Euler Taveira de Oliveira | Oliveira, Euler Taveira | 0.807692\n Euler Taveira de Oliveira | Sr. Oliveira            | 0.439024\n(6 rows)\n\n```\n\n*Example 4*: Using a set of operators using the same threshold (0.7) to ilustrate that some similarity functions are appropriated to certain data domains.\n\n```\nmydb=# select * from bar where b ~@@ 'euler'; -- jaro-winkler operator\n          b\n----------------------\n Euler T. de Oliveira\n Euller\n(2 rows)\n\nmydb=# select * from bar where b ~~~ 'euler'; -- qgram operator\n b\n---\n(0 rows)\n\nmydb=# select * from bar where b ~== 'euler'; -- levenshtein operator\n   b\n--------\n Euller\n(1 row)\n\nmydb=# select * from bar where b ~## 'euler'; -- cosine operator\n b\n---\n(0 rows)\n```\n\nLicense\n=======\n\n\u003e Copyright © 2008-2020 Euler Taveira de Oliveira\n\u003e All rights reserved.\n\n\u003e Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met:\n\n\u003e Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer;\n\u003e Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the documentation and/or other materials provided with the distribution;\n\u003e Neither the name of the Euler Taveira de Oliveira nor the names of its contributors may be used to endorse or promote products derived from this software without specific prior written permission.\n\n\u003e THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS \"AS IS\" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.\n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feulerto%2Fpg_similarity","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Feulerto%2Fpg_similarity","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Feulerto%2Fpg_similarity/lists"}