-
Notifications
You must be signed in to change notification settings - Fork 179
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 #249 from sir-kokabi/resolve-conflict-in-pr-#120
Resolve conflict in pr #120
- Loading branch information
Showing
1 changed file
with
19 additions
and
0 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,19 @@ | ||
from nltk.corpus import PlaintextCorpusReader | ||
from nltk.corpus.reader import StreamBackedCorpusView, read_blankline_block | ||
|
||
from hazm import word_tokenize, sent_tokenize | ||
|
||
|
||
class PersianPlainTextReader(PlaintextCorpusReader): | ||
""" | ||
Reader for corpora that consist of plaintext documents. Paragraphs | ||
are assumed to be split using blank lines. Sentences and words can | ||
be tokenized using the default tokenizers, or by custom tokenizers | ||
specificed as parameters to the constructor. | ||
""" | ||
CorpusView = StreamBackedCorpusView | ||
|
||
def __init__(self, root, fileids, word_tokenizer=word_tokenize, sent_tokenizer=sent_tokenize, | ||
para_block_reader=read_blankline_block, encoding='utf8'): | ||
super().__init__(root, fileids, word_tokenizer, sent_tokenizer, para_block_reader, encoding) |