-
Notifications
You must be signed in to change notification settings - Fork 273
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #869 from konbraphat51/corpus_wiki
Add Thai wikipedia titles corpus. Thanks @konbraphat51
- Loading branch information
Showing
5 changed files
with
290,170 additions
and
37 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,43 @@ | ||
# -*- 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 from Thai Wikipedia titles corpus. | ||
They are mostly nouns and noun phrases, | ||
including event, organization, people, place, and product names. | ||
Commonly misspelled words are included intentionally. | ||
More info: | ||
https://github.com/PyThaiNLP/pythainlp/blob/dev/pythainlp/corpus/corpus_license.md | ||
:return: :class:`frozenset` containing words in Thai Wikipedia titles. | ||
:rtype: :class:`frozenset` | ||
""" | ||
global _WIKIPEDIA_TITLES | ||
if not _WIKIPEDIA_TITLES: | ||
_WIKIPEDIA_TITLES = get_corpus(_WIKIPEDIA_TITLES_FILENAME) | ||
|
||
return _WIKIPEDIA_TITLES |
Oops, something went wrong.