def __init__(self, word): """ Create a word filter. Irrelevant members can be left null. @param word: The word containing the conditions to include. @type word: Word """ if not isinstance(word, Word): raise TypeError(word) Literal.__init__(self, (word.form, word.lemma.entry_form, word.lemma.id, None, None, word.categories))
def __init__(self, p_o_s=None, lemma_categories=None, categories=None): """ Create a word category filter. Irrelevant fields can be left null. @param p_o_s: The part of speech to match. @type p_o_s: str @param lemma_categories: The lemma category to match. @type lemma_categories: tuple of str/CategoryFilter @param categories: The word category to match. @type categories: tuple of str/CategoryFilter """ if lemma_categories is not None and not isinstance(lemma_categories, tuple): raise TypeError(lemma_categories) if categories is not None and not isinstance(categories, tuple): raise TypeError(categories) Literal.__init__(self, (None, None, None, p_o_s, lemma_categories, categories))
#!/usr/bin/env python from bnf import Context from bnf import Literal if __name__ == '__main__': context = Context('filename') # language ::= "Hello, World!" language = Literal('Hello, World!') language.parse(context)