Skip to content

Add Thai word list from Thai Wikipedia titles #869

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 20 commits into from
Dec 1, 2023
Merged
Show file tree
Hide file tree
Changes from 9 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 3 additions & 1 deletion pythainlp/corpus/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -45,6 +45,7 @@
"thai_orst_words",
"path_pythainlp_corpus",
"get_path_folder_corpus",
"wikipedia_titles",
]

import os
Expand Down Expand Up @@ -117,5 +118,6 @@ def corpus_db_path() -> str:
thai_words,
thai_orst_words,
thai_dict,
thai_wsd_dict
thai_wsd_dict,
)
from pythainlp.corpus.wikipedia_titles import wikipedia_titles
31 changes: 31 additions & 0 deletions pythainlp/corpus/corpus_license.md
Original file line number Diff line number Diff line change
Expand Up @@ -101,3 +101,34 @@ S. Thoongsup et al., ‘Thai WordNet construction’,
in Proceedings of the 7th Workshop on Asian Language Resources,
Suntec, Singapore, Aug. 2009, pp. 139–144.
https://www.aclweb.org/anthology/W09-3420.pdf

## Wikipedia Titles
Corpus of Wikipedia titles (wikipedia_titles.txt) was processed by konbraphat51 (https://github.com/konbraphat51/Thai_Dictionary_Cleaner/tree/main)

The original data is thwiki-latest-all-titles.gz of https://dumps.wikimedia.org/thwiki/latest/ which Wikipedia.org has created.
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do you mind to add date of the Wikipedia data here please?
The date that you have downloaded the data for your preparation.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah that's definitely required. Added!


```
Wikipedia.org

This is a human-readable summary of (and not a substitute for) the license below.

You are free:

to Share—copy and redistribute the material in any medium or format
to Adapt—remix, transform, and build upon the material
for any purpose, even commercially.

The licensor cannot revoke these freedoms as long as you follow the license terms.

Under the following terms:

Attribution—You must give appropriate credit, provide a link to the license, and indicate if changes were made. You may do so in any reasonable manner, but not in any way that suggests the licensor endorses you or your use.

Share Alike—If you remix, transform, or build upon the material, you must distribute your contributions under the same license as the original.

No additional restrictions—You may not apply legal terms or technological measures that legally restrict others from doing anything the license permits.

Notices:

You do not have to comply with the license for elements of the material in the public domain or where your use is permitted by an applicable exception or limitation. No warranties are given. The license may not give you all of the permissions necessary for your intended use. For example, other rights such as publicity, privacy, or moral rights may limit how you use the material.
```
41 changes: 41 additions & 0 deletions pythainlp/corpus/wikipedia_titles.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
# -*- coding: utf-8 -*-
# Copyright (C) 2016-2023 PyThaiNLP Project
#
# Licensed under the Apache License, Version 2.0 (the "License");
# you may not use this file except in compliance with the License.
# You may obtain a copy of the License at
#
# http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""
Provides an optional word list from Thai Wikipedia titles.
"""
from typing import FrozenSet

from pythainlp.corpus.common import get_corpus

_WIKIPEDIA_TITLES = None
_WIKIPEDIA_TITLES_FILENAME = "wikipedia_titles.txt"


def wikipedia_titles() -> FrozenSet[str]:
"""
Return a frozenset of words in the Thai Wikipedia titles corpus.

The data file is at pythainlp/corpus/wikipedia_titles.txt
The word list has beed prepared by the code at:
https://github.com/konbraphat51/Thai_Dictionary_Cleaner

:return: :class:`frozenset` containing words in Thai Wikipedia titles corpus.
:rtype: :class:`frozenset`
"""
global _WIKIPEDIA_TITLES
if not _WIKIPEDIA_TITLES:
_WIKIPEDIA_TITLES = get_corpus(_WIKIPEDIA_TITLES_FILENAME)

return _WIKIPEDIA_TITLES
Loading