{"id":22089902,"url":"https://github.com/dhchenx/semantic-kit","last_synced_at":"2025-07-24T19:31:34.623Z","repository":{"id":57465426,"uuid":"436324764","full_name":"dhchenx/semantic-kit","owner":"dhchenx","description":"A toolkit to estimate semantic similarity and relatedness between words/sentences","archived":false,"fork":false,"pushed_at":"2022-02-04T18:19:42.000Z","size":99190,"stargazers_count":5,"open_issues_count":1,"forks_count":1,"subscribers_count":2,"default_branch":"main","last_synced_at":"2024-11-29T07:41:31.351Z","etag":null,"topics":["semantic-analysis","semantic-relatedness","semantic-similarity","text-analysis"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/dhchenx.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null}},"created_at":"2021-12-08T16:56:59.000Z","updated_at":"2024-11-17T15:38:36.000Z","dependencies_parsed_at":"2022-09-13T13:40:50.803Z","dependency_job_id":null,"html_url":"https://github.com/dhchenx/semantic-kit","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhchenx%2Fsemantic-kit","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhchenx%2Fsemantic-kit/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhchenx%2Fsemantic-kit/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/dhchenx%2Fsemantic-kit/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/dhchenx","download_url":"https://codeload.github.com/dhchenx/semantic-kit/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":227470068,"owners_count":17778930,"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":["semantic-analysis","semantic-relatedness","semantic-similarity","text-analysis"],"created_at":"2024-12-01T02:14:40.485Z","updated_at":"2024-12-01T02:14:41.045Z","avatar_url":"https://github.com/dhchenx.png","language":"Python","funding_links":[],"categories":["Python"],"sub_categories":[],"readme":"# Semantic Similarity and Relatedness Toolkit\n\nA toolkit to estimate semantic similarity and relatedness between two words/sentences. \n\n## Installation\n```pip\npip install semantic-kit\n```\n\n## Functions\n1. Lesk algorithm and improved version\n2. Similarity algorithms including WordNet , word2vec similarity, LDA, and googlenews-based methods\n3. Distance algorithms like jaccard, soren, levenshtein, and their improved versions\n4. Use Open Multilingual Wordnet to generate relevant keywords from multiple language\n\n## Examples\n### Lesk Algorithm\n```python\nfrom semantickit.relatedness.lesk import lesk\nfrom semantickit.relatedness.lesk_max_overlap import lesk_max_overlap\nsent = ['I', 'went', 'to', 'the', 'bank', 'to', 'deposit', 'money', '.']\nm1, s1 = lesk(sent, 'bank', 'n')\nm2, s2 = lesk_max_overlap(sent, 'bank', 'n')\nprint(m1,s1)\nprint(m2,s2)\n```\n### WordNet-based Similarity\n```python\nfrom semantickit.similarity.wordnet_similarity import wordnet_similarity_all\nprint(wordnet_similarity_all(\"dog.n.1\",\"cat.n.1\"))\n```\n\n### Corpus-based Similarity\n```python\nfrom semantickit.similarity.word2vec_similarity import build_model,similarity_model\n# build similarity model based on text source\nbuild_model(data_path=\"text8\",save_path=\"wiki_model\")\n# estimate similarity between words using the built model\nsim=similarity_model(\"wiki_model\",\"france\",\"spain\")\n# print result\nprint(\"word2vec similarity: \",sim)\n```\n\n### Pre-trained model-based Similarity\n```python\nfrom semantickit.similarity.googlenews_similarity import googlenews_similarity\ndata_path= r'GoogleNews-vectors-negative300.bin'\nsim=googlenews_similarity(data_path,'human','people')\nprint(sim)\n```\n\n## Weighted Levenshtein\n```python\nfrom semantickit.distance.n_gram.train_ngram import TrainNgram\nfrom semantickit.distance.weighted_levenshtein import weighted_levenshtein,Build_TFIDF\n\n# train model\ntrain_data_path = 'wlev/icd10_train.txt'\nwordict_path = 'wlev/word_dict.model'\ntransdict_path = 'wlev/trans_dict.model'\nwords_path=\"wlev/dict_words.txt\"\ntrainer = TrainNgram()\ntrainer.train(train_data_path, wordict_path, transdict_path)\n\n# build words tf-idf file\nBuild_TFIDF(train_data_path,words_path)\n\n# estimate weight lev distance\ns0='颈结缔组织良性肿瘤'\ns1='耳软骨良性肿瘤'\nresult=weighted_levenshtein(s0,s1, word_dict_path=wordict_path,trans_dict_path=transdict_path,data_path=train_data_path,words_path=words_path)\nprint(result)\n```\n\n## License\nThe `Semantic-Kit` project is provided by [Donghua Chen](https://github.com/dhchenx). \n\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhchenx%2Fsemantic-kit","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fdhchenx%2Fsemantic-kit","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fdhchenx%2Fsemantic-kit/lists"}