id int64 0 190k | prompt stringlengths 21 13.4M | docstring stringlengths 1 12k ⌀ |
|---|---|---|
170,710 | import os
import re
import shelve
import sys
import nltk.data
The provided code snippet includes necessary dependencies for implementing the `val_load` function. Write a Python function `def val_load(db)` to solve the following problem:
Load a ``Valuation`` from a persistent database. :param db: name of file from whic... | Load a ``Valuation`` from a persistent database. :param db: name of file from which data is read. The suffix '.db' should be omitted from the name. :type db: str |
170,711 | import os
import re
import shelve
import sys
import nltk.data
def sql_query(dbname, query):
"""
Execute an SQL query over a database.
:param dbname: filename of persistent store
:type schema: str
:param query: SQL query
:type rel_name: str
"""
import sqlite3
try:
path = nltk.... | Print out every row from the 'city.db' database. |
170,712 | import operator
from functools import reduce
from itertools import chain
from nltk.sem.logic import (
APP,
AbstractVariableExpression,
AllExpression,
AndExpression,
ApplicationExpression,
BinaryExpression,
BooleanExpression,
ConstantExpression,
EqualityExpression,
EventVariableEx... | This is a factory method that instantiates and returns a subtype of ``DrtAbstractVariableExpression`` appropriate for the given variable. |
170,713 | import operator
from functools import reduce
from itertools import chain
from nltk.sem.logic import (
APP,
AbstractVariableExpression,
AllExpression,
AndExpression,
ApplicationExpression,
BinaryExpression,
BooleanExpression,
ConstantExpression,
EqualityExpression,
EventVariableEx... | null |
170,714 | import operator
from functools import reduce
from itertools import chain
from nltk.sem.logic import (
APP,
AbstractVariableExpression,
AllExpression,
AndExpression,
ApplicationExpression,
BinaryExpression,
BooleanExpression,
ConstantExpression,
EqualityExpression,
EventVariableEx... | null |
170,715 | import operator
from functools import reduce
from itertools import chain
from nltk.sem.logic import (
APP,
AbstractVariableExpression,
AllExpression,
AndExpression,
ApplicationExpression,
BinaryExpression,
BooleanExpression,
ConstantExpression,
EqualityExpression,
EventVariableEx... | null |
170,716 | from itertools import chain
from nltk.internals import Counter
class FStructure(dict):
def safeappend(self, key, item):
"""
Append 'item' to the list at 'key'. If no list exists for 'key', then
construct one.
"""
if key not in self:
self[key] = []
self[ke... | null |
170,717 | import inspect
import re
import sys
import textwrap
from pprint import pformat
from nltk.decorators import decorator
from nltk.sem.logic import (
AbstractVariableExpression,
AllExpression,
AndExpression,
ApplicationExpression,
EqualityExpression,
ExistsExpression,
Expression,
IffExpress... | Check whether a set represents a relation (of any arity). :param s: a set containing tuples of str elements :type s: set :rtype: bool |
170,718 | import inspect
import re
import sys
import textwrap
from pprint import pformat
from nltk.decorators import decorator
from nltk.sem.logic import (
AbstractVariableExpression,
AllExpression,
AndExpression,
ApplicationExpression,
EqualityExpression,
ExistsExpression,
Expression,
IffExpress... | Convert a set containing individuals (strings or numbers) into a set of unary tuples. Any tuples of strings already in the set are passed through unchanged. For example: - set(['a', 'b']) => set([('a',), ('b',)]) - set([3, 27]) => set([('3',), ('27',)]) :type s: set :rtype: set of tuple of str |
170,719 | import inspect
import re
import sys
import textwrap
from pprint import pformat
from nltk.decorators import decorator
from nltk.sem.logic import (
AbstractVariableExpression,
AllExpression,
AndExpression,
ApplicationExpression,
EqualityExpression,
ExistsExpression,
Expression,
IffExpress... | Check the arity of a relation. :type rel: set of tuples :rtype: int of tuple of str |
170,720 | import inspect
import re
import sys
import textwrap
from pprint import pformat
from nltk.decorators import decorator
from nltk.sem.logic import (
AbstractVariableExpression,
AllExpression,
AndExpression,
ApplicationExpression,
EqualityExpression,
ExistsExpression,
Expression,
IffExpress... | Convert a valuation string into a valuation. :param s: a valuation string :type s: str :param encoding: the encoding of the input string, if it is binary :type encoding: str :return: a ``nltk.sem`` valuation :rtype: Valuation |
170,721 | import inspect
import re
import sys
import textwrap
from pprint import pformat
from nltk.decorators import decorator
from nltk.sem.logic import (
AbstractVariableExpression,
AllExpression,
AndExpression,
ApplicationExpression,
EqualityExpression,
ExistsExpression,
Expression,
IffExpress... | Run exists demos. - num = 1: propositional logic demo - num = 2: first order model demo (only if trace is set) - num = 3: first order sentences demo - num = 4: satisfaction of open formulas demo - any other value: run all the demos :param trace: trace = 1, or trace = 2 for more verbose tracing |
170,722 | import gc
import re
import nltk
The provided code snippet includes necessary dependencies for implementing the `_make_bound_method` function. Write a Python function `def _make_bound_method(func, self)` to solve the following problem:
Magic for creating bound methods (used for _unload).
Here is the function:
def _ma... | Magic for creating bound methods (used for _unload). |
170,723 | import functools
from nltk.corpus.reader.api import CorpusReader
from nltk.corpus.reader.util import StreamBackedCorpusView, concat
def _parse_args(fun):
@functools.wraps(fun)
def decorator(self, fileids=None, **kwargs):
kwargs.pop("tags", None)
if not fileids:
fileids = self.fileid... | null |
170,724 | from collections import namedtuple
from functools import partial, wraps
from nltk.corpus.reader.api import CategorizedCorpusReader
from nltk.corpus.reader.plaintext import PlaintextCorpusReader
from nltk.corpus.reader.util import concat, read_blankline_block
from nltk.tokenize import blankline_tokenize, sent_tokenize, ... | A decorator that allows a function to be called with a single string of comma-separated values which become individual function arguments. |
170,725 | from collections import namedtuple
from functools import partial, wraps
from nltk.corpus.reader.api import CategorizedCorpusReader
from nltk.corpus.reader.plaintext import PlaintextCorpusReader
from nltk.corpus.reader.util import concat, read_blankline_block
from nltk.tokenize import blankline_tokenize, sent_tokenize, ... | null |
170,726 | import bisect
import os
import pickle
import re
import tempfile
from functools import reduce
from xml.etree import ElementTree
from nltk.data import (
FileSystemPathPointer,
PathPointer,
SeekableUnicodeStreamReader,
ZipFilePathPointer,
)
from nltk.internals import slice_bounds
from nltk.tokenize import ... | Concatenate together the contents of multiple documents from a single corpus, using an appropriate concatenation function. This utility function is used by corpus readers when the user requests more than one document at a time. |
170,727 | import bisect
import os
import pickle
import re
import tempfile
from functools import reduce
from xml.etree import ElementTree
from nltk.data import (
FileSystemPathPointer,
PathPointer,
SeekableUnicodeStreamReader,
ZipFilePathPointer,
)
from nltk.internals import slice_bounds
from nltk.tokenize import ... | null |
170,728 | import bisect
import os
import pickle
import re
import tempfile
from functools import reduce
from xml.etree import ElementTree
from nltk.data import (
FileSystemPathPointer,
PathPointer,
SeekableUnicodeStreamReader,
ZipFilePathPointer,
)
from nltk.internals import slice_bounds
from nltk.tokenize import ... | null |
170,729 | import bisect
import os
import pickle
import re
import tempfile
from functools import reduce
from xml.etree import ElementTree
from nltk.data import (
FileSystemPathPointer,
PathPointer,
SeekableUnicodeStreamReader,
ZipFilePathPointer,
)
from nltk.internals import slice_bounds
from nltk.tokenize import ... | null |
170,730 | import bisect
import os
import pickle
import re
import tempfile
from functools import reduce
from xml.etree import ElementTree
from nltk.data import (
FileSystemPathPointer,
PathPointer,
SeekableUnicodeStreamReader,
ZipFilePathPointer,
)
from nltk.internals import slice_bounds
from nltk.tokenize import ... | null |
170,731 | import bisect
import os
import pickle
import re
import tempfile
from functools import reduce
from xml.etree import ElementTree
from nltk.data import (
FileSystemPathPointer,
PathPointer,
SeekableUnicodeStreamReader,
ZipFilePathPointer,
)
from nltk.internals import slice_bounds
from nltk.tokenize import ... | Read a sequence of tokens from a stream, where tokens begin with lines that match ``start_re``. If ``end_re`` is specified, then tokens end with lines that match ``end_re``; otherwise, tokens end whenever the next line matching ``start_re`` or EOF is found. |
170,732 | import bisect
import os
import pickle
import re
import tempfile
from functools import reduce
from xml.etree import ElementTree
from nltk.data import (
FileSystemPathPointer,
PathPointer,
SeekableUnicodeStreamReader,
ZipFilePathPointer,
)
from nltk.internals import slice_bounds
from nltk.tokenize import ... | Read a sequence of s-expressions from the stream, and leave the stream's file position at the end the last complete s-expression read. This function will always return at least one s-expression, unless there are no more s-expressions in the file. If the file ends in in the middle of an s-expression, then that incomplet... |
170,733 | import bisect
import os
import pickle
import re
import tempfile
from functools import reduce
from xml.etree import ElementTree
from nltk.data import (
FileSystemPathPointer,
PathPointer,
SeekableUnicodeStreamReader,
ZipFilePathPointer,
)
from nltk.internals import slice_bounds
from nltk.tokenize import ... | null |
170,734 | import re
from collections import defaultdict
from functools import reduce
from nltk.corpus.reader import CorpusReader
lin_thesaurus: LinThesaurusCorpusReader = LazyCorpusLoader(
"lin_thesaurus", LinThesaurusCorpusReader, r".*\.lsp"
)
def demo():
from nltk.corpus import lin_thesaurus as thes
word1 = "bus... | null |
170,735 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing any AttrDict object. :param obj: The obj to be printed. :type obj: AttrDict :return: A nicely formatted string representation of the AttrDict object. :rtype: str |
170,736 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing a semantic type. :param st: The semantic type to be printed. :type st: AttrDict :return: A nicely formatted string representation of the semantic type. :rtype: str |
170,737 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing a frame relation type. :param freltyp: The frame relation type to be printed. :type freltyp: AttrDict :return: A nicely formatted string representation of the frame relation type. :rtype: str |
170,738 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing a frame relation. :param frel: The frame relation to be printed. :type frel: AttrDict :return: A nicely formatted string representation of the frame relation. :rtype: str |
170,739 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing an FE relation. :param ferel: The FE relation to be printed. :type ferel: AttrDict :return: A nicely formatted string representation of the FE relation. :rtype: str |
170,740 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing a lexical unit. :param lu: The lu to be printed. :type lu: AttrDict :return: A nicely formatted string representation of the lexical unit. :rtype: str |
170,741 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing a list of exemplar sentences for a lexical unit. :param sent: The list of exemplar sentences to be printed. :type sent: list(AttrDict) :return: An index of the text of the exemplar sentences. :rtype: str |
170,742 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing a list of annotated sentences for a full-text document. :param sent: The list of sentences to be printed. :type sent: list(AttrDict) :return: An index of the text of the sentences. :rtype: str |
170,743 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing an annotated sentence from a full-text document. :param sent: The sentence to be printed. :type sent: list(AttrDict) :return: The text of the sentence with annotation set indices on frame targets. :rtype: str |
170,744 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing a sentence with its POS tags. :param aset: The POS annotation set of the sentence to be printed. :type sent: list(AttrDict) :return: The text of the sentence and its POS tags. :rtype: str |
170,745 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing an exemplar sentence for a lexical unit. :param sent: An annotation set or exemplar sentence to be printed. :param aset_level: If True, 'sent' is actually an annotation set within a sentence. :type sent: AttrDict :return: A nicely formatted string representation of the exemplar sente... |
170,746 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Given a sentence or FE annotation set, construct the width-limited string showing an ASCII visualization of the sentence's annotations, calling either _annotation_ascii_frames() or _annotation_ascii_FEs() as appropriate. This will be attached as a method to appropriate AttrDict instances and called in the full pretty-p... |
170,747 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing a frame element. :param fe: The frame element to be printed. :type fe: AttrDict :return: A nicely formatted string representation of the frame element. :rtype: str |
170,748 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | Helper function for pretty-printing a frame. :param frame: The frame to be printed. :type frame: AttrDict :return: A nicely formatted string representation of the frame. :rtype: str |
170,749 | import itertools
import os
import re
import sys
import textwrap
import types
from collections import OrderedDict, defaultdict
from itertools import zip_longest
from operator import itemgetter
from pprint import pprint
from nltk.corpus.reader import XMLCorpusReader, XMLCorpusView
from nltk.util import LazyConcatenation,... | null |
170,750 | import re
from xml.etree import ElementTree
from nltk.corpus.reader.api import *
from nltk.corpus.reader.util import *
from nltk.tokenize import *
The provided code snippet includes necessary dependencies for implementing the `_fixXML` function. Write a Python function `def _fixXML(text)` to solve the following proble... | Fix the various issues with Senseval pseudo-XML. |
170,751 | import sys
from nltk.corpus.reader import util
from nltk.corpus.reader.api import *
from nltk.corpus.reader.util import *
class ChasenCorpusReader(CorpusReader):
def __init__(self, root, fileids, encoding="utf8", sent_splitter=None):
self._sent_splitter = sent_splitter
CorpusReader.__init__(self, ro... | null |
170,752 | import functools
import os
import re
import tempfile
from nltk.corpus.reader.util import concat
from nltk.corpus.reader.xmldocs import XMLCorpusReader, XMLCorpusView
The provided code snippet includes necessary dependencies for implementing the `_parse_args` function. Write a Python function `def _parse_args(fun)` to ... | Wraps function arguments: if fileids not specified then function set NKJPCorpusReader paths. |
170,753 | from nltk.corpus.reader.api import *
from nltk.corpus.reader.util import *
from nltk.toolbox import ToolboxData
def demo():
pass | null |
170,754 | import os
import re
from functools import reduce
from nltk.corpus.reader import TaggedCorpusReader, concat
from nltk.corpus.reader.xmldocs import XMLCorpusView
def xpath(root, path, ns):
return root.findall(path, ns) | null |
170,755 | import re
from nltk.corpus.reader.api import CorpusReader, SyntaxCorpusReader
from nltk.corpus.reader.util import (
FileSystemPathPointer,
find_corpus_fileids,
read_blankline_block,
)
from nltk.parse import DependencyGraph
class KNBCorpusReader(SyntaxCorpusReader):
"""
This class implements:
-... | null |
170,756 | from nltk.corpus.reader.api import *
from nltk.corpus.reader.util import *
from nltk.util import Index
def read_cmudict_block(stream):
entries = []
while len(entries) < 100: # Read 100 at a time.
line = stream.readline()
if line == "":
return entries # end of file.
pieces ... | null |
170,757 | import sys
import time
from nltk.corpus.reader.api import *
from nltk.internals import import_from_stdlib
from nltk.tree import Tree
The provided code snippet includes necessary dependencies for implementing the `read_timit_block` function. Write a Python function `def read_timit_block(stream)` to solve the following ... | Block reader for timit tagged sentences, which are preceded by a sentence number that will be ignored. |
170,758 | import math
import os
import re
import warnings
from collections import defaultdict, deque
from functools import total_ordering
from itertools import chain, islice
from operator import itemgetter
from nltk.corpus.reader import CorpusReader
from nltk.internals import deprecated
from nltk.probability import FreqDist
from... | null |
170,759 | import math
import os
import re
import warnings
from collections import defaultdict, deque
from functools import total_ordering
from itertools import chain, islice
from operator import itemgetter
from nltk.corpus.reader import CorpusReader
from nltk.internals import deprecated
from nltk.probability import FreqDist
from... | null |
170,760 | import math
import os
import re
import warnings
from collections import defaultdict, deque
from functools import total_ordering
from itertools import chain, islice
from operator import itemgetter
from nltk.corpus.reader import CorpusReader
from nltk.internals import deprecated
from nltk.probability import FreqDist
from... | null |
170,761 | import math
import os
import re
import warnings
from collections import defaultdict, deque
from functools import total_ordering
from itertools import chain, islice
from operator import itemgetter
from nltk.corpus.reader import CorpusReader
from nltk.internals import deprecated
from nltk.probability import FreqDist
from... | null |
170,762 | import math
import os
import re
import warnings
from collections import defaultdict, deque
from functools import total_ordering
from itertools import chain, islice
from operator import itemgetter
from nltk.corpus.reader import CorpusReader
from nltk.internals import deprecated
from nltk.probability import FreqDist
from... | null |
170,763 | import math
import os
import re
import warnings
from collections import defaultdict, deque
from functools import total_ordering
from itertools import chain, islice
from operator import itemgetter
from nltk.corpus.reader import CorpusReader
from nltk.internals import deprecated
from nltk.probability import FreqDist
from... | null |
170,764 | import math
import os
import re
import warnings
from collections import defaultdict, deque
from functools import total_ordering
from itertools import chain, islice
from operator import itemgetter
from nltk.corpus.reader import CorpusReader
from nltk.internals import deprecated
from nltk.probability import FreqDist
from... | Get the information content of the least common subsumer that has the highest information content value. If two nodes have no explicit common subsumer, assume that they share an artificial root node that is the hypernym of all explicit roots. :type synset1: Synset :param synset1: First input synset. :type synset2: Syns... |
170,765 | import math
import os
import re
import warnings
from collections import defaultdict, deque
from functools import total_ordering
from itertools import chain, islice
from operator import itemgetter
from nltk.corpus.reader import CorpusReader
from nltk.internals import deprecated
from nltk.probability import FreqDist
from... | null |
170,766 | from nltk.corpus.reader.api import *
from nltk.corpus.reader.xmldocs import XMLCorpusReader, XMLCorpusView
from nltk.tree import Tree
def _all_xmlwords_in(elt, result=None):
if result is None:
result = []
for child in elt:
if child.tag in ("wf", "punc"):
result.append(child)
... | null |
170,767 | from nltk.corpus.reader.api import *
from nltk.corpus.reader.util import *
from nltk.corpus.reader.xmldocs import *
The provided code snippet includes necessary dependencies for implementing the `norm` function. Write a Python function `def norm(value_string)` to solve the following problem:
Normalize the string value... | Normalize the string value in an RTE pair's ``value`` or ``entailment`` attribute as an integer (1, 0). :param value_string: the label used to classify a text/hypothesis pair :type value_string: str :rtype: int |
170,768 | import re
from collections import defaultdict
from nltk.corpus.reader.util import concat
from nltk.corpus.reader.xmldocs import ElementTree, XMLCorpusReader
from nltk.util import LazyConcatenation, LazyMap, flatten
class CHILDESCorpusReader(XMLCorpusReader):
"""
Corpus reader for the XML version of the CHILDES ... | The CHILDES corpus should be manually downloaded and saved to ``[NLTK_Data_Dir]/corpora/childes/`` |
170,769 | from nltk.corpus.reader.util import concat
from nltk.corpus.reader.xmldocs import ElementTree, XMLCorpusReader, XMLCorpusView
def _all_xmlwords_in(elt, result=None):
if result is None:
result = []
for child in elt:
if child.tag in ("c", "w"):
result.append(child)
else:
... | null |
170,770 | import sys
import inspect
def getinfo(func):
"""
Returns an info dictionary containing:
- name (the name of the function : str)
- argnames (the names of the arguments : list)
- defaults (the values of the default arguments : tuple)
- signature (the signature : str)
- fullsignature (the full ... | General purpose decorator factory: takes a caller function as input and returns a decorator with the same attributes. A caller function is any function like this:: def caller(func, *args, **kw): # do something return func(*args, **kw) Here is an example of usage: >>> @decorator ... def chatty(f, *args, **kw): ... print... |
170,771 | import sys
import inspect
def getattr_(obj, name, default_thunk):
"Similar to .setdefault in dictionaries."
try:
return getattr(obj, name)
except AttributeError:
default = default_thunk()
setattr(obj, name, default)
return default
def memoize(func, *args):
dic = getattr_... | null |
170,772 | import fnmatch
import locale
import os
import re
import stat
import subprocess
import sys
import textwrap
import types
import warnings
from xml.etree import ElementTree
_java_bin = None
_java_options = []
def config_java(bin=None, options=None, verbose=False):
"""
Configure nltk's java interface, by letting nlt... | Execute the given java command, by opening a subprocess that calls Java. If java has not yet been configured, it will be configured by calling ``config_java()`` with no arguments. :param cmd: The java command that should be called, formatted as a list of strings. Typically, the first string will be the name of the java... |
170,773 | import fnmatch
import locale
import os
import re
import stat
import subprocess
import sys
import textwrap
import types
import warnings
from xml.etree import ElementTree
class ReadError(ValueError):
"""
Exception raised by read_* functions when they fail.
:param position: The index in the input string where ... | If a Python string literal begins at the specified position in the given string, then return a tuple ``(val, end_position)`` containing the value of the string literal and the position where it ends. Otherwise, raise a ``ReadError``. :param s: A string that will be checked to see if within which a Python string literal... |
170,774 | import fnmatch
import locale
import os
import re
import stat
import subprocess
import sys
import textwrap
import types
import warnings
from xml.etree import ElementTree
class ReadError(ValueError):
"""
Exception raised by read_* functions when they fail.
:param position: The index in the input string where ... | If an integer begins at the specified position in the given string, then return a tuple ``(val, end_position)`` containing the value of the integer and the position where it ends. Otherwise, raise a ``ReadError``. :param s: A string that will be checked to see if within which a Python integer exists. :type s: str :para... |
170,775 | import fnmatch
import locale
import os
import re
import stat
import subprocess
import sys
import textwrap
import types
import warnings
from xml.etree import ElementTree
class ReadError(ValueError):
"""
Exception raised by read_* functions when they fail.
:param position: The index in the input string where ... | If an integer or float begins at the specified position in the given string, then return a tuple ``(val, end_position)`` containing the value of the number and the position where it ends. Otherwise, raise a ``ReadError``. :param s: A string that will be checked to see if within which a Python number exists. :type s: st... |
170,776 | import fnmatch
import locale
import os
import re
import stat
import subprocess
import sys
import textwrap
import types
import warnings
from xml.etree import ElementTree
def _mro(cls):
"""
Return the method resolution order for ``cls`` -- i.e., a list
containing ``cls`` and all its base classes, in the order... | :return: True if ``method`` overrides some method with the same name in a base class. This is typically used when defining abstract base classes or interfaces, to allow subclasses to define either of two related methods: >>> class EaterI: ... '''Subclass must define eat() or batch_eat().''' ... def eat(self, food): ...... |
170,777 | import fnmatch
import locale
import os
import re
import stat
import subprocess
import sys
import textwrap
import types
import warnings
from xml.etree import ElementTree
def _add_epytext_field(obj, field, message):
"""Add an epytext @field to a given object's docstring."""
indent = ""
# If we already have a ... | A decorator used to mark functions as deprecated. This will cause a warning to be printed the when the function is used. Usage: >>> from nltk.internals import deprecated >>> @deprecated('Use foo() instead') ... def bar(x): ... print(x/10) |
170,778 | import fnmatch
import locale
import os
import re
import stat
import subprocess
import sys
import textwrap
import types
import warnings
from xml.etree import ElementTree
def find_jar_iter(
name_pattern,
path_to_jar=None,
env_vars=(),
searchpath=(),
url=None,
verbose=False,
is_regex=False,
):
... | null |
170,779 | import fnmatch
import locale
import os
import re
import stat
import subprocess
import sys
import textwrap
import types
import warnings
from xml.etree import ElementTree
The provided code snippet includes necessary dependencies for implementing the `import_from_stdlib` function. Write a Python function `def import_from... | When python is run from within the nltk/ directory tree, the current directory is included at the beginning of the search path. Unfortunately, that means that modules within nltk can sometimes shadow standard library modules. As an example, the stdlib 'inspect' module will attempt to import the stdlib 'tokenize' module... |
170,780 | import fnmatch
import locale
import os
import re
import stat
import subprocess
import sys
import textwrap
import types
import warnings
from xml.etree import ElementTree
The provided code snippet includes necessary dependencies for implementing the `slice_bounds` function. Write a Python function `def slice_bounds(sequ... | Given a slice, return the corresponding (start, stop) bounds, taking into account None indices and negative indices. The following guarantees are made for the returned start and stop values: - 0 <= start <= len(sequence) - 0 <= stop <= len(sequence) - start <= stop :raise ValueError: If ``slice_obj.step`` is not None. ... |
170,781 | import fnmatch
import locale
import os
import re
import stat
import subprocess
import sys
import textwrap
import types
import warnings
from xml.etree import ElementTree
def is_writable(path):
# Ensure that it exists.
if not os.path.exists(path):
return False
# If we're on a posix system, check its... | null |
170,782 | import fnmatch
import locale
import os
import re
import stat
import subprocess
import sys
import textwrap
import types
import warnings
from xml.etree import ElementTree
def raise_unorderable_types(ordering, a, b):
raise TypeError(
"unorderable types: %s() %s %s()"
% (type(a).__name__, ordering, typ... | null |
170,783 | import functools
import re
import nltk.tree
def _build_tgrep_parser(set_parse_actions=True):
"""
Builds a pyparsing-based parser object for tokenizing and
interpreting tgrep search strings.
"""
tgrep_op = pyparsing.Optional("!") + pyparsing.Regex("[$%,.<>][%,.<>0-9-':]*")
tgrep_qstring = pyparsi... | Tokenizes a TGrep search string into separate tokens. |
170,784 | import functools
import re
import nltk.tree
def tgrep_compile(tgrep_string):
"""
Parses (and tokenizes, if necessary) a TGrep search string into a
lambda function.
"""
parser = _build_tgrep_parser(True)
if isinstance(tgrep_string, bytes):
tgrep_string = tgrep_string.decode()
return l... | Return the tree positions in the trees which match the given pattern. :param pattern: a tgrep search pattern :type pattern: str or output of tgrep_compile() :param trees: a sequence of NLTK trees (usually ParentedTrees) :type trees: iter(ParentedTree) or iter(Tree) :param search_leaves: whether to return matching leaf ... |
170,785 | import functools
import re
import nltk.tree
def tgrep_compile(tgrep_string):
"""
Parses (and tokenizes, if necessary) a TGrep search string into a
lambda function.
"""
parser = _build_tgrep_parser(True)
if isinstance(tgrep_string, bytes):
tgrep_string = tgrep_string.decode()
return l... | Return the tree nodes in the trees which match the given pattern. :param pattern: a tgrep search pattern :type pattern: str or output of tgrep_compile() :param trees: a sequence of NLTK trees (usually ParentedTrees) :type trees: iter(ParentedTree) or iter(Tree) :param search_leaves: whether to return matching leaf node... |
170,786 | from nltk.corpus import (
genesis,
gutenberg,
inaugural,
nps_chat,
treebank,
webtext,
wordnet,
)
from nltk.probability import FreqDist
from nltk.text import Text
from nltk.util import bigrams
print("*** Introductory Examples for the NLTK Book ***")
print("Loading text1, ..., text9 and sent1,... | null |
170,787 | from nltk.corpus import (
genesis,
gutenberg,
inaugural,
nps_chat,
treebank,
webtext,
wordnet,
)
from nltk.probability import FreqDist
from nltk.text import Text
from nltk.util import bigrams
print("*** Introductory Examples for the NLTK Book ***")
print("Loading text1, ..., text9 and sent1,... | null |
170,788 | from nltk.corpus import wordnet
wordnet: WordNetCorpusReader = LazyCorpusLoader(
"wordnet",
WordNetCorpusReader,
LazyCorpusLoader("omw-1.4", CorpusReader, r".*/wn-data-.*\.tab", encoding="utf8"),
)
The provided code snippet includes necessary dependencies for implementing the `lesk` function. Write a Pyth... | Return a synset for an ambiguous word in a context. :param iter context_sentence: The context sentence where the ambiguous word occurs, passed as an iterable of words. :param str ambiguous_word: The ambiguous word that requires WSD. :param str pos: A specified Part-of-Speech (POS). :param iter synsets: Possible synsets... |
170,789 | import re
import sys
from collections import Counter, defaultdict, namedtuple
from functools import reduce
from math import log
from nltk.collocations import BigramCollocationFinder
from nltk.lm import MLE
from nltk.lm.preprocessing import padded_everygram_pipeline
from nltk.metrics import BigramAssocMeasures, f_measur... | null |
170,790 |
The provided code snippet includes necessary dependencies for implementing the `error_list` function. Write a Python function `def error_list(train_sents, test_sents)` to solve the following problem:
Returns a list of human-readable strings indicating the errors in the given tagging of the corpus. :param train_sents:... | Returns a list of human-readable strings indicating the errors in the given tagging of the corpus. :param train_sents: The correct tagging of the corpus :type train_sents: list(tuple) :param test_sents: The tagged corpus :type test_sents: list(tuple) |
170,791 | import os
import pickle
import random
import time
from nltk.corpus import treebank
from nltk.tag import BrillTaggerTrainer, RegexpTagger, UnigramTagger
from nltk.tag.brill import Pos, Word
from nltk.tbl import Template, error_list
def postag(
templates=None,
tagged_data=None,
num_sents=1000,
max_rules=3... | Run a demo with defaults. See source comments for details, or docstrings of any of the more specific demo_* functions. |
170,792 | import os
import pickle
import random
import time
from nltk.corpus import treebank
from nltk.tag import BrillTaggerTrainer, RegexpTagger, UnigramTagger
from nltk.tag.brill import Pos, Word
from nltk.tbl import Template, error_list
def postag(
templates=None,
tagged_data=None,
num_sents=1000,
max_rules=3... | Exemplify repr(Rule) (see also str(Rule) and Rule.format("verbose")) |
170,793 | import os
import pickle
import random
import time
from nltk.corpus import treebank
from nltk.tag import BrillTaggerTrainer, RegexpTagger, UnigramTagger
from nltk.tag.brill import Pos, Word
from nltk.tbl import Template, error_list
def postag(
templates=None,
tagged_data=None,
num_sents=1000,
max_rules=3... | Exemplify repr(Rule) (see also str(Rule) and Rule.format("verbose")) |
170,794 | import os
import pickle
import random
import time
from nltk.corpus import treebank
from nltk.tag import BrillTaggerTrainer, RegexpTagger, UnigramTagger
from nltk.tag.brill import Pos, Word
from nltk.tbl import Template, error_list
def postag(
templates=None,
tagged_data=None,
num_sents=1000,
max_rules=3... | Exemplify Rule.format("verbose") |
170,795 | import os
import pickle
import random
import time
from nltk.corpus import treebank
from nltk.tag import BrillTaggerTrainer, RegexpTagger, UnigramTagger
from nltk.tag.brill import Pos, Word
from nltk.tbl import Template, error_list
def postag(
templates=None,
tagged_data=None,
num_sents=1000,
max_rules=3... | The feature/s of a template takes a list of positions relative to the current word where the feature should be looked for, conceptually joined by logical OR. For instance, Pos([-1, 1]), given a value V, will hold whenever V is found one step to the left and/or one step to the right. For contiguous ranges, a 2-arg form ... |
170,796 | import os
import pickle
import random
import time
from nltk.corpus import treebank
from nltk.tag import BrillTaggerTrainer, RegexpTagger, UnigramTagger
from nltk.tag.brill import Pos, Word
from nltk.tbl import Template, error_list
def postag(
templates=None,
tagged_data=None,
num_sents=1000,
max_rules=3... | Templates can have more than a single feature. |
170,797 | import os
import pickle
import random
import time
from nltk.corpus import treebank
from nltk.tag import BrillTaggerTrainer, RegexpTagger, UnigramTagger
from nltk.tag.brill import Pos, Word
from nltk.tbl import Template, error_list
def postag(
templates=None,
tagged_data=None,
num_sents=1000,
max_rules=3... | Show aggregate statistics per template. Little used templates are candidates for deletion, much used templates may possibly be refined. Deleting unused templates is mostly about saving time and/or space: training is basically O(T) in the number of templates T (also in terms of memory usage, which often will be the limi... |
170,798 | import os
import pickle
import random
import time
from nltk.corpus import treebank
from nltk.tag import BrillTaggerTrainer, RegexpTagger, UnigramTagger
from nltk.tag.brill import Pos, Word
from nltk.tbl import Template, error_list
def postag(
templates=None,
tagged_data=None,
num_sents=1000,
max_rules=3... | Template.expand and Feature.expand are class methods facilitating generating large amounts of templates. See their documentation for details. Note: training with 500 templates can easily fill all available even on relatively small corpora |
170,799 | import os
import pickle
import random
import time
from nltk.corpus import treebank
from nltk.tag import BrillTaggerTrainer, RegexpTagger, UnigramTagger
from nltk.tag.brill import Pos, Word
from nltk.tbl import Template, error_list
def postag(
templates=None,
tagged_data=None,
num_sents=1000,
max_rules=3... | Plot a learning curve -- the contribution on tagging accuracy of the individual rules. Note: requires matplotlib |
170,800 | import os
import pickle
import random
import time
from nltk.corpus import treebank
from nltk.tag import BrillTaggerTrainer, RegexpTagger, UnigramTagger
from nltk.tag.brill import Pos, Word
from nltk.tbl import Template, error_list
def postag(
templates=None,
tagged_data=None,
num_sents=1000,
max_rules=3... | Writes a file with context for each erroneous word after tagging testing data |
170,801 | import os
import pickle
import random
import time
from nltk.corpus import treebank
from nltk.tag import BrillTaggerTrainer, RegexpTagger, UnigramTagger
from nltk.tag.brill import Pos, Word
from nltk.tbl import Template, error_list
def postag(
templates=None,
tagged_data=None,
num_sents=1000,
max_rules=3... | Serializes the learned tagger to a file in pickle format; reloads it and validates the process. |
170,802 | import os
import pickle
import random
import time
from nltk.corpus import treebank
from nltk.tag import BrillTaggerTrainer, RegexpTagger, UnigramTagger
from nltk.tag.brill import Pos, Word
from nltk.tbl import Template, error_list
def postag(
templates=None,
tagged_data=None,
num_sents=1000,
max_rules=3... | Discard rules with low accuracy. This may hurt performance a bit, but will often produce rules which are more interesting read to a human. |
170,803 | import re
from collections import defaultdict
from nltk.ccg.api import CCGVar, Direction, FunctionalCategory, PrimitiveCategory
from nltk.internals import deprecated
from nltk.sem.logic import Expression
def fromstring(lex_str, include_semantics=False):
def parseLexicon(lex_str):
return fromstring(lex_str) | null |
170,804 | from abc import ABCMeta, abstractmethod
from nltk.ccg.api import FunctionalCategory
def forwardOnly(left, right):
return left.dir().is_forward() | null |
170,805 | from abc import ABCMeta, abstractmethod
from nltk.ccg.api import FunctionalCategory
def backwardOnly(left, right):
return right.dir().is_backward() | null |
170,806 | from abc import ABCMeta, abstractmethod
from nltk.ccg.api import FunctionalCategory
def bothBackward(left, right):
return left.dir().is_backward() and right.dir().is_backward() | null |
170,807 | from abc import ABCMeta, abstractmethod
from nltk.ccg.api import FunctionalCategory
def crossedDirs(left, right):
return left.dir().is_forward() and right.dir().is_backward()
def backwardBxConstraint(left, right):
# The functors must be crossed inwards
if not crossedDirs(left, right):
return False
... | null |
170,808 | from abc import ABCMeta, abstractmethod
from nltk.ccg.api import FunctionalCategory
def bothForward(left, right):
return left.dir().is_forward() and right.dir().is_forward()
def forwardSConstraint(left, right):
if not bothForward(left, right):
return False
return left.res().dir().is_forward() and l... | null |
170,809 | from abc import ABCMeta, abstractmethod
from nltk.ccg.api import FunctionalCategory
def bothForward(left, right):
def backwardSxConstraint(left, right):
if not left.dir().can_cross() and right.dir().can_cross():
return False
if not bothForward(left, right):
return False
return right.res().d... | null |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.