pycrossword  0.4
Pure-Python implementation of a crossword puzzle generator and editor
Public Member Functions | Public Attributes | Private Member Functions | List of all members
pycross.wordsrc.TextfileWordsource Class Reference

Word source generated from a text file. More...

Inheritance diagram for pycross.wordsrc.TextfileWordsource:
pycross.wordsrc.TextWordsource pycross.wordsrc.Wordsource

Public Member Functions

def __init__ (self, path, enc=ENCODING, delimiter=' ', max_fetch=None, shuffle=True)
 Constructor. More...
 
- Public Member Functions inherited from pycross.wordsrc.TextWordsource
def __init__ (self, words=[], max_fetch=None, shuffle=True)
 Constructor. More...
 
def isvalid (self)
 Valid only if TextWordsource::words not empty. More...
 
def fetch (self, word=None, blank=' ', pos=None, filter_func=None, shuffle=True, truncate=True)
 Fetches results from TextWordsource::words. More...
 
- Public Member Functions inherited from pycross.wordsrc.Wordsource
def __init__ (self, max_fetch=None, shuffle=True)
 Constructor. More...
 
def truncate (self, suggestions)
 Truncates the results by the threshold number stored in Wordsource::max_fetch. More...
 
def shuffle (self, suggestions)
 Shuffles the results randomly. More...
 
def check (self, word, pos=None, filter_func=None)
 Checks if a given word or word pattern is found in the word source. More...
 
def pop_word (self, suggestions)
 Retrieves the last suggestion (word) from the list of suggestions, removing that word from the original results. More...
 
def __repr__ (self)
 Python repr() overload. More...
 
def __bool__ (self)
 Python bool() overload. More...
 

Public Attributes

 words
 
- Public Attributes inherited from pycross.wordsrc.TextWordsource
 words
 list list of 2-tuples, where the first element is the source word and the second element is either a list of parts of speech or None if no part-of-speech data is available More...
 
- Public Attributes inherited from pycross.wordsrc.Wordsource
 max_fetch
 int maximum number of suggestions returned from the word source More...
 
 shuffle_words
 bool if True, fetched words will be shuffled More...
 
 active
 bool if True, this word source will be used; otherwise it will be ignored More...
 

Private Member Functions

def _read_data (self, path, enc=ENCODING, delimiter=' ')
 

Detailed Description

Word source generated from a text file.

Derives from TextWordsource, so all members are implemented without change.

Constructor & Destructor Documentation

◆ __init__()

def pycross.wordsrc.TextfileWordsource.__init__ (   self,
  path,
  enc = ENCODING,
  delimiter = ' ',
  max_fetch = None,
  shuffle = True 
)

Constructor.

Parameters
pathstr full path to the source text file
encstr file encoding (default = UTF8)
delimiterstr field delimiter character in text file (default = whitespace)
max_fetchint maximum number of suggestions returned from the word source
Warning
None means no limit on suggestions, which may be time/resource consuming!
Parameters
shufflebool if True, fetched words will be shuffled

Member Function Documentation

◆ _read_data()

def pycross.wordsrc.TextfileWordsource._read_data (   self,
  path,
  enc = ENCODING,
  delimiter = ' ' 
)
private

Member Data Documentation

◆ words

pycross.wordsrc.TextfileWordsource.words

The documentation for this class was generated from the following file: