repository_name
stringlengths
7
55
func_path_in_repository
stringlengths
4
223
func_name
stringlengths
1
134
whole_func_string
stringlengths
75
104k
language
stringclasses
1 value
func_code_string
stringlengths
75
104k
func_code_tokens
listlengths
19
28.4k
func_documentation_string
stringlengths
1
46.9k
func_documentation_tokens
listlengths
1
1.97k
split_name
stringclasses
1 value
func_code_url
stringlengths
87
315
IceflowRE/unidown
unidown/plugin/a_plugin.py
APlugin.get_plugins
def get_plugins() -> Dict[str, pkg_resources.EntryPoint]: """ Get all available plugins for unidown. :return: plugin name list :rtype: Dict[str, ~pkg_resources.EntryPoint] """ return {entry.name: entry for entry in pkg_resources.iter_entry_points('unidown.plugin')}
python
def get_plugins() -> Dict[str, pkg_resources.EntryPoint]: """ Get all available plugins for unidown. :return: plugin name list :rtype: Dict[str, ~pkg_resources.EntryPoint] """ return {entry.name: entry for entry in pkg_resources.iter_entry_points('unidown.plugin')}
[ "def", "get_plugins", "(", ")", "->", "Dict", "[", "str", ",", "pkg_resources", ".", "EntryPoint", "]", ":", "return", "{", "entry", ".", "name", ":", "entry", "for", "entry", "in", "pkg_resources", ".", "iter_entry_points", "(", "'unidown.plugin'", ")", "...
Get all available plugins for unidown. :return: plugin name list :rtype: Dict[str, ~pkg_resources.EntryPoint]
[ "Get", "all", "available", "plugins", "for", "unidown", "." ]
train
https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/plugin/a_plugin.py#L440-L447
HiPERCAM/hcam_widgets
hcam_widgets/astro.py
_equation_of_time
def _equation_of_time(t): """ Find the difference between apparent and mean solar time Parameters ---------- t : `~astropy.time.Time` times (array) Returns ---------- ret1 : `~astropy.units.Quantity` the equation of time """ # Julian centuries since J2000.0 ...
python
def _equation_of_time(t): """ Find the difference between apparent and mean solar time Parameters ---------- t : `~astropy.time.Time` times (array) Returns ---------- ret1 : `~astropy.units.Quantity` the equation of time """ # Julian centuries since J2000.0 ...
[ "def", "_equation_of_time", "(", "t", ")", ":", "# Julian centuries since J2000.0", "T", "=", "(", "t", "-", "Time", "(", "\"J2000\"", ")", ")", ".", "to", "(", "u", ".", "year", ")", ".", "value", "/", "100", "# obliquity of ecliptic (Meeus 1998, eq 22.2)", ...
Find the difference between apparent and mean solar time Parameters ---------- t : `~astropy.time.Time` times (array) Returns ---------- ret1 : `~astropy.units.Quantity` the equation of time
[ "Find", "the", "difference", "between", "apparent", "and", "mean", "solar", "time" ]
train
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/astro.py#L15-L53
HiPERCAM/hcam_widgets
hcam_widgets/astro.py
_astropy_time_from_LST
def _astropy_time_from_LST(t, LST, location, prev_next): """ Convert a Local Sidereal Time to an astropy Time object. The local time is related to the LST through the RA of the Sun. This routine uses this relationship to convert a LST to an astropy time object. Returns ------- ret1 : `...
python
def _astropy_time_from_LST(t, LST, location, prev_next): """ Convert a Local Sidereal Time to an astropy Time object. The local time is related to the LST through the RA of the Sun. This routine uses this relationship to convert a LST to an astropy time object. Returns ------- ret1 : `...
[ "def", "_astropy_time_from_LST", "(", "t", ",", "LST", ",", "location", ",", "prev_next", ")", ":", "# now we need to figure out time to return from LST", "raSun", "=", "coord", ".", "get_sun", "(", "t", ")", ".", "ra", "# calculate Greenwich Apparent Solar Time, which ...
Convert a Local Sidereal Time to an astropy Time object. The local time is related to the LST through the RA of the Sun. This routine uses this relationship to convert a LST to an astropy time object. Returns ------- ret1 : `~astropy.time.Time` time corresponding to LST
[ "Convert", "a", "Local", "Sidereal", "Time", "to", "an", "astropy", "Time", "object", "." ]
train
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/astro.py#L56-L97
HiPERCAM/hcam_widgets
hcam_widgets/astro.py
_rise_set_trig
def _rise_set_trig(t, target, location, prev_next, rise_set): """ Crude time at next rise/set of ``target`` using spherical trig. This method is ~15 times faster than `_calcriseset`, and inherently does *not* take the atmosphere into account. The time returned should not be used in calculations; t...
python
def _rise_set_trig(t, target, location, prev_next, rise_set): """ Crude time at next rise/set of ``target`` using spherical trig. This method is ~15 times faster than `_calcriseset`, and inherently does *not* take the atmosphere into account. The time returned should not be used in calculations; t...
[ "def", "_rise_set_trig", "(", "t", ",", "target", ",", "location", ",", "prev_next", ",", "rise_set", ")", ":", "dec", "=", "target", ".", "transform_to", "(", "coord", ".", "ICRS", ")", ".", "dec", "with", "warnings", ".", "catch_warnings", "(", ")", ...
Crude time at next rise/set of ``target`` using spherical trig. This method is ~15 times faster than `_calcriseset`, and inherently does *not* take the atmosphere into account. The time returned should not be used in calculations; the purpose of this routine is to supply a guess to `_calcriseset`. ...
[ "Crude", "time", "at", "next", "rise", "/", "set", "of", "target", "using", "spherical", "trig", "." ]
train
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/astro.py#L100-L150
HiPERCAM/hcam_widgets
hcam_widgets/astro.py
calc_riseset
def calc_riseset(t, target_name, location, prev_next, rise_set, horizon): """ Time at next rise/set of ``target``. Parameters ---------- t : `~astropy.time.Time` or other (see below) Time of observation. This will be passed in as the first argument to the `~astropy.time.Time` initia...
python
def calc_riseset(t, target_name, location, prev_next, rise_set, horizon): """ Time at next rise/set of ``target``. Parameters ---------- t : `~astropy.time.Time` or other (see below) Time of observation. This will be passed in as the first argument to the `~astropy.time.Time` initia...
[ "def", "calc_riseset", "(", "t", ",", "target_name", ",", "location", ",", "prev_next", ",", "rise_set", ",", "horizon", ")", ":", "target", "=", "coord", ".", "get_body", "(", "target_name", ",", "t", ")", "t0", "=", "_rise_set_trig", "(", "t", ",", "...
Time at next rise/set of ``target``. Parameters ---------- t : `~astropy.time.Time` or other (see below) Time of observation. This will be passed in as the first argument to the `~astropy.time.Time` initializer, so it can be anything that `~astropy.time.Time` will accept (including ...
[ "Time", "at", "next", "rise", "/", "set", "of", "target", "." ]
train
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/astro.py#L153-L198
HiPERCAM/hcam_widgets
hcam_widgets/astro.py
_horiz_cross
def _horiz_cross(t, alt, rise_set, horizon=0*u.degree): """ Find time ``t`` when values in array ``a`` go from negative to positive or positive to negative (exclude endpoints) ``return_limits`` will return nearest times to zero-crossing. Parameters ---------- t : `~astropy.time.Time` ...
python
def _horiz_cross(t, alt, rise_set, horizon=0*u.degree): """ Find time ``t`` when values in array ``a`` go from negative to positive or positive to negative (exclude endpoints) ``return_limits`` will return nearest times to zero-crossing. Parameters ---------- t : `~astropy.time.Time` ...
[ "def", "_horiz_cross", "(", "t", ",", "alt", ",", "rise_set", ",", "horizon", "=", "0", "*", "u", ".", "degree", ")", ":", "if", "rise_set", "==", "'rising'", ":", "# Find index where altitude goes from below to above horizon", "condition", "=", "(", "alt", "[...
Find time ``t`` when values in array ``a`` go from negative to positive or positive to negative (exclude endpoints) ``return_limits`` will return nearest times to zero-crossing. Parameters ---------- t : `~astropy.time.Time` Grid of times alt : `~astropy.units.Quantity` Grid of...
[ "Find", "time", "t", "when", "values", "in", "array", "a", "go", "from", "negative", "to", "positive", "or", "positive", "to", "negative", "(", "exclude", "endpoints", ")" ]
train
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/astro.py#L202-L248
HiPERCAM/hcam_widgets
hcam_widgets/astro.py
_two_point_interp
def _two_point_interp(times, altitudes, horizon=0*u.deg): """ Do linear interpolation between two ``altitudes`` at two ``times`` to determine the time where the altitude goes through zero. Parameters ---------- times : `~astropy.time.Time` Two times for linear interpolation between ...
python
def _two_point_interp(times, altitudes, horizon=0*u.deg): """ Do linear interpolation between two ``altitudes`` at two ``times`` to determine the time where the altitude goes through zero. Parameters ---------- times : `~astropy.time.Time` Two times for linear interpolation between ...
[ "def", "_two_point_interp", "(", "times", ",", "altitudes", ",", "horizon", "=", "0", "*", "u", ".", "deg", ")", ":", "if", "not", "isinstance", "(", "times", ",", "Time", ")", ":", "return", "MAGIC_TIME", "else", ":", "slope", "=", "(", "altitudes", ...
Do linear interpolation between two ``altitudes`` at two ``times`` to determine the time where the altitude goes through zero. Parameters ---------- times : `~astropy.time.Time` Two times for linear interpolation between altitudes : array of `~astropy.units.Quantity` Two altitu...
[ "Do", "linear", "interpolation", "between", "two", "altitudes", "at", "two", "times", "to", "determine", "the", "time", "where", "the", "altitude", "goes", "through", "zero", "." ]
train
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/astro.py#L252-L281
IceflowRE/unidown
unidown/dynamic_data.py
init_dirs
def init_dirs(main_dir: Path, logfilepath: Path): """ Initialize the main directories. :param main_dir: main directory :type main_dir: ~pathlib.Path :param logfilepath: log file :type logfilepath: ~pathlib.Path """ global MAIN_DIR, TEMP_DIR, DOWNLOAD_DIR, SAVESTAT_DIR, LOGFILE_PATH ...
python
def init_dirs(main_dir: Path, logfilepath: Path): """ Initialize the main directories. :param main_dir: main directory :type main_dir: ~pathlib.Path :param logfilepath: log file :type logfilepath: ~pathlib.Path """ global MAIN_DIR, TEMP_DIR, DOWNLOAD_DIR, SAVESTAT_DIR, LOGFILE_PATH ...
[ "def", "init_dirs", "(", "main_dir", ":", "Path", ",", "logfilepath", ":", "Path", ")", ":", "global", "MAIN_DIR", ",", "TEMP_DIR", ",", "DOWNLOAD_DIR", ",", "SAVESTAT_DIR", ",", "LOGFILE_PATH", "MAIN_DIR", "=", "main_dir", "TEMP_DIR", "=", "MAIN_DIR", ".", ...
Initialize the main directories. :param main_dir: main directory :type main_dir: ~pathlib.Path :param logfilepath: log file :type logfilepath: ~pathlib.Path
[ "Initialize", "the", "main", "directories", "." ]
train
https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/dynamic_data.py#L37-L51
IceflowRE/unidown
unidown/dynamic_data.py
reset
def reset(): """ Reset all dynamic variables to the default values. """ global MAIN_DIR, TEMP_DIR, DOWNLOAD_DIR, SAVESTAT_DIR, LOGFILE_PATH, USING_CORES, LOG_LEVEL, DISABLE_TQDM, \ SAVE_STATE_VERSION MAIN_DIR = Path('./') TEMP_DIR = MAIN_DIR.joinpath(Path('temp/')) DOWNLOAD_DIR = MAI...
python
def reset(): """ Reset all dynamic variables to the default values. """ global MAIN_DIR, TEMP_DIR, DOWNLOAD_DIR, SAVESTAT_DIR, LOGFILE_PATH, USING_CORES, LOG_LEVEL, DISABLE_TQDM, \ SAVE_STATE_VERSION MAIN_DIR = Path('./') TEMP_DIR = MAIN_DIR.joinpath(Path('temp/')) DOWNLOAD_DIR = MAI...
[ "def", "reset", "(", ")", ":", "global", "MAIN_DIR", ",", "TEMP_DIR", ",", "DOWNLOAD_DIR", ",", "SAVESTAT_DIR", ",", "LOGFILE_PATH", ",", "USING_CORES", ",", "LOG_LEVEL", ",", "DISABLE_TQDM", ",", "SAVE_STATE_VERSION", "MAIN_DIR", "=", "Path", "(", "'./'", ")"...
Reset all dynamic variables to the default values.
[ "Reset", "all", "dynamic", "variables", "to", "the", "default", "values", "." ]
train
https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/dynamic_data.py#L54-L70
IceflowRE/unidown
unidown/dynamic_data.py
check_dirs
def check_dirs(): """ Check the directories if they exist. :raises FileExistsError: if a file exists but is not a directory """ dirs = [MAIN_DIR, TEMP_DIR, DOWNLOAD_DIR, SAVESTAT_DIR] for directory in dirs: if directory.exists() and not directory.is_dir(): raise FileExistsEr...
python
def check_dirs(): """ Check the directories if they exist. :raises FileExistsError: if a file exists but is not a directory """ dirs = [MAIN_DIR, TEMP_DIR, DOWNLOAD_DIR, SAVESTAT_DIR] for directory in dirs: if directory.exists() and not directory.is_dir(): raise FileExistsEr...
[ "def", "check_dirs", "(", ")", ":", "dirs", "=", "[", "MAIN_DIR", ",", "TEMP_DIR", ",", "DOWNLOAD_DIR", ",", "SAVESTAT_DIR", "]", "for", "directory", "in", "dirs", ":", "if", "directory", ".", "exists", "(", ")", "and", "not", "directory", ".", "is_dir",...
Check the directories if they exist. :raises FileExistsError: if a file exists but is not a directory
[ "Check", "the", "directories", "if", "they", "exist", "." ]
train
https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/dynamic_data.py#L73-L82
HiPERCAM/hcam_widgets
hcam_widgets/gtc/headers.py
parse_hstring
def parse_hstring(hs): """ Parse a single item from the telescope server into name, value, comment. """ # split the string on = and /, also stripping whitespace and annoying quotes name, value, comment = yield_three( [val.strip().strip("'") for val in filter(None, re.split("[=/]+", hs))] ...
python
def parse_hstring(hs): """ Parse a single item from the telescope server into name, value, comment. """ # split the string on = and /, also stripping whitespace and annoying quotes name, value, comment = yield_three( [val.strip().strip("'") for val in filter(None, re.split("[=/]+", hs))] ...
[ "def", "parse_hstring", "(", "hs", ")", ":", "# split the string on = and /, also stripping whitespace and annoying quotes", "name", ",", "value", ",", "comment", "=", "yield_three", "(", "[", "val", ".", "strip", "(", ")", ".", "strip", "(", "\"'\"", ")", "for", ...
Parse a single item from the telescope server into name, value, comment.
[ "Parse", "a", "single", "item", "from", "the", "telescope", "server", "into", "name", "value", "comment", "." ]
train
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/gtc/headers.py#L27-L43
HiPERCAM/hcam_widgets
hcam_widgets/gtc/headers.py
create_header_from_telpars
def create_header_from_telpars(telpars): """ Create a list of fits header items from GTC telescope pars. The GTC telescope server gives a list of string describing FITS header items such as RA, DEC, etc. Arguments --------- telpars : list list returned by server call to getTelescop...
python
def create_header_from_telpars(telpars): """ Create a list of fits header items from GTC telescope pars. The GTC telescope server gives a list of string describing FITS header items such as RA, DEC, etc. Arguments --------- telpars : list list returned by server call to getTelescop...
[ "def", "create_header_from_telpars", "(", "telpars", ")", ":", "# pars is a list of strings describing tel info in FITS", "# style, each entry in the list is a different class of", "# thing (weather, telescope, instrument etc).", "# first, we munge it into a single list of strings, each one", "#...
Create a list of fits header items from GTC telescope pars. The GTC telescope server gives a list of string describing FITS header items such as RA, DEC, etc. Arguments --------- telpars : list list returned by server call to getTelescopeParams
[ "Create", "a", "list", "of", "fits", "header", "items", "from", "GTC", "telescope", "pars", "." ]
train
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/gtc/headers.py#L46-L72
HiPERCAM/hcam_widgets
hcam_widgets/gtc/headers.py
add_gtc_header_table_row
def add_gtc_header_table_row(t, telpars): """ Add a row with current values to GTC table Arguments --------- t : `~astropy.table.Table` The table to append row to telpars : list list returned by server call to getTelescopeParams """ now = Time.now().mjd hdr = create_...
python
def add_gtc_header_table_row(t, telpars): """ Add a row with current values to GTC table Arguments --------- t : `~astropy.table.Table` The table to append row to telpars : list list returned by server call to getTelescopeParams """ now = Time.now().mjd hdr = create_...
[ "def", "add_gtc_header_table_row", "(", "t", ",", "telpars", ")", ":", "now", "=", "Time", ".", "now", "(", ")", ".", "mjd", "hdr", "=", "create_header_from_telpars", "(", "telpars", ")", "# make dictionary of vals to put in table", "vals", "=", "{", "k", ":",...
Add a row with current values to GTC table Arguments --------- t : `~astropy.table.Table` The table to append row to telpars : list list returned by server call to getTelescopeParams
[ "Add", "a", "row", "with", "current", "values", "to", "GTC", "table" ]
train
https://github.com/HiPERCAM/hcam_widgets/blob/7219f0d96dd3a8ebe3139c7f542a72c02d02fce8/hcam_widgets/gtc/headers.py#L80-L99
IceflowRE/unidown
unidown/plugin/plugin_info.py
PluginInfo.from_protobuf
def from_protobuf(cls, proto: PluginInfoProto) -> PluginInfo: """ Constructor from protobuf. :param proto: protobuf structure :type proto: ~unidown.plugin.protobuf.plugin_info_pb2.PluginInfoProto :return: the PluginInfo :rtype: ~unidown.plugin.plugin_info.PluginInfo ...
python
def from_protobuf(cls, proto: PluginInfoProto) -> PluginInfo: """ Constructor from protobuf. :param proto: protobuf structure :type proto: ~unidown.plugin.protobuf.plugin_info_pb2.PluginInfoProto :return: the PluginInfo :rtype: ~unidown.plugin.plugin_info.PluginInfo ...
[ "def", "from_protobuf", "(", "cls", ",", "proto", ":", "PluginInfoProto", ")", "->", "PluginInfo", ":", "if", "proto", ".", "name", "==", "\"\"", ":", "raise", "ValueError", "(", "\"name of PluginInfo does not exist or is empty inside the protobuf.\"", ")", "elif", ...
Constructor from protobuf. :param proto: protobuf structure :type proto: ~unidown.plugin.protobuf.plugin_info_pb2.PluginInfoProto :return: the PluginInfo :rtype: ~unidown.plugin.plugin_info.PluginInfo :raises ValueError: name of PluginInfo does not exist or is empty inside the p...
[ "Constructor", "from", "protobuf", "." ]
train
https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/plugin/plugin_info.py#L48-L66
IceflowRE/unidown
unidown/plugin/plugin_info.py
PluginInfo.to_protobuf
def to_protobuf(self) -> PluginInfoProto: """ Create protobuf item. :return: protobuf structure :rtype: ~unidown.plugin.protobuf.link_item_pb2.PluginInfoProto """ proto = PluginInfoProto() proto.name = self.name proto.version = str(self.version) p...
python
def to_protobuf(self) -> PluginInfoProto: """ Create protobuf item. :return: protobuf structure :rtype: ~unidown.plugin.protobuf.link_item_pb2.PluginInfoProto """ proto = PluginInfoProto() proto.name = self.name proto.version = str(self.version) p...
[ "def", "to_protobuf", "(", "self", ")", "->", "PluginInfoProto", ":", "proto", "=", "PluginInfoProto", "(", ")", "proto", ".", "name", "=", "self", ".", "name", "proto", ".", "version", "=", "str", "(", "self", ".", "version", ")", "proto", ".", "host"...
Create protobuf item. :return: protobuf structure :rtype: ~unidown.plugin.protobuf.link_item_pb2.PluginInfoProto
[ "Create", "protobuf", "item", "." ]
train
https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/plugin/plugin_info.py#L79-L90
IceflowRE/unidown
unidown/plugin/save_state.py
SaveState.from_protobuf
def from_protobuf(cls, proto: SaveStateProto) -> SaveState: """ Constructor from protobuf. Can raise ValueErrors from called from_protobuf() parsers. :param proto: protobuf structure :type proto: ~unidown.plugin.protobuf.save_state_pb2.SaveStateProto :return: the SaveState ...
python
def from_protobuf(cls, proto: SaveStateProto) -> SaveState: """ Constructor from protobuf. Can raise ValueErrors from called from_protobuf() parsers. :param proto: protobuf structure :type proto: ~unidown.plugin.protobuf.save_state_pb2.SaveStateProto :return: the SaveState ...
[ "def", "from_protobuf", "(", "cls", ",", "proto", ":", "SaveStateProto", ")", "->", "SaveState", ":", "data_dict", "=", "{", "}", "for", "key", ",", "link_item", "in", "proto", ".", "data", ".", "items", "(", ")", ":", "data_dict", "[", "key", "]", "...
Constructor from protobuf. Can raise ValueErrors from called from_protobuf() parsers. :param proto: protobuf structure :type proto: ~unidown.plugin.protobuf.save_state_pb2.SaveStateProto :return: the SaveState :rtype: ~unidown.plugin.save_state.SaveState :raises ValueError: vers...
[ "Constructor", "from", "protobuf", ".", "Can", "raise", "ValueErrors", "from", "called", "from_protobuf", "()", "parsers", "." ]
train
https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/plugin/save_state.py#L55-L76
IceflowRE/unidown
unidown/plugin/save_state.py
SaveState.to_protobuf
def to_protobuf(self) -> SaveStateProto: """ Create protobuf item. :return: protobuf structure :rtype: ~unidown.plugin.protobuf.save_state_pb2.SaveStateProto """ result = SaveStateProto() result.version = str(self.version) result.last_update.CopyFrom(date...
python
def to_protobuf(self) -> SaveStateProto: """ Create protobuf item. :return: protobuf structure :rtype: ~unidown.plugin.protobuf.save_state_pb2.SaveStateProto """ result = SaveStateProto() result.version = str(self.version) result.last_update.CopyFrom(date...
[ "def", "to_protobuf", "(", "self", ")", "->", "SaveStateProto", ":", "result", "=", "SaveStateProto", "(", ")", "result", ".", "version", "=", "str", "(", "self", ".", "version", ")", "result", ".", "last_update", ".", "CopyFrom", "(", "datetime_to_timestamp...
Create protobuf item. :return: protobuf structure :rtype: ~unidown.plugin.protobuf.save_state_pb2.SaveStateProto
[ "Create", "protobuf", "item", "." ]
train
https://github.com/IceflowRE/unidown/blob/2a6f82ab780bb825668bfc55b67c11c4f72ec05c/unidown/plugin/save_state.py#L78-L91
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
definite_article
def definite_article(word, gender=MALE, role=SUBJECT): """ Returns the definite article (der/die/das/die) for a given word. """ return article_definite.get((gender[:1].lower(), role[:3].lower()))
python
def definite_article(word, gender=MALE, role=SUBJECT): """ Returns the definite article (der/die/das/die) for a given word. """ return article_definite.get((gender[:1].lower(), role[:3].lower()))
[ "def", "definite_article", "(", "word", ",", "gender", "=", "MALE", ",", "role", "=", "SUBJECT", ")", ":", "return", "article_definite", ".", "get", "(", "(", "gender", "[", ":", "1", "]", ".", "lower", "(", ")", ",", "role", "[", ":", "3", "]", ...
Returns the definite article (der/die/das/die) for a given word.
[ "Returns", "the", "definite", "article", "(", "der", "/", "die", "/", "das", "/", "die", ")", "for", "a", "given", "word", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L87-L90
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
indefinite_article
def indefinite_article(word, gender=MALE, role=SUBJECT): """ Returns the indefinite article (ein) for a given word. """ return article_indefinite.get((gender[:1].lower(), role[:3].lower()))
python
def indefinite_article(word, gender=MALE, role=SUBJECT): """ Returns the indefinite article (ein) for a given word. """ return article_indefinite.get((gender[:1].lower(), role[:3].lower()))
[ "def", "indefinite_article", "(", "word", ",", "gender", "=", "MALE", ",", "role", "=", "SUBJECT", ")", ":", "return", "article_indefinite", ".", "get", "(", "(", "gender", "[", ":", "1", "]", ".", "lower", "(", ")", ",", "role", "[", ":", "3", "]"...
Returns the indefinite article (ein) for a given word.
[ "Returns", "the", "indefinite", "article", "(", "ein", ")", "for", "a", "given", "word", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L92-L95
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
article
def article(word, function=INDEFINITE, gender=MALE, role=SUBJECT): """ Returns the indefinite (ein) or definite (der/die/das/die) article for the given word. """ return function == DEFINITE \ and definite_article(word, gender, role) \ or indefinite_article(word, gender, role)
python
def article(word, function=INDEFINITE, gender=MALE, role=SUBJECT): """ Returns the indefinite (ein) or definite (der/die/das/die) article for the given word. """ return function == DEFINITE \ and definite_article(word, gender, role) \ or indefinite_article(word, gender, role)
[ "def", "article", "(", "word", ",", "function", "=", "INDEFINITE", ",", "gender", "=", "MALE", ",", "role", "=", "SUBJECT", ")", ":", "return", "function", "==", "DEFINITE", "and", "definite_article", "(", "word", ",", "gender", ",", "role", ")", "or", ...
Returns the indefinite (ein) or definite (der/die/das/die) article for the given word.
[ "Returns", "the", "indefinite", "(", "ein", ")", "or", "definite", "(", "der", "/", "die", "/", "das", "/", "die", ")", "article", "for", "the", "given", "word", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L100-L105
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
referenced
def referenced(word, article=INDEFINITE, gender=MALE, role=SUBJECT): """ Returns a string with the article + the word. """ return "%s %s" % (_article(word, article, gender, role), word)
python
def referenced(word, article=INDEFINITE, gender=MALE, role=SUBJECT): """ Returns a string with the article + the word. """ return "%s %s" % (_article(word, article, gender, role), word)
[ "def", "referenced", "(", "word", ",", "article", "=", "INDEFINITE", ",", "gender", "=", "MALE", ",", "role", "=", "SUBJECT", ")", ":", "return", "\"%s %s\"", "%", "(", "_article", "(", "word", ",", "article", ",", "gender", ",", "role", ")", ",", "w...
Returns a string with the article + the word.
[ "Returns", "a", "string", "with", "the", "article", "+", "the", "word", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L108-L111
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
gender
def gender(word, pos=NOUN): """ Returns the gender (MALE, FEMALE or NEUTRAL) for nouns (majority vote). Returns None for words that are not nouns. """ w = word.lower() if pos == NOUN: # Default rules (baseline = 32%). if w.endswith(gender_masculine): return MASCULINE ...
python
def gender(word, pos=NOUN): """ Returns the gender (MALE, FEMALE or NEUTRAL) for nouns (majority vote). Returns None for words that are not nouns. """ w = word.lower() if pos == NOUN: # Default rules (baseline = 32%). if w.endswith(gender_masculine): return MASCULINE ...
[ "def", "gender", "(", "word", ",", "pos", "=", "NOUN", ")", ":", "w", "=", "word", ".", "lower", "(", ")", "if", "pos", "==", "NOUN", ":", "# Default rules (baseline = 32%).", "if", "w", ".", "endswith", "(", "gender_masculine", ")", ":", "return", "MA...
Returns the gender (MALE, FEMALE or NEUTRAL) for nouns (majority vote). Returns None for words that are not nouns.
[ "Returns", "the", "gender", "(", "MALE", "FEMALE", "or", "NEUTRAL", ")", "for", "nouns", "(", "majority", "vote", ")", ".", "Returns", "None", "for", "words", "that", "are", "not", "nouns", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L147-L163
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
pluralize
def pluralize(word, pos=NOUN, gender=MALE, role=SUBJECT, custom={}): """ Returns the plural of a given word. The inflection is based on probability rather than gender and role. """ w = word.lower().capitalize() if word in custom: return custom[word] if pos == NOUN: for a, b i...
python
def pluralize(word, pos=NOUN, gender=MALE, role=SUBJECT, custom={}): """ Returns the plural of a given word. The inflection is based on probability rather than gender and role. """ w = word.lower().capitalize() if word in custom: return custom[word] if pos == NOUN: for a, b i...
[ "def", "pluralize", "(", "word", ",", "pos", "=", "NOUN", ",", "gender", "=", "MALE", ",", "role", "=", "SUBJECT", ",", "custom", "=", "{", "}", ")", ":", "w", "=", "word", ".", "lower", "(", ")", ".", "capitalize", "(", ")", "if", "word", "in"...
Returns the plural of a given word. The inflection is based on probability rather than gender and role.
[ "Returns", "the", "plural", "of", "a", "given", "word", ".", "The", "inflection", "is", "based", "on", "probability", "rather", "than", "gender", "and", "role", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L212-L262
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
singularize
def singularize(word, pos=NOUN, gender=MALE, role=SUBJECT, custom={}): """ Returns the singular of a given word. The inflection is based on probability rather than gender and role. """ w = word.lower().capitalize() if word in custom: return custom[word] if word in singular: r...
python
def singularize(word, pos=NOUN, gender=MALE, role=SUBJECT, custom={}): """ Returns the singular of a given word. The inflection is based on probability rather than gender and role. """ w = word.lower().capitalize() if word in custom: return custom[word] if word in singular: r...
[ "def", "singularize", "(", "word", ",", "pos", "=", "NOUN", ",", "gender", "=", "MALE", ",", "role", "=", "SUBJECT", ",", "custom", "=", "{", "}", ")", ":", "w", "=", "word", ".", "lower", "(", ")", ".", "capitalize", "(", ")", "if", "word", "i...
Returns the singular of a given word. The inflection is based on probability rather than gender and role.
[ "Returns", "the", "singular", "of", "a", "given", "word", ".", "The", "inflection", "is", "based", "on", "probability", "rather", "than", "gender", "and", "role", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L317-L339
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
attributive
def attributive(adjective, gender=MALE, role=SUBJECT, article=None): """ For a predicative adjective, returns the attributive form (lowercase). In German, the attributive is formed with -e, -em, -en, -er or -es, depending on gender (masculine, feminine, neuter or plural) and role (nominative...
python
def attributive(adjective, gender=MALE, role=SUBJECT, article=None): """ For a predicative adjective, returns the attributive form (lowercase). In German, the attributive is formed with -e, -em, -en, -er or -es, depending on gender (masculine, feminine, neuter or plural) and role (nominative...
[ "def", "attributive", "(", "adjective", ",", "gender", "=", "MALE", ",", "role", "=", "SUBJECT", ",", "article", "=", "None", ")", ":", "w", ",", "g", ",", "c", ",", "a", "=", "adjective", ".", "lower", "(", ")", ",", "gender", "[", ":", "1", "...
For a predicative adjective, returns the attributive form (lowercase). In German, the attributive is formed with -e, -em, -en, -er or -es, depending on gender (masculine, feminine, neuter or plural) and role (nominative, accusative, dative, genitive).
[ "For", "a", "predicative", "adjective", "returns", "the", "attributive", "form", "(", "lowercase", ")", ".", "In", "German", "the", "attributive", "is", "formed", "with", "-", "e", "-", "em", "-", "en", "-", "er", "or", "-", "es", "depending", "on", "g...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L517-L541
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
predicative
def predicative(adjective): """ Returns the predicative adjective (lowercase). In German, the attributive form preceding a noun is always used: "ein kleiner Junge" => strong, masculine, nominative, "eine schöne Frau" => mixed, feminine, nominative, "der kleine Prinz" => weak, masculi...
python
def predicative(adjective): """ Returns the predicative adjective (lowercase). In German, the attributive form preceding a noun is always used: "ein kleiner Junge" => strong, masculine, nominative, "eine schöne Frau" => mixed, feminine, nominative, "der kleine Prinz" => weak, masculi...
[ "def", "predicative", "(", "adjective", ")", ":", "w", "=", "adjective", ".", "lower", "(", ")", "if", "len", "(", "w", ")", ">", "3", ":", "for", "suffix", "in", "(", "\"em\"", ",", "\"en\"", ",", "\"er\"", ",", "\"es\"", ",", "\"e\"", ")", ":",...
Returns the predicative adjective (lowercase). In German, the attributive form preceding a noun is always used: "ein kleiner Junge" => strong, masculine, nominative, "eine schöne Frau" => mixed, feminine, nominative, "der kleine Prinz" => weak, masculine, nominative, etc. The pre...
[ "Returns", "the", "predicative", "adjective", "(", "lowercase", ")", ".", "In", "German", "the", "attributive", "form", "preceding", "a", "noun", "is", "always", "used", ":", "ein", "kleiner", "Junge", "=", ">", "strong", "masculine", "nominative", "eine", "...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L543-L561
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
grade
def grade(adjective, suffix=COMPARATIVE): """ Returns the comparative or superlative form of the given (inflected) adjective. """ b = predicative(adjective) # groß => großt, schön => schönst if suffix == SUPERLATIVE and b.endswith(("s", u"ß")): suffix = suffix[1:] # große => großere, sch...
python
def grade(adjective, suffix=COMPARATIVE): """ Returns the comparative or superlative form of the given (inflected) adjective. """ b = predicative(adjective) # groß => großt, schön => schönst if suffix == SUPERLATIVE and b.endswith(("s", u"ß")): suffix = suffix[1:] # große => großere, sch...
[ "def", "grade", "(", "adjective", ",", "suffix", "=", "COMPARATIVE", ")", ":", "b", "=", "predicative", "(", "adjective", ")", "# groß => großt, schön => schönst", "if", "suffix", "==", "SUPERLATIVE", "and", "b", ".", "endswith", "(", "(", "\"s\"", ",", "u\"...
Returns the comparative or superlative form of the given (inflected) adjective.
[ "Returns", "the", "comparative", "or", "superlative", "form", "of", "the", "given", "(", "inflected", ")", "adjective", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L568-L576
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
Verbs.find_lemma
def find_lemma(self, verb): """ Returns the base form of the given inflected verb, using a rule-based approach. """ v = verb.lower() # Common prefixes: be-finden and emp-finden probably inflect like finden. if not (v.startswith("ge") and v.endswith("t")): # Probably gerund. ...
python
def find_lemma(self, verb): """ Returns the base form of the given inflected verb, using a rule-based approach. """ v = verb.lower() # Common prefixes: be-finden and emp-finden probably inflect like finden. if not (v.startswith("ge") and v.endswith("t")): # Probably gerund. ...
[ "def", "find_lemma", "(", "self", ",", "verb", ")", ":", "v", "=", "verb", ".", "lower", "(", ")", "# Common prefixes: be-finden and emp-finden probably inflect like finden.", "if", "not", "(", "v", ".", "startswith", "(", "\"ge\"", ")", "and", "v", ".", "ends...
Returns the base form of the given inflected verb, using a rule-based approach.
[ "Returns", "the", "base", "form", "of", "the", "given", "inflected", "verb", "using", "a", "rule", "-", "based", "approach", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L372-L413
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
Verbs.find_lexeme
def find_lexeme(self, verb): """ For a regular verb (base form), returns the forms using a rule-based approach. """ v = verb.lower() # Stem = infinitive minus -en, -ln, -rn. b = b0 = re.sub("en$", "", re.sub("ln$", "l", re.sub("rn$", "r", v))) # Split common prefixes. ...
python
def find_lexeme(self, verb): """ For a regular verb (base form), returns the forms using a rule-based approach. """ v = verb.lower() # Stem = infinitive minus -en, -ln, -rn. b = b0 = re.sub("en$", "", re.sub("ln$", "l", re.sub("rn$", "r", v))) # Split common prefixes. ...
[ "def", "find_lexeme", "(", "self", ",", "verb", ")", ":", "v", "=", "verb", ".", "lower", "(", ")", "# Stem = infinitive minus -en, -ln, -rn.", "b", "=", "b0", "=", "re", ".", "sub", "(", "\"en$\"", ",", "\"\"", ",", "re", ".", "sub", "(", "\"ln$\"", ...
For a regular verb (base form), returns the forms using a rule-based approach.
[ "For", "a", "regular", "verb", "(", "base", "form", ")", "returns", "the", "forms", "using", "a", "rule", "-", "based", "approach", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L415-L464
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/inflect.py
Verbs.tenses
def tenses(self, verb, parse=True): """ Returns a list of possible tenses for the given inflected verb. """ tenses = _Verbs.tenses(self, verb, parse) if len(tenses) == 0: # auswirkte => wirkte aus for prefix in prefix_separable: if verb.startswith(...
python
def tenses(self, verb, parse=True): """ Returns a list of possible tenses for the given inflected verb. """ tenses = _Verbs.tenses(self, verb, parse) if len(tenses) == 0: # auswirkte => wirkte aus for prefix in prefix_separable: if verb.startswith(...
[ "def", "tenses", "(", "self", ",", "verb", ",", "parse", "=", "True", ")", ":", "tenses", "=", "_Verbs", ".", "tenses", "(", "self", ",", "verb", ",", "parse", ")", "if", "len", "(", "tenses", ")", "==", "0", ":", "# auswirkte => wirkte aus", "for", ...
Returns a list of possible tenses for the given inflected verb.
[ "Returns", "a", "list", "of", "possible", "tenses", "for", "the", "given", "inflected", "verb", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/inflect.py#L466-L476
markuskiller/textblob-de
textblob_de/classifiers.py
_get_words_from_dataset
def _get_words_from_dataset(dataset): """Return a set of all words in a dataset. :param dataset: A list of tuples of the form ``(words, label)`` where ``words`` is either a string of a list of tokens. """ # Words may be either a string or a list of tokens. Return an iterator # of tokens ac...
python
def _get_words_from_dataset(dataset): """Return a set of all words in a dataset. :param dataset: A list of tuples of the form ``(words, label)`` where ``words`` is either a string of a list of tokens. """ # Words may be either a string or a list of tokens. Return an iterator # of tokens ac...
[ "def", "_get_words_from_dataset", "(", "dataset", ")", ":", "# Words may be either a string or a list of tokens. Return an iterator", "# of tokens accordingly", "def", "tokenize", "(", "words", ")", ":", "if", "isinstance", "(", "words", ",", "basestring", ")", ":", "retu...
Return a set of all words in a dataset. :param dataset: A list of tuples of the form ``(words, label)`` where ``words`` is either a string of a list of tokens.
[ "Return", "a", "set", "of", "all", "words", "in", "a", "dataset", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L57-L72
markuskiller/textblob-de
textblob_de/classifiers.py
basic_extractor
def basic_extractor(document, train_set): """A basic document feature extractor that returns a dict indicating what words in ``train_set`` are contained in ``document``. :param document: The text to extract features from. Can be a string or an iterable. :param list train_set: Training data set, a list ...
python
def basic_extractor(document, train_set): """A basic document feature extractor that returns a dict indicating what words in ``train_set`` are contained in ``document``. :param document: The text to extract features from. Can be a string or an iterable. :param list train_set: Training data set, a list ...
[ "def", "basic_extractor", "(", "document", ",", "train_set", ")", ":", "word_features", "=", "_get_words_from_dataset", "(", "train_set", ")", "tokens", "=", "_get_document_tokens", "(", "document", ")", "features", "=", "dict", "(", "(", "(", "u'contains({0})'", ...
A basic document feature extractor that returns a dict indicating what words in ``train_set`` are contained in ``document``. :param document: The text to extract features from. Can be a string or an iterable. :param list train_set: Training data set, a list of tuples of the form ``(words, label)``.
[ "A", "basic", "document", "feature", "extractor", "that", "returns", "a", "dict", "indicating", "what", "words", "in", "train_set", "are", "contained", "in", "document", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L84-L97
markuskiller/textblob-de
textblob_de/classifiers.py
contains_extractor
def contains_extractor(document): """A basic document feature extractor that returns a dict of words that the document contains.""" tokens = _get_document_tokens(document) features = dict((u'contains({0})'.format(w), True) for w in tokens) return features
python
def contains_extractor(document): """A basic document feature extractor that returns a dict of words that the document contains.""" tokens = _get_document_tokens(document) features = dict((u'contains({0})'.format(w), True) for w in tokens) return features
[ "def", "contains_extractor", "(", "document", ")", ":", "tokens", "=", "_get_document_tokens", "(", "document", ")", "features", "=", "dict", "(", "(", "u'contains({0})'", ".", "format", "(", "w", ")", ",", "True", ")", "for", "w", "in", "tokens", ")", "...
A basic document feature extractor that returns a dict of words that the document contains.
[ "A", "basic", "document", "feature", "extractor", "that", "returns", "a", "dict", "of", "words", "that", "the", "document", "contains", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L100-L105
markuskiller/textblob-de
textblob_de/classifiers.py
BaseClassifier._read_data
def _read_data(self, dataset, format=None): """Reads a data file and returns and iterable that can be used as testing or training data.""" # Attempt to detect file format if "format" isn't specified if not format: format_class = formats.detect(dataset) else: ...
python
def _read_data(self, dataset, format=None): """Reads a data file and returns and iterable that can be used as testing or training data.""" # Attempt to detect file format if "format" isn't specified if not format: format_class = formats.detect(dataset) else: ...
[ "def", "_read_data", "(", "self", ",", "dataset", ",", "format", "=", "None", ")", ":", "# Attempt to detect file format if \"format\" isn't specified", "if", "not", "format", ":", "format_class", "=", "formats", ".", "detect", "(", "dataset", ")", "else", ":", ...
Reads a data file and returns and iterable that can be used as testing or training data.
[ "Reads", "a", "data", "file", "and", "returns", "and", "iterable", "that", "can", "be", "used", "as", "testing", "or", "training", "data", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L138-L148
markuskiller/textblob-de
textblob_de/classifiers.py
BaseClassifier.extract_features
def extract_features(self, text): """Extracts features from a body of text. :rtype: dictionary of features """ # Feature extractor may take one or two arguments try: return self.feature_extractor(text, self.train_set) except (TypeError, AttributeError): ...
python
def extract_features(self, text): """Extracts features from a body of text. :rtype: dictionary of features """ # Feature extractor may take one or two arguments try: return self.feature_extractor(text, self.train_set) except (TypeError, AttributeError): ...
[ "def", "extract_features", "(", "self", ",", "text", ")", ":", "# Feature extractor may take one or two arguments", "try", ":", "return", "self", ".", "feature_extractor", "(", "text", ",", "self", ".", "train_set", ")", "except", "(", "TypeError", ",", "Attribute...
Extracts features from a body of text. :rtype: dictionary of features
[ "Extracts", "features", "from", "a", "body", "of", "text", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L167-L177
markuskiller/textblob-de
textblob_de/classifiers.py
NLTKClassifier.train
def train(self, *args, **kwargs): """Train the classifier with a labeled feature set and return the classifier. Takes the same arguments as the wrapped NLTK class. This method is implicitly called when calling ``classify`` or ``accuracy`` methods and is included only to allow passing in ...
python
def train(self, *args, **kwargs): """Train the classifier with a labeled feature set and return the classifier. Takes the same arguments as the wrapped NLTK class. This method is implicitly called when calling ``classify`` or ``accuracy`` methods and is included only to allow passing in ...
[ "def", "train", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "try", ":", "self", ".", "classifier", "=", "self", ".", "nltk_class", ".", "train", "(", "self", ".", "train_features", ",", "*", "args", ",", "*", "*", "kwargs", ...
Train the classifier with a labeled feature set and return the classifier. Takes the same arguments as the wrapped NLTK class. This method is implicitly called when calling ``classify`` or ``accuracy`` methods and is included only to allow passing in arguments to the ``train`` method of ...
[ "Train", "the", "classifier", "with", "a", "labeled", "feature", "set", "and", "return", "the", "classifier", ".", "Takes", "the", "same", "arguments", "as", "the", "wrapped", "NLTK", "class", ".", "This", "method", "is", "implicitly", "called", "when", "cal...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L224-L242
markuskiller/textblob-de
textblob_de/classifiers.py
NLTKClassifier.classify
def classify(self, text): """Classifies the text. :param str text: A string of text. """ text_features = self.extract_features(text) return self.classifier.classify(text_features)
python
def classify(self, text): """Classifies the text. :param str text: A string of text. """ text_features = self.extract_features(text) return self.classifier.classify(text_features)
[ "def", "classify", "(", "self", ",", "text", ")", ":", "text_features", "=", "self", ".", "extract_features", "(", "text", ")", "return", "self", ".", "classifier", ".", "classify", "(", "text_features", ")" ]
Classifies the text. :param str text: A string of text.
[ "Classifies", "the", "text", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L248-L255
markuskiller/textblob-de
textblob_de/classifiers.py
NLTKClassifier.accuracy
def accuracy(self, test_set, format=None): """Compute the accuracy on a test set. :param test_set: A list of tuples of the form ``(text, label)``, or a filename. :param format: If ``test_set`` is a filename, the file format, e.g. ``"csv"`` or ``"json"``. If ``None``, wil...
python
def accuracy(self, test_set, format=None): """Compute the accuracy on a test set. :param test_set: A list of tuples of the form ``(text, label)``, or a filename. :param format: If ``test_set`` is a filename, the file format, e.g. ``"csv"`` or ``"json"``. If ``None``, wil...
[ "def", "accuracy", "(", "self", ",", "test_set", ",", "format", "=", "None", ")", ":", "if", "isinstance", "(", "test_set", ",", "basestring", ")", ":", "# test_set is a filename", "test_data", "=", "self", ".", "_read_data", "(", "test_set", ")", "else", ...
Compute the accuracy on a test set. :param test_set: A list of tuples of the form ``(text, label)``, or a filename. :param format: If ``test_set`` is a filename, the file format, e.g. ``"csv"`` or ``"json"``. If ``None``, will attempt to detect the file format.
[ "Compute", "the", "accuracy", "on", "a", "test", "set", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L257-L272
markuskiller/textblob-de
textblob_de/classifiers.py
NLTKClassifier.update
def update(self, new_data, *args, **kwargs): '''Update the classifier with new training data and re-trains the classifier. :param new_data: New data as a list of tuples of the form ``(text, label)``. ''' self.train_set += new_data self.train_features = [(self...
python
def update(self, new_data, *args, **kwargs): '''Update the classifier with new training data and re-trains the classifier. :param new_data: New data as a list of tuples of the form ``(text, label)``. ''' self.train_set += new_data self.train_features = [(self...
[ "def", "update", "(", "self", ",", "new_data", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "train_set", "+=", "new_data", "self", ".", "train_features", "=", "[", "(", "self", ".", "extract_features", "(", "d", ")", ",", "c", ...
Update the classifier with new training data and re-trains the classifier. :param new_data: New data as a list of tuples of the form ``(text, label)``.
[ "Update", "the", "classifier", "with", "new", "training", "data", "and", "re", "-", "trains", "the", "classifier", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L274-L290
markuskiller/textblob-de
textblob_de/classifiers.py
NaiveBayesClassifier.prob_classify
def prob_classify(self, text): """Return the label probability distribution for classifying a string of text. Example: :: >>> classifier = NaiveBayesClassifier(train_data) >>> prob_dist = classifier.prob_classify("I feel happy this morning.") >>> pro...
python
def prob_classify(self, text): """Return the label probability distribution for classifying a string of text. Example: :: >>> classifier = NaiveBayesClassifier(train_data) >>> prob_dist = classifier.prob_classify("I feel happy this morning.") >>> pro...
[ "def", "prob_classify", "(", "self", ",", "text", ")", ":", "text_features", "=", "self", ".", "extract_features", "(", "text", ")", "return", "self", ".", "classifier", ".", "prob_classify", "(", "text_features", ")" ]
Return the label probability distribution for classifying a string of text. Example: :: >>> classifier = NaiveBayesClassifier(train_data) >>> prob_dist = classifier.prob_classify("I feel happy this morning.") >>> prob_dist.max() 'positive' ...
[ "Return", "the", "label", "probability", "distribution", "for", "classifying", "a", "string", "of", "text", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L312-L330
markuskiller/textblob-de
textblob_de/classifiers.py
PositiveNaiveBayesClassifier.train
def train(self, *args, **kwargs): """Train the classifier with a labeled and unlabeled feature sets and return the classifier. Takes the same arguments as the wrapped NLTK class. This method is implicitly called when calling ``classify`` or ``accuracy`` methods and is included only to al...
python
def train(self, *args, **kwargs): """Train the classifier with a labeled and unlabeled feature sets and return the classifier. Takes the same arguments as the wrapped NLTK class. This method is implicitly called when calling ``classify`` or ``accuracy`` methods and is included only to al...
[ "def", "train", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "classifier", "=", "self", ".", "nltk_class", ".", "train", "(", "self", ".", "positive_features", ",", "self", ".", "unlabeled_features", ",", "self", ".", ...
Train the classifier with a labeled and unlabeled feature sets and return the classifier. Takes the same arguments as the wrapped NLTK class. This method is implicitly called when calling ``classify`` or ``accuracy`` methods and is included only to allow passing in arguments to the ``tra...
[ "Train", "the", "classifier", "with", "a", "labeled", "and", "unlabeled", "feature", "sets", "and", "return", "the", "classifier", ".", "Takes", "the", "same", "arguments", "as", "the", "wrapped", "NLTK", "class", ".", "This", "method", "is", "implicitly", "...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L453-L466
markuskiller/textblob-de
textblob_de/classifiers.py
PositiveNaiveBayesClassifier.update
def update(self, new_positive_data=None, new_unlabeled_data=None, positive_prob_prior=0.5, *args, **kwargs): '''Update the classifier with new data and re-trains the classifier. :param new_positive_data: List of new, labeled strings. :param new_unlabeled_da...
python
def update(self, new_positive_data=None, new_unlabeled_data=None, positive_prob_prior=0.5, *args, **kwargs): '''Update the classifier with new data and re-trains the classifier. :param new_positive_data: List of new, labeled strings. :param new_unlabeled_da...
[ "def", "update", "(", "self", ",", "new_positive_data", "=", "None", ",", "new_unlabeled_data", "=", "None", ",", "positive_prob_prior", "=", "0.5", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "self", ".", "positive_prob_prior", "=", "positive_prob_...
Update the classifier with new data and re-trains the classifier. :param new_positive_data: List of new, labeled strings. :param new_unlabeled_data: List of new, unlabeled strings.
[ "Update", "the", "classifier", "with", "new", "data", "and", "re", "-", "trains", "the", "classifier", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L468-L490
markuskiller/textblob-de
textblob_de/classifiers.py
MaxEntClassifier.prob_classify
def prob_classify(self, text): """Return the label probability distribution for classifying a string of text. Example: :: >>> classifier = MaxEntClassifier(train_data) >>> prob_dist = classifier.prob_classify("I feel happy this morning.") >>> prob_di...
python
def prob_classify(self, text): """Return the label probability distribution for classifying a string of text. Example: :: >>> classifier = MaxEntClassifier(train_data) >>> prob_dist = classifier.prob_classify("I feel happy this morning.") >>> prob_di...
[ "def", "prob_classify", "(", "self", ",", "text", ")", ":", "feats", "=", "self", ".", "extract_features", "(", "text", ")", "return", "self", ".", "classifier", ".", "prob_classify", "(", "feats", ")" ]
Return the label probability distribution for classifying a string of text. Example: :: >>> classifier = MaxEntClassifier(train_data) >>> prob_dist = classifier.prob_classify("I feel happy this morning.") >>> prob_dist.max() 'positive' ...
[ "Return", "the", "label", "probability", "distribution", "for", "classifying", "a", "string", "of", "text", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/classifiers.py#L497-L515
markuskiller/textblob-de
textblob_de/lemmatizers.py
PatternParserLemmatizer.lemmatize
def lemmatize(self, text): """Return a list of (lemma, tag) tuples. :param str text: A string. """ #: Do not process empty strings (Issue #3) if text.strip() == "": return [] parsed_sentences = self._parse_text(text) _lemmalist = [] for s in ...
python
def lemmatize(self, text): """Return a list of (lemma, tag) tuples. :param str text: A string. """ #: Do not process empty strings (Issue #3) if text.strip() == "": return [] parsed_sentences = self._parse_text(text) _lemmalist = [] for s in ...
[ "def", "lemmatize", "(", "self", ",", "text", ")", ":", "#: Do not process empty strings (Issue #3)", "if", "text", ".", "strip", "(", ")", "==", "\"\"", ":", "return", "[", "]", "parsed_sentences", "=", "self", ".", "_parse_text", "(", "text", ")", "_lemmal...
Return a list of (lemma, tag) tuples. :param str text: A string.
[ "Return", "a", "list", "of", "(", "lemma", "tag", ")", "tuples", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/lemmatizers.py#L43-L80
markuskiller/textblob-de
textblob_de/lemmatizers.py
PatternParserLemmatizer._parse_text
def _parse_text(self, text): """Parse text (string) and return list of parsed sentences (strings). Each sentence consists of space separated token elements and the token format returned by the PatternParser is WORD/TAG/PHRASE/ROLE/LEMMA (separated by a forward slash '/') :param...
python
def _parse_text(self, text): """Parse text (string) and return list of parsed sentences (strings). Each sentence consists of space separated token elements and the token format returned by the PatternParser is WORD/TAG/PHRASE/ROLE/LEMMA (separated by a forward slash '/') :param...
[ "def", "_parse_text", "(", "self", ",", "text", ")", ":", "# Fix for issue #1", "text", "=", "text", ".", "replace", "(", "\"/\"", ",", "\" FORWARDSLASH \"", ")", "_tokenized", "=", "\" \"", ".", "join", "(", "self", ".", "tokenizer", ".", "tokenize", "(",...
Parse text (string) and return list of parsed sentences (strings). Each sentence consists of space separated token elements and the token format returned by the PatternParser is WORD/TAG/PHRASE/ROLE/LEMMA (separated by a forward slash '/') :param str text: A string.
[ "Parse", "text", "(", "string", ")", "and", "return", "list", "of", "parsed", "sentences", "(", "strings", ")", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/lemmatizers.py#L82-L96
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
_match
def _match(string, pattern): """ Returns True if the pattern matches the given word string. The pattern can include a wildcard (*front, back*, *both*, in*side), or it can be a compiled regular expression. """ p = pattern try: if p[:1] == WILDCARD and (p[-1:] == WILDCARD and p[1:-...
python
def _match(string, pattern): """ Returns True if the pattern matches the given word string. The pattern can include a wildcard (*front, back*, *both*, in*side), or it can be a compiled regular expression. """ p = pattern try: if p[:1] == WILDCARD and (p[-1:] == WILDCARD and p[1:-...
[ "def", "_match", "(", "string", ",", "pattern", ")", ":", "p", "=", "pattern", "try", ":", "if", "p", "[", ":", "1", "]", "==", "WILDCARD", "and", "(", "p", "[", "-", "1", ":", "]", "==", "WILDCARD", "and", "p", "[", "1", ":", "-", "1", "]"...
Returns True if the pattern matches the given word string. The pattern can include a wildcard (*front, back*, *both*, in*side), or it can be a compiled regular expression.
[ "Returns", "True", "if", "the", "pattern", "matches", "the", "given", "word", "string", ".", "The", "pattern", "can", "include", "a", "wildcard", "(", "*", "front", "back", "*", "*", "both", "*", "in", "*", "side", ")", "or", "it", "can", "be", "a", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L101-L121
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
unique
def unique(iterable): """ Returns a list copy in which each item occurs only once (in-order). """ seen = set() return [x for x in iterable if x not in seen and not seen.add(x)]
python
def unique(iterable): """ Returns a list copy in which each item occurs only once (in-order). """ seen = set() return [x for x in iterable if x not in seen and not seen.add(x)]
[ "def", "unique", "(", "iterable", ")", ":", "seen", "=", "set", "(", ")", "return", "[", "x", "for", "x", "in", "iterable", "if", "x", "not", "in", "seen", "and", "not", "seen", ".", "add", "(", "x", ")", "]" ]
Returns a list copy in which each item occurs only once (in-order).
[ "Returns", "a", "list", "copy", "in", "which", "each", "item", "occurs", "only", "once", "(", "in", "-", "order", ")", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L127-L131
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
product
def product(*args, **kwargs): """ Yields all permutations with replacement: list(product("cat", repeat=2)) => [("c", "c"), ("c", "a"), ("c", "t"), ("a", "c"), ("a", "a"), ("a", "t"), ("t", "c"), ("t", "a"), ("t", "t")] ...
python
def product(*args, **kwargs): """ Yields all permutations with replacement: list(product("cat", repeat=2)) => [("c", "c"), ("c", "a"), ("c", "t"), ("a", "c"), ("a", "a"), ("a", "t"), ("t", "c"), ("t", "a"), ("t", "t")] ...
[ "def", "product", "(", "*", "args", ",", "*", "*", "kwargs", ")", ":", "p", "=", "[", "[", "]", "]", "for", "iterable", "in", "map", "(", "tuple", ",", "args", ")", "*", "kwargs", ".", "get", "(", "\"repeat\"", ",", "1", ")", ":", "p", "=", ...
Yields all permutations with replacement: list(product("cat", repeat=2)) => [("c", "c"), ("c", "a"), ("c", "t"), ("a", "c"), ("a", "a"), ("a", "t"), ("t", "c"), ("t", "a"), ("t", "t")]
[ "Yields", "all", "permutations", "with", "replacement", ":", "list", "(", "product", "(", "cat", "repeat", "=", "2", "))", "=", ">", "[", "(", "c", "c", ")", "(", "c", "a", ")", "(", "c", "t", ")", "(", "a", "c", ")", "(", "a", "a", ")", "(...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L144-L161
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
variations
def variations(iterable, optional=lambda x: False): """ Returns all possible variations of a sequence with optional items. """ # For example: variations(["A?", "B?", "C"], optional=lambda s: s.endswith("?")) # defines a sequence where constraint A and B are optional: # [("A?", "B?", "C"), ("B?", "C"...
python
def variations(iterable, optional=lambda x: False): """ Returns all possible variations of a sequence with optional items. """ # For example: variations(["A?", "B?", "C"], optional=lambda s: s.endswith("?")) # defines a sequence where constraint A and B are optional: # [("A?", "B?", "C"), ("B?", "C"...
[ "def", "variations", "(", "iterable", ",", "optional", "=", "lambda", "x", ":", "False", ")", ":", "# For example: variations([\"A?\", \"B?\", \"C\"], optional=lambda s: s.endswith(\"?\"))", "# defines a sequence where constraint A and B are optional:", "# [(\"A?\", \"B?\", \"C\"), (\"...
Returns all possible variations of a sequence with optional items.
[ "Returns", "all", "possible", "variations", "of", "a", "sequence", "with", "optional", "items", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L167-L187
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
compile
def compile(pattern, *args, **kwargs): """ Returns a Pattern from the given string or regular expression. Recently compiled patterns are kept in cache (if they do not use taxonomies, which are mutable dicts). """ id, p = repr(pattern) + repr(args), pattern if id in _cache and not kwargs:...
python
def compile(pattern, *args, **kwargs): """ Returns a Pattern from the given string or regular expression. Recently compiled patterns are kept in cache (if they do not use taxonomies, which are mutable dicts). """ id, p = repr(pattern) + repr(args), pattern if id in _cache and not kwargs:...
[ "def", "compile", "(", "pattern", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "id", ",", "p", "=", "repr", "(", "pattern", ")", "+", "repr", "(", "args", ")", ",", "pattern", "if", "id", "in", "_cache", "and", "not", "kwargs", ":", "re...
Returns a Pattern from the given string or regular expression. Recently compiled patterns are kept in cache (if they do not use taxonomies, which are mutable dicts).
[ "Returns", "a", "Pattern", "from", "the", "given", "string", "or", "regular", "expression", ".", "Recently", "compiled", "patterns", "are", "kept", "in", "cache", "(", "if", "they", "do", "not", "use", "taxonomies", "which", "are", "mutable", "dicts", ")", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L927-L946
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
scan
def scan(pattern, string, *args, **kwargs): """ Returns True if pattern.search(Sentence(string)) may yield matches. If is often faster to scan prior to creating a Sentence and searching it. """ return compile(pattern, *args, **kwargs).scan(string)
python
def scan(pattern, string, *args, **kwargs): """ Returns True if pattern.search(Sentence(string)) may yield matches. If is often faster to scan prior to creating a Sentence and searching it. """ return compile(pattern, *args, **kwargs).scan(string)
[ "def", "scan", "(", "pattern", ",", "string", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "compile", "(", "pattern", ",", "*", "args", ",", "*", "*", "kwargs", ")", ".", "scan", "(", "string", ")" ]
Returns True if pattern.search(Sentence(string)) may yield matches. If is often faster to scan prior to creating a Sentence and searching it.
[ "Returns", "True", "if", "pattern", ".", "search", "(", "Sentence", "(", "string", "))", "may", "yield", "matches", ".", "If", "is", "often", "faster", "to", "scan", "prior", "to", "creating", "a", "Sentence", "and", "searching", "it", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L948-L952
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
match
def match(pattern, sentence, *args, **kwargs): """ Returns the first match found in the given sentence, or None. """ return compile(pattern, *args, **kwargs).match(sentence)
python
def match(pattern, sentence, *args, **kwargs): """ Returns the first match found in the given sentence, or None. """ return compile(pattern, *args, **kwargs).match(sentence)
[ "def", "match", "(", "pattern", ",", "sentence", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "compile", "(", "pattern", ",", "*", "args", ",", "*", "*", "kwargs", ")", ".", "match", "(", "sentence", ")" ]
Returns the first match found in the given sentence, or None.
[ "Returns", "the", "first", "match", "found", "in", "the", "given", "sentence", "or", "None", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L954-L957
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
search
def search(pattern, sentence, *args, **kwargs): """ Returns a list of all matches found in the given sentence. """ return compile(pattern, *args, **kwargs).search(sentence)
python
def search(pattern, sentence, *args, **kwargs): """ Returns a list of all matches found in the given sentence. """ return compile(pattern, *args, **kwargs).search(sentence)
[ "def", "search", "(", "pattern", ",", "sentence", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "compile", "(", "pattern", ",", "*", "args", ",", "*", "*", "kwargs", ")", ".", "search", "(", "sentence", ")" ]
Returns a list of all matches found in the given sentence.
[ "Returns", "a", "list", "of", "all", "matches", "found", "in", "the", "given", "sentence", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L959-L962
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
odict.push
def push(self, kv): """ Adds a new item from the given (key, value)-tuple. If the key exists, pushes the updated item to the head of the dict. """ if kv[0] in self: self.__delitem__(kv[0]) self.__setitem__(kv[0], kv[1])
python
def push(self, kv): """ Adds a new item from the given (key, value)-tuple. If the key exists, pushes the updated item to the head of the dict. """ if kv[0] in self: self.__delitem__(kv[0]) self.__setitem__(kv[0], kv[1])
[ "def", "push", "(", "self", ",", "kv", ")", ":", "if", "kv", "[", "0", "]", "in", "self", ":", "self", ".", "__delitem__", "(", "kv", "[", "0", "]", ")", "self", ".", "__setitem__", "(", "kv", "[", "0", "]", ",", "kv", "[", "1", "]", ")" ]
Adds a new item from the given (key, value)-tuple. If the key exists, pushes the updated item to the head of the dict.
[ "Adds", "a", "new", "item", "from", "the", "given", "(", "key", "value", ")", "-", "tuple", ".", "If", "the", "key", "exists", "pushes", "the", "updated", "item", "to", "the", "head", "of", "the", "dict", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L211-L217
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Taxonomy.append
def append(self, term, type=None, value=None): """ Appends the given term to the taxonomy and tags it as the given type. Optionally, a disambiguation value can be supplied. For example: taxonomy.append("many", "quantity", "50-200") """ term = self._normalize(term) ...
python
def append(self, term, type=None, value=None): """ Appends the given term to the taxonomy and tags it as the given type. Optionally, a disambiguation value can be supplied. For example: taxonomy.append("many", "quantity", "50-200") """ term = self._normalize(term) ...
[ "def", "append", "(", "self", ",", "term", ",", "type", "=", "None", ",", "value", "=", "None", ")", ":", "term", "=", "self", ".", "_normalize", "(", "term", ")", "type", "=", "self", ".", "_normalize", "(", "type", ")", "self", ".", "setdefault",...
Appends the given term to the taxonomy and tags it as the given type. Optionally, a disambiguation value can be supplied. For example: taxonomy.append("many", "quantity", "50-200")
[ "Appends", "the", "given", "term", "to", "the", "taxonomy", "and", "tags", "it", "as", "the", "given", "type", ".", "Optionally", "a", "disambiguation", "value", "can", "be", "supplied", ".", "For", "example", ":", "taxonomy", ".", "append", "(", "many", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L308-L317
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Taxonomy.classify
def classify(self, term, **kwargs): """ Returns the (most recently added) semantic type for the given term ("many" => "quantity"). If the term is not in the dictionary, try Taxonomy.classifiers. """ term = self._normalize(term) if dict.__contains__(self, term): re...
python
def classify(self, term, **kwargs): """ Returns the (most recently added) semantic type for the given term ("many" => "quantity"). If the term is not in the dictionary, try Taxonomy.classifiers. """ term = self._normalize(term) if dict.__contains__(self, term): re...
[ "def", "classify", "(", "self", ",", "term", ",", "*", "*", "kwargs", ")", ":", "term", "=", "self", ".", "_normalize", "(", "term", ")", "if", "dict", ".", "__contains__", "(", "self", ",", "term", ")", ":", "return", "self", "[", "term", "]", "...
Returns the (most recently added) semantic type for the given term ("many" => "quantity"). If the term is not in the dictionary, try Taxonomy.classifiers.
[ "Returns", "the", "(", "most", "recently", "added", ")", "semantic", "type", "for", "the", "given", "term", "(", "many", "=", ">", "quantity", ")", ".", "If", "the", "term", "is", "not", "in", "the", "dictionary", "try", "Taxonomy", ".", "classifiers", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L319-L333
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Taxonomy.parents
def parents(self, term, recursive=False, **kwargs): """ Returns a list of all semantic types for the given term. If recursive=True, traverses parents up to the root. """ def dfs(term, recursive=False, visited={}, **kwargs): if term in visited: # Break on cyclic relations....
python
def parents(self, term, recursive=False, **kwargs): """ Returns a list of all semantic types for the given term. If recursive=True, traverses parents up to the root. """ def dfs(term, recursive=False, visited={}, **kwargs): if term in visited: # Break on cyclic relations....
[ "def", "parents", "(", "self", ",", "term", ",", "recursive", "=", "False", ",", "*", "*", "kwargs", ")", ":", "def", "dfs", "(", "term", ",", "recursive", "=", "False", ",", "visited", "=", "{", "}", ",", "*", "*", "kwargs", ")", ":", "if", "t...
Returns a list of all semantic types for the given term. If recursive=True, traverses parents up to the root.
[ "Returns", "a", "list", "of", "all", "semantic", "types", "for", "the", "given", "term", ".", "If", "recursive", "=", "True", "traverses", "parents", "up", "to", "the", "root", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L335-L350
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Taxonomy.value
def value(self, term, **kwargs): """ Returns the value of the given term ("many" => "50-200") """ term = self._normalize(term) if term in self._values: return self._values[term] for classifier in self.classifiers: v = classifier.value(term, **kwargs) ...
python
def value(self, term, **kwargs): """ Returns the value of the given term ("many" => "50-200") """ term = self._normalize(term) if term in self._values: return self._values[term] for classifier in self.classifiers: v = classifier.value(term, **kwargs) ...
[ "def", "value", "(", "self", ",", "term", ",", "*", "*", "kwargs", ")", ":", "term", "=", "self", ".", "_normalize", "(", "term", ")", "if", "term", "in", "self", ".", "_values", ":", "return", "self", ".", "_values", "[", "term", "]", "for", "cl...
Returns the value of the given term ("many" => "50-200")
[ "Returns", "the", "value", "of", "the", "given", "term", "(", "many", "=", ">", "50", "-", "200", ")" ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L369-L378
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Constraint.fromstring
def fromstring(cls, s, **kwargs): """ Returns a new Constraint from the given string. Uppercase words indicate either a tag ("NN", "JJ", "VP") or a taxonomy term (e.g., "PRODUCT", "PERSON"). Syntax: ( defines an optional constraint, e.g., "(JJ)". [ def...
python
def fromstring(cls, s, **kwargs): """ Returns a new Constraint from the given string. Uppercase words indicate either a tag ("NN", "JJ", "VP") or a taxonomy term (e.g., "PRODUCT", "PERSON"). Syntax: ( defines an optional constraint, e.g., "(JJ)". [ def...
[ "def", "fromstring", "(", "cls", ",", "s", ",", "*", "*", "kwargs", ")", ":", "C", "=", "cls", "(", "*", "*", "kwargs", ")", "s", "=", "s", ".", "strip", "(", ")", "s", "=", "s", ".", "strip", "(", "\"{}\"", ")", "s", "=", "s", ".", "stri...
Returns a new Constraint from the given string. Uppercase words indicate either a tag ("NN", "JJ", "VP") or a taxonomy term (e.g., "PRODUCT", "PERSON"). Syntax: ( defines an optional constraint, e.g., "(JJ)". [ defines a constraint with spaces, e.g., "[Mac OS ...
[ "Returns", "a", "new", "Constraint", "from", "the", "given", "string", ".", "Uppercase", "words", "indicate", "either", "a", "tag", "(", "NN", "JJ", "VP", ")", "or", "a", "taxonomy", "term", "(", "e", ".", "g", ".", "PRODUCT", "PERSON", ")", ".", "Sy...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L487-L546
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Constraint.match
def match(self, word): """ Return True if the given Word is part of the constraint: - the word (or lemma) occurs in Constraint.words, OR - the word (or lemma) occurs in Constraint.taxa taxonomy tree, AND - the word and/or chunk tags match those defined in the constraint. ...
python
def match(self, word): """ Return True if the given Word is part of the constraint: - the word (or lemma) occurs in Constraint.words, OR - the word (or lemma) occurs in Constraint.taxa taxonomy tree, AND - the word and/or chunk tags match those defined in the constraint. ...
[ "def", "match", "(", "self", ",", "word", ")", ":", "# If the constraint has a custom function it must return True.", "if", "self", ".", "custom", "is", "not", "None", "and", "self", ".", "custom", "(", "word", ")", "is", "False", ":", "return", "False", "# If...
Return True if the given Word is part of the constraint: - the word (or lemma) occurs in Constraint.words, OR - the word (or lemma) occurs in Constraint.taxa taxonomy tree, AND - the word and/or chunk tags match those defined in the constraint. Individual terms in Constra...
[ "Return", "True", "if", "the", "given", "Word", "is", "part", "of", "the", "constraint", ":", "-", "the", "word", "(", "or", "lemma", ")", "occurs", "in", "Constraint", ".", "words", "OR", "-", "the", "word", "(", "or", "lemma", ")", "occurs", "in", ...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L571-L650
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Pattern.fromstring
def fromstring(cls, s, *args, **kwargs): """ Returns a new Pattern from the given string. Constraints are separated by a space. If a constraint contains a space, it must be wrapped in []. """ s = s.replace("\(", "&lparen;") s = s.replace("\)", "&rparen;") ...
python
def fromstring(cls, s, *args, **kwargs): """ Returns a new Pattern from the given string. Constraints are separated by a space. If a constraint contains a space, it must be wrapped in []. """ s = s.replace("\(", "&lparen;") s = s.replace("\)", "&rparen;") ...
[ "def", "fromstring", "(", "cls", ",", "s", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "s", "=", "s", ".", "replace", "(", "\"\\(\"", ",", "\"&lparen;\"", ")", "s", "=", "s", ".", "replace", "(", "\"\\)\"", ",", "\"&rparen;\"", ")", "s",...
Returns a new Pattern from the given string. Constraints are separated by a space. If a constraint contains a space, it must be wrapped in [].
[ "Returns", "a", "new", "Pattern", "from", "the", "given", "string", ".", "Constraints", "are", "separated", "by", "a", "space", ".", "If", "a", "constraint", "contains", "a", "space", "it", "must", "be", "wrapped", "in", "[]", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L718-L767
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Pattern.scan
def scan(self, string): """ Returns True if search(Sentence(string)) may yield matches. If is often faster to scan prior to creating a Sentence and searching it. """ # In the following example, first scan the string for "good" and "bad": # p = Pattern.fromstring("good|bad NN"...
python
def scan(self, string): """ Returns True if search(Sentence(string)) may yield matches. If is often faster to scan prior to creating a Sentence and searching it. """ # In the following example, first scan the string for "good" and "bad": # p = Pattern.fromstring("good|bad NN"...
[ "def", "scan", "(", "self", ",", "string", ")", ":", "# In the following example, first scan the string for \"good\" and \"bad\":", "# p = Pattern.fromstring(\"good|bad NN\")", "# for s in open(\"parsed.txt\"):", "# if p.scan(s):", "# s = Sentence(s)", "# m = p.search(s...
Returns True if search(Sentence(string)) may yield matches. If is often faster to scan prior to creating a Sentence and searching it.
[ "Returns", "True", "if", "search", "(", "Sentence", "(", "string", "))", "may", "yield", "matches", ".", "If", "is", "often", "faster", "to", "scan", "prior", "to", "creating", "a", "Sentence", "and", "searching", "it", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L769-L786
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Pattern.search
def search(self, sentence): """ Returns a list of all matches found in the given sentence. """ if sentence.__class__.__name__ == "Sentence": pass elif isinstance(sentence, list) or sentence.__class__.__name__ == "Text": a=[]; [a.extend(self.search(s)) for s in sen...
python
def search(self, sentence): """ Returns a list of all matches found in the given sentence. """ if sentence.__class__.__name__ == "Sentence": pass elif isinstance(sentence, list) or sentence.__class__.__name__ == "Text": a=[]; [a.extend(self.search(s)) for s in sen...
[ "def", "search", "(", "self", ",", "sentence", ")", ":", "if", "sentence", ".", "__class__", ".", "__name__", "==", "\"Sentence\"", ":", "pass", "elif", "isinstance", "(", "sentence", ",", "list", ")", "or", "sentence", ".", "__class__", ".", "__name__", ...
Returns a list of all matches found in the given sentence.
[ "Returns", "a", "list", "of", "all", "matches", "found", "in", "the", "given", "sentence", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L788-L806
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Pattern.match
def match(self, sentence, start=0, _v=None, _u=None): """ Returns the first match found in the given sentence, or None. """ if sentence.__class__.__name__ == "Sentence": pass elif isinstance(sentence, list) or sentence.__class__.__name__ == "Text": return find(lam...
python
def match(self, sentence, start=0, _v=None, _u=None): """ Returns the first match found in the given sentence, or None. """ if sentence.__class__.__name__ == "Sentence": pass elif isinstance(sentence, list) or sentence.__class__.__name__ == "Text": return find(lam...
[ "def", "match", "(", "self", ",", "sentence", ",", "start", "=", "0", ",", "_v", "=", "None", ",", "_u", "=", "None", ")", ":", "if", "sentence", ".", "__class__", ".", "__name__", "==", "\"Sentence\"", ":", "pass", "elif", "isinstance", "(", "senten...
Returns the first match found in the given sentence, or None.
[ "Returns", "the", "first", "match", "found", "in", "the", "given", "sentence", "or", "None", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L808-L835
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Match.constraint
def constraint(self, word): """ Returns the constraint that matches the given Word, or None. """ if word.index in self._map1: return self._map1[word.index]
python
def constraint(self, word): """ Returns the constraint that matches the given Word, or None. """ if word.index in self._map1: return self._map1[word.index]
[ "def", "constraint", "(", "self", ",", "word", ")", ":", "if", "word", ".", "index", "in", "self", ".", "_map1", ":", "return", "self", ".", "_map1", "[", "word", ".", "index", "]" ]
Returns the constraint that matches the given Word, or None.
[ "Returns", "the", "constraint", "that", "matches", "the", "given", "Word", "or", "None", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L1005-L1009
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Match.constraints
def constraints(self, chunk): """ Returns a list of constraints that match the given Chunk. """ a = [self._map1[w.index] for w in chunk.words if w.index in self._map1] b = []; [b.append(constraint) for constraint in a if constraint not in b] return b
python
def constraints(self, chunk): """ Returns a list of constraints that match the given Chunk. """ a = [self._map1[w.index] for w in chunk.words if w.index in self._map1] b = []; [b.append(constraint) for constraint in a if constraint not in b] return b
[ "def", "constraints", "(", "self", ",", "chunk", ")", ":", "a", "=", "[", "self", ".", "_map1", "[", "w", ".", "index", "]", "for", "w", "in", "chunk", ".", "words", "if", "w", ".", "index", "in", "self", ".", "_map1", "]", "b", "=", "[", "]"...
Returns a list of constraints that match the given Chunk.
[ "Returns", "a", "list", "of", "constraints", "that", "match", "the", "given", "Chunk", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L1011-L1016
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Match.constituents
def constituents(self, constraint=None): """ Returns a list of Word and Chunk objects, where words have been grouped into their chunks whenever possible. Optionally, returns only chunks/words that match given constraint(s), or constraint index. """ # Select only words th...
python
def constituents(self, constraint=None): """ Returns a list of Word and Chunk objects, where words have been grouped into their chunks whenever possible. Optionally, returns only chunks/words that match given constraint(s), or constraint index. """ # Select only words th...
[ "def", "constituents", "(", "self", ",", "constraint", "=", "None", ")", ":", "# Select only words that match the given constraint.", "# Note: this will only work with constraints from Match.pattern.sequence.", "W", "=", "self", ".", "words", "n", "=", "len", "(", "self", ...
Returns a list of Word and Chunk objects, where words have been grouped into their chunks whenever possible. Optionally, returns only chunks/words that match given constraint(s), or constraint index.
[ "Returns", "a", "list", "of", "Word", "and", "Chunk", "objects", "where", "words", "have", "been", "grouped", "into", "their", "chunks", "whenever", "possible", ".", "Optionally", "returns", "only", "chunks", "/", "words", "that", "match", "given", "constraint...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L1018-L1049
markuskiller/textblob-de
textblob_de/ext/_pattern/text/search.py
Match.group
def group(self, index, chunked=False): """ Returns a list of Word objects that match the given group. With chunked=True, returns a list of Word + Chunk objects - see Match.constituents(). A group consists of consecutive constraints wrapped in { }, e.g., search("{JJ JJ} NN", S...
python
def group(self, index, chunked=False): """ Returns a list of Word objects that match the given group. With chunked=True, returns a list of Word + Chunk objects - see Match.constituents(). A group consists of consecutive constraints wrapped in { }, e.g., search("{JJ JJ} NN", S...
[ "def", "group", "(", "self", ",", "index", ",", "chunked", "=", "False", ")", ":", "if", "index", "<", "0", "or", "index", ">", "len", "(", "self", ".", "pattern", ".", "groups", ")", ":", "raise", "IndexError", "(", "\"no such group\"", ")", "if", ...
Returns a list of Word objects that match the given group. With chunked=True, returns a list of Word + Chunk objects - see Match.constituents(). A group consists of consecutive constraints wrapped in { }, e.g., search("{JJ JJ} NN", Sentence(parse("big black cat"))).group(1) => big bl...
[ "Returns", "a", "list", "of", "Word", "objects", "that", "match", "the", "given", "group", ".", "With", "chunked", "=", "True", "returns", "a", "list", "of", "Word", "+", "Chunk", "objects", "-", "see", "Match", ".", "constituents", "()", ".", "A", "gr...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/search.py#L1051-L1065
markuskiller/textblob-de
textblob_de/sentiments.py
PatternAnalyzer.analyze
def analyze(self, text): """Return the sentiment as a tuple of the form: ``(polarity, subjectivity)`` :param str text: A string. .. todo:: Figure out best format to be passed to the analyzer. There might be a better format than a string of space separated ...
python
def analyze(self, text): """Return the sentiment as a tuple of the form: ``(polarity, subjectivity)`` :param str text: A string. .. todo:: Figure out best format to be passed to the analyzer. There might be a better format than a string of space separated ...
[ "def", "analyze", "(", "self", ",", "text", ")", ":", "if", "self", ".", "lemmatize", ":", "text", "=", "self", ".", "_lemmatize", "(", "text", ")", "return", "self", ".", "RETURN_TYPE", "(", "*", "pattern_sentiment", "(", "text", ")", ")" ]
Return the sentiment as a tuple of the form: ``(polarity, subjectivity)`` :param str text: A string. .. todo:: Figure out best format to be passed to the analyzer. There might be a better format than a string of space separated lemmas (e.g. with pos tags) b...
[ "Return", "the", "sentiment", "as", "a", "tuple", "of", "the", "form", ":", "(", "polarity", "subjectivity", ")" ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/sentiments.py#L124-L142
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/__init__.py
stts2universal
def stts2universal(token, tag): """ Converts an STTS tag to a universal tag. For example: ohne/APPR => ohne/PREP """ if tag in ("KON", "KOUI", "KOUS", "KOKOM"): return (token, CONJ) if tag in ("PTKZU", "PTKNEG", "PTKVZ", "PTKANT"): return (token, PRT) if tag in ("PDF", "PDAT"...
python
def stts2universal(token, tag): """ Converts an STTS tag to a universal tag. For example: ohne/APPR => ohne/PREP """ if tag in ("KON", "KOUI", "KOUS", "KOKOM"): return (token, CONJ) if tag in ("PTKZU", "PTKNEG", "PTKVZ", "PTKANT"): return (token, PRT) if tag in ("PDF", "PDAT"...
[ "def", "stts2universal", "(", "token", ",", "tag", ")", ":", "if", "tag", "in", "(", "\"KON\"", ",", "\"KOUI\"", ",", "\"KOUS\"", ",", "\"KOKOM\"", ")", ":", "return", "(", "token", ",", "CONJ", ")", "if", "tag", "in", "(", "\"PTKZU\"", ",", "\"PTKNE...
Converts an STTS tag to a universal tag. For example: ohne/APPR => ohne/PREP
[ "Converts", "an", "STTS", "tag", "to", "a", "universal", "tag", ".", "For", "example", ":", "ohne", "/", "APPR", "=", ">", "ohne", "/", "PREP" ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L160-L172
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/__init__.py
find_lemmata
def find_lemmata(tokens): """ Annotates the tokens with lemmata for plural nouns and conjugated verbs, where each token is a [word, part-of-speech] list. """ for token in tokens: word, pos, lemma = token[0], token[1], token[0] if pos.startswith(("DT", "JJ")): lemma = pred...
python
def find_lemmata(tokens): """ Annotates the tokens with lemmata for plural nouns and conjugated verbs, where each token is a [word, part-of-speech] list. """ for token in tokens: word, pos, lemma = token[0], token[1], token[0] if pos.startswith(("DT", "JJ")): lemma = pred...
[ "def", "find_lemmata", "(", "tokens", ")", ":", "for", "token", "in", "tokens", ":", "word", ",", "pos", ",", "lemma", "=", "token", "[", "0", "]", ",", "token", "[", "1", "]", ",", "token", "[", "0", "]", "if", "pos", ".", "startswith", "(", "...
Annotates the tokens with lemmata for plural nouns and conjugated verbs, where each token is a [word, part-of-speech] list.
[ "Annotates", "the", "tokens", "with", "lemmata", "for", "plural", "nouns", "and", "conjugated", "verbs", "where", "each", "token", "is", "a", "[", "word", "part", "-", "of", "-", "speech", "]", "list", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L186-L199
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/__init__.py
tree
def tree(s, token=[WORD, POS, CHUNK, PNP, REL, LEMMA]): """ Returns a parsed Text from the given parsed string. """ return Text(s, token)
python
def tree(s, token=[WORD, POS, CHUNK, PNP, REL, LEMMA]): """ Returns a parsed Text from the given parsed string. """ return Text(s, token)
[ "def", "tree", "(", "s", ",", "token", "=", "[", "WORD", ",", "POS", ",", "CHUNK", ",", "PNP", ",", "REL", ",", "LEMMA", "]", ")", ":", "return", "Text", "(", "s", ",", "token", ")" ]
Returns a parsed Text from the given parsed string.
[ "Returns", "a", "parsed", "Text", "from", "the", "given", "parsed", "string", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L250-L253
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/__init__.py
tag
def tag(s, tokenize=True, encoding="utf-8", **kwargs): """ Returns a list of (token, tag)-tuples from the given string. """ tags = [] for sentence in parse(s, tokenize, True, False, False, False, encoding, **kwargs).split(): for token in sentence: tags.append((token[0], token[1])) ...
python
def tag(s, tokenize=True, encoding="utf-8", **kwargs): """ Returns a list of (token, tag)-tuples from the given string. """ tags = [] for sentence in parse(s, tokenize, True, False, False, False, encoding, **kwargs).split(): for token in sentence: tags.append((token[0], token[1])) ...
[ "def", "tag", "(", "s", ",", "tokenize", "=", "True", ",", "encoding", "=", "\"utf-8\"", ",", "*", "*", "kwargs", ")", ":", "tags", "=", "[", "]", "for", "sentence", "in", "parse", "(", "s", ",", "tokenize", ",", "True", ",", "False", ",", "False...
Returns a list of (token, tag)-tuples from the given string.
[ "Returns", "a", "list", "of", "(", "token", "tag", ")", "-", "tuples", "from", "the", "given", "string", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L255-L262
markuskiller/textblob-de
textblob_de/ext/_pattern/text/de/__init__.py
keywords
def keywords(s, top=10, **kwargs): """ Returns a sorted list of keywords in the given string. """ return parser.find_keywords(s, top=top, frequency=parser.frequency)
python
def keywords(s, top=10, **kwargs): """ Returns a sorted list of keywords in the given string. """ return parser.find_keywords(s, top=top, frequency=parser.frequency)
[ "def", "keywords", "(", "s", ",", "top", "=", "10", ",", "*", "*", "kwargs", ")", ":", "return", "parser", ".", "find_keywords", "(", "s", ",", "top", "=", "top", ",", "frequency", "=", "parser", ".", "frequency", ")" ]
Returns a sorted list of keywords in the given string.
[ "Returns", "a", "sorted", "list", "of", "keywords", "in", "the", "given", "string", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/ext/_pattern/text/de/__init__.py#L264-L267
markuskiller/textblob-de
textblob_de/tokenizers.py
sent_tokenize
def sent_tokenize(text, tokenizer=None): """Convenience function for tokenizing sentences (not iterable). If tokenizer is not specified, the default tokenizer NLTKPunktTokenizer() is used (same behaviour as in the main `TextBlob`_ library). This function returns the sentences as a generator object. ...
python
def sent_tokenize(text, tokenizer=None): """Convenience function for tokenizing sentences (not iterable). If tokenizer is not specified, the default tokenizer NLTKPunktTokenizer() is used (same behaviour as in the main `TextBlob`_ library). This function returns the sentences as a generator object. ...
[ "def", "sent_tokenize", "(", "text", ",", "tokenizer", "=", "None", ")", ":", "_tokenizer", "=", "tokenizer", "if", "tokenizer", "is", "not", "None", "else", "NLTKPunktTokenizer", "(", ")", "return", "SentenceTokenizer", "(", "tokenizer", "=", "_tokenizer", ")...
Convenience function for tokenizing sentences (not iterable). If tokenizer is not specified, the default tokenizer NLTKPunktTokenizer() is used (same behaviour as in the main `TextBlob`_ library). This function returns the sentences as a generator object. .. _TextBlob: http://textblob.readthedocs.org...
[ "Convenience", "function", "for", "tokenizing", "sentences", "(", "not", "iterable", ")", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L306-L318
markuskiller/textblob-de
textblob_de/tokenizers.py
word_tokenize
def word_tokenize(text, tokenizer=None, include_punc=True, *args, **kwargs): """Convenience function for tokenizing text into words. NOTE: NLTK's word tokenizer expects sentences as input, so the text will be tokenized to sentences before being tokenized to words. This function returns an itertools ch...
python
def word_tokenize(text, tokenizer=None, include_punc=True, *args, **kwargs): """Convenience function for tokenizing text into words. NOTE: NLTK's word tokenizer expects sentences as input, so the text will be tokenized to sentences before being tokenized to words. This function returns an itertools ch...
[ "def", "word_tokenize", "(", "text", ",", "tokenizer", "=", "None", ",", "include_punc", "=", "True", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "_tokenizer", "=", "tokenizer", "if", "tokenizer", "is", "not", "None", "else", "NLTKPunktTokenizer",...
Convenience function for tokenizing text into words. NOTE: NLTK's word tokenizer expects sentences as input, so the text will be tokenized to sentences before being tokenized to words. This function returns an itertools chain object (generator).
[ "Convenience", "function", "for", "tokenizing", "text", "into", "words", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L321-L335
markuskiller/textblob-de
textblob_de/tokenizers.py
NLTKPunktTokenizer.tokenize
def tokenize(self, text, include_punc=True, nested=False): """Return a list of word tokens. :param text: string of text. :param include_punc: (optional) whether to include punctuation as separate tokens. Default to True. :param nested: (optional) whether to return tokens as ...
python
def tokenize(self, text, include_punc=True, nested=False): """Return a list of word tokens. :param text: string of text. :param include_punc: (optional) whether to include punctuation as separate tokens. Default to True. :param nested: (optional) whether to return tokens as ...
[ "def", "tokenize", "(", "self", ",", "text", ",", "include_punc", "=", "True", ",", "nested", "=", "False", ")", ":", "self", ".", "tokens", "=", "[", "w", "for", "w", "in", "(", "self", ".", "word_tokenize", "(", "s", ",", "include_punc", ")", "fo...
Return a list of word tokens. :param text: string of text. :param include_punc: (optional) whether to include punctuation as separate tokens. Default to True. :param nested: (optional) whether to return tokens as nested lists of sentences. Default to False.
[ "Return", "a", "list", "of", "word", "tokens", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L54-L72
markuskiller/textblob-de
textblob_de/tokenizers.py
NLTKPunktTokenizer.sent_tokenize
def sent_tokenize(self, text, **kwargs): """NLTK's sentence tokenizer (currently PunktSentenceTokenizer). Uses an unsupervised algorithm to build a model for abbreviation words, collocations, and words that start sentences, then uses that to find sentence boundaries. """ ...
python
def sent_tokenize(self, text, **kwargs): """NLTK's sentence tokenizer (currently PunktSentenceTokenizer). Uses an unsupervised algorithm to build a model for abbreviation words, collocations, and words that start sentences, then uses that to find sentence boundaries. """ ...
[ "def", "sent_tokenize", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "sentences", "=", "self", ".", "sent_tok", ".", "tokenize", "(", "text", ",", "realign_boundaries", "=", "kwargs", ".", "get", "(", "\"realign_boundaries\"", ",", "True", ...
NLTK's sentence tokenizer (currently PunktSentenceTokenizer). Uses an unsupervised algorithm to build a model for abbreviation words, collocations, and words that start sentences, then uses that to find sentence boundaries.
[ "NLTK", "s", "sentence", "tokenizer", "(", "currently", "PunktSentenceTokenizer", ")", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L75-L88
markuskiller/textblob-de
textblob_de/tokenizers.py
NLTKPunktTokenizer.word_tokenize
def word_tokenize(self, text, include_punc=True): """The Treebank tokenizer uses regular expressions to tokenize text as in Penn Treebank. It assumes that the text has already been segmented into sentences, e.g. using ``self.sent_tokenize()``. This tokenizer performs the follow...
python
def word_tokenize(self, text, include_punc=True): """The Treebank tokenizer uses regular expressions to tokenize text as in Penn Treebank. It assumes that the text has already been segmented into sentences, e.g. using ``self.sent_tokenize()``. This tokenizer performs the follow...
[ "def", "word_tokenize", "(", "self", ",", "text", ",", "include_punc", "=", "True", ")", ":", "#: Do not process empty strings (Issue #3)", "if", "text", ".", "strip", "(", ")", "==", "\"\"", ":", "return", "[", "]", "_tokens", "=", "self", ".", "word_tok", ...
The Treebank tokenizer uses regular expressions to tokenize text as in Penn Treebank. It assumes that the text has already been segmented into sentences, e.g. using ``self.sent_tokenize()``. This tokenizer performs the following steps: - split standard contractions, e.g. ``don...
[ "The", "Treebank", "tokenizer", "uses", "regular", "expressions", "to", "tokenize", "text", "as", "in", "Penn", "Treebank", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L90-L132
markuskiller/textblob-de
textblob_de/tokenizers.py
PatternTokenizer.sent_tokenize
def sent_tokenize(self, text, **kwargs): """Returns a list of sentences. Each sentence is a space-separated string of tokens (words). Handles common cases of abbreviations (e.g., etc., ...). Punctuation marks are split from other words. Periods (or ?!) mark the end of a sentence. ...
python
def sent_tokenize(self, text, **kwargs): """Returns a list of sentences. Each sentence is a space-separated string of tokens (words). Handles common cases of abbreviations (e.g., etc., ...). Punctuation marks are split from other words. Periods (or ?!) mark the end of a sentence. ...
[ "def", "sent_tokenize", "(", "self", ",", "text", ",", "*", "*", "kwargs", ")", ":", "sentences", "=", "find_sentences", "(", "text", ",", "punctuation", "=", "kwargs", ".", "get", "(", "\"punctuation\"", ",", "PUNCTUATION", ")", ",", "abbreviations", "=",...
Returns a list of sentences. Each sentence is a space-separated string of tokens (words). Handles common cases of abbreviations (e.g., etc., ...). Punctuation marks are split from other words. Periods (or ?!) mark the end of a sentence. Headings without an ending period are inferred by ...
[ "Returns", "a", "list", "of", "sentences", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L173-L192
markuskiller/textblob-de
textblob_de/tokenizers.py
WordTokenizer.tokenize
def tokenize(self, text, include_punc=True, **kwargs): """Return a list of word tokens. :param text: string of text. :param include_punc: (optional) whether to include punctuation as separate tokens. Default to True. """ return self.tokenizer.word_tokenize(text, inc...
python
def tokenize(self, text, include_punc=True, **kwargs): """Return a list of word tokens. :param text: string of text. :param include_punc: (optional) whether to include punctuation as separate tokens. Default to True. """ return self.tokenizer.word_tokenize(text, inc...
[ "def", "tokenize", "(", "self", ",", "text", ",", "include_punc", "=", "True", ",", "*", "*", "kwargs", ")", ":", "return", "self", ".", "tokenizer", ".", "word_tokenize", "(", "text", ",", "include_punc", ",", "*", "*", "kwargs", ")" ]
Return a list of word tokens. :param text: string of text. :param include_punc: (optional) whether to include punctuation as separate tokens. Default to True.
[ "Return", "a", "list", "of", "word", "tokens", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/tokenizers.py#L254-L262
markuskiller/textblob-de
textblob_de/parsers.py
PatternParser.parse
def parse(self, text): """Parses the text. ``pattern.de.parse(**kwargs)`` can be passed to the parser instance and are documented in the main docstring of :class:`PatternParser() <textblob_de.parsers.PatternParser>`. :param str text: A string. """ #: Do not pro...
python
def parse(self, text): """Parses the text. ``pattern.de.parse(**kwargs)`` can be passed to the parser instance and are documented in the main docstring of :class:`PatternParser() <textblob_de.parsers.PatternParser>`. :param str text: A string. """ #: Do not pro...
[ "def", "parse", "(", "self", ",", "text", ")", ":", "#: Do not process empty strings (Issue #3)", "if", "text", ".", "strip", "(", ")", "==", "\"\"", ":", "return", "\"\"", "#: Do not process strings consisting of a single punctuation mark (Issue #4)", "elif", "text", "...
Parses the text. ``pattern.de.parse(**kwargs)`` can be passed to the parser instance and are documented in the main docstring of :class:`PatternParser() <textblob_de.parsers.PatternParser>`. :param str text: A string.
[ "Parses", "the", "text", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/parsers.py#L77-L116
markuskiller/textblob-de
textblob_de/np_extractors.py
PatternParserNPExtractor.extract
def extract(self, text): """Return a list of noun phrases (strings) for a body of text. :param str text: A string. """ _extracted = [] if text.strip() == "": return _extracted parsed_sentences = self._parse_text(text) for s in parsed_sentences: ...
python
def extract(self, text): """Return a list of noun phrases (strings) for a body of text. :param str text: A string. """ _extracted = [] if text.strip() == "": return _extracted parsed_sentences = self._parse_text(text) for s in parsed_sentences: ...
[ "def", "extract", "(", "self", ",", "text", ")", ":", "_extracted", "=", "[", "]", "if", "text", ".", "strip", "(", ")", "==", "\"\"", ":", "return", "_extracted", "parsed_sentences", "=", "self", ".", "_parse_text", "(", "text", ")", "for", "s", "in...
Return a list of noun phrases (strings) for a body of text. :param str text: A string.
[ "Return", "a", "list", "of", "noun", "phrases", "(", "strings", ")", "for", "a", "body", "of", "text", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/np_extractors.py#L88-L118
markuskiller/textblob-de
textblob_de/np_extractors.py
PatternParserNPExtractor._filter_extracted
def _filter_extracted(self, extracted_list): """Filter insignificant words for key noun phrase extraction. determiners, relative pronouns, reflexive pronouns In general, pronouns are not useful, as you need context to know what they refer to. Most of the pronouns, however, are filtered ...
python
def _filter_extracted(self, extracted_list): """Filter insignificant words for key noun phrase extraction. determiners, relative pronouns, reflexive pronouns In general, pronouns are not useful, as you need context to know what they refer to. Most of the pronouns, however, are filtered ...
[ "def", "_filter_extracted", "(", "self", ",", "extracted_list", ")", ":", "_filtered", "=", "[", "]", "for", "np", "in", "extracted_list", ":", "_np", "=", "np", ".", "split", "(", ")", "if", "_np", "[", "0", "]", "in", "INSIGNIFICANT", ":", "_np", "...
Filter insignificant words for key noun phrase extraction. determiners, relative pronouns, reflexive pronouns In general, pronouns are not useful, as you need context to know what they refer to. Most of the pronouns, however, are filtered out by blob.noun_phrase method's np length (>1) ...
[ "Filter", "insignificant", "words", "for", "key", "noun", "phrase", "extraction", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/np_extractors.py#L120-L146
markuskiller/textblob-de
textblob_de/np_extractors.py
PatternParserNPExtractor._parse_text
def _parse_text(self, text): """Parse text (string) and return list of parsed sentences (strings). Each sentence consists of space separated token elements and the token format returned by the PatternParser is WORD/TAG/PHRASE/ROLE/(LEMMA) (separated by a forward slash '/') :par...
python
def _parse_text(self, text): """Parse text (string) and return list of parsed sentences (strings). Each sentence consists of space separated token elements and the token format returned by the PatternParser is WORD/TAG/PHRASE/ROLE/(LEMMA) (separated by a forward slash '/') :par...
[ "def", "_parse_text", "(", "self", ",", "text", ")", ":", "if", "isinstance", "(", "self", ".", "tokenizer", ",", "PatternTokenizer", ")", ":", "parsed_text", "=", "pattern_parse", "(", "text", ",", "tokenize", "=", "True", ",", "lemmata", "=", "False", ...
Parse text (string) and return list of parsed sentences (strings). Each sentence consists of space separated token elements and the token format returned by the PatternParser is WORD/TAG/PHRASE/ROLE/(LEMMA) (separated by a forward slash '/') :param str text: A string.
[ "Parse", "text", "(", "string", ")", "and", "return", "list", "of", "parsed", "sentences", "(", "strings", ")", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/np_extractors.py#L148-L169
markuskiller/textblob-de
textblob_de/taggers.py
PatternTagger.tag
def tag(self, sentence, tokenize=True): """Tag a string `sentence`. :param str or list sentence: A string or a list of sentence strings. :param tokenize: (optional) If ``False`` string has to be tokenized before (space separated string). """ #: Do not process empty ...
python
def tag(self, sentence, tokenize=True): """Tag a string `sentence`. :param str or list sentence: A string or a list of sentence strings. :param tokenize: (optional) If ``False`` string has to be tokenized before (space separated string). """ #: Do not process empty ...
[ "def", "tag", "(", "self", ",", "sentence", ",", "tokenize", "=", "True", ")", ":", "#: Do not process empty strings (Issue #3)", "if", "sentence", ".", "strip", "(", ")", "==", "\"\"", ":", "return", "[", "]", "#: Do not process strings consisting of a single punct...
Tag a string `sentence`. :param str or list sentence: A string or a list of sentence strings. :param tokenize: (optional) If ``False`` string has to be tokenized before (space separated string).
[ "Tag", "a", "string", "sentence", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/taggers.py#L60-L96
markuskiller/textblob-de
textblob_de/compat.py
decode_string
def decode_string(v, encoding="utf-8"): """Returns the given value as a Unicode string (if possible).""" if isinstance(encoding, basestring): encoding = ((encoding,),) + (("windows-1252",), ("utf-8", "ignore")) if isinstance(v, binary_type): for e in encoding: try: ...
python
def decode_string(v, encoding="utf-8"): """Returns the given value as a Unicode string (if possible).""" if isinstance(encoding, basestring): encoding = ((encoding,),) + (("windows-1252",), ("utf-8", "ignore")) if isinstance(v, binary_type): for e in encoding: try: ...
[ "def", "decode_string", "(", "v", ",", "encoding", "=", "\"utf-8\"", ")", ":", "if", "isinstance", "(", "encoding", ",", "basestring", ")", ":", "encoding", "=", "(", "(", "encoding", ",", ")", ",", ")", "+", "(", "(", "\"windows-1252\"", ",", ")", "...
Returns the given value as a Unicode string (if possible).
[ "Returns", "the", "given", "value", "as", "a", "Unicode", "string", "(", "if", "possible", ")", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/compat.py#L112-L123
markuskiller/textblob-de
textblob_de/compat.py
encode_string
def encode_string(v, encoding="utf-8"): """Returns the given value as a Python byte string (if possible).""" if isinstance(encoding, basestring): encoding = ((encoding,),) + (("windows-1252",), ("utf-8", "ignore")) if isinstance(v, unicode): for e in encoding: try: ...
python
def encode_string(v, encoding="utf-8"): """Returns the given value as a Python byte string (if possible).""" if isinstance(encoding, basestring): encoding = ((encoding,),) + (("windows-1252",), ("utf-8", "ignore")) if isinstance(v, unicode): for e in encoding: try: ...
[ "def", "encode_string", "(", "v", ",", "encoding", "=", "\"utf-8\"", ")", ":", "if", "isinstance", "(", "encoding", ",", "basestring", ")", ":", "encoding", "=", "(", "(", "encoding", ",", ")", ",", ")", "+", "(", "(", "\"windows-1252\"", ",", ")", "...
Returns the given value as a Python byte string (if possible).
[ "Returns", "the", "given", "value", "as", "a", "Python", "byte", "string", "(", "if", "possible", ")", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/compat.py#L126-L137
markuskiller/textblob-de
textblob_de/compat.py
_shutil_which
def _shutil_which(cmd, mode=os.F_OK | os.X_OK, path=None): """Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can b...
python
def _shutil_which(cmd, mode=os.F_OK | os.X_OK, path=None): """Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can b...
[ "def", "_shutil_which", "(", "cmd", ",", "mode", "=", "os", ".", "F_OK", "|", "os", ".", "X_OK", ",", "path", "=", "None", ")", ":", "# Check that a given file can be accessed with the correct mode.", "# Additionally check that `file` is not a directory, as on Windows", "...
Given a command, mode, and a PATH string, return the path which conforms to the given mode on the PATH, or None if there is no such file. `mode` defaults to os.F_OK | os.X_OK. `path` defaults to the result of os.environ.get("PATH"), or can be overridden with a custom search path.
[ "Given", "a", "command", "mode", "and", "a", "PATH", "string", "return", "the", "path", "which", "conforms", "to", "the", "given", "mode", "on", "the", "PATH", "or", "None", "if", "there", "is", "no", "such", "file", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/compat.py#L156-L215
markuskiller/textblob-de
textblob_de/blob.py
Word.translate
def translate(self, from_lang=None, to="de"): """Translate the word to another language using Google's Translate API. .. versionadded:: 0.5.0 (``textblob``) """ if from_lang is None: from_lang = self.translator.detect(self.string) return self.translator.translate(se...
python
def translate(self, from_lang=None, to="de"): """Translate the word to another language using Google's Translate API. .. versionadded:: 0.5.0 (``textblob``) """ if from_lang is None: from_lang = self.translator.detect(self.string) return self.translator.translate(se...
[ "def", "translate", "(", "self", ",", "from_lang", "=", "None", ",", "to", "=", "\"de\"", ")", ":", "if", "from_lang", "is", "None", ":", "from_lang", "=", "self", ".", "translator", ".", "detect", "(", "self", ".", "string", ")", "return", "self", "...
Translate the word to another language using Google's Translate API. .. versionadded:: 0.5.0 (``textblob``)
[ "Translate", "the", "word", "to", "another", "language", "using", "Google", "s", "Translate", "API", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L100-L109
markuskiller/textblob-de
textblob_de/blob.py
WordList.lemmatize
def lemmatize(self): """Return the lemma of each word in this WordList. Currently using NLTKPunktTokenizer() for all lemmatization tasks. This might cause slightly different tokenization results compared to the TextBlob.words property. """ _lemmatizer = PatternParserLem...
python
def lemmatize(self): """Return the lemma of each word in this WordList. Currently using NLTKPunktTokenizer() for all lemmatization tasks. This might cause slightly different tokenization results compared to the TextBlob.words property. """ _lemmatizer = PatternParserLem...
[ "def", "lemmatize", "(", "self", ")", ":", "_lemmatizer", "=", "PatternParserLemmatizer", "(", "tokenizer", "=", "NLTKPunktTokenizer", "(", ")", ")", "# WordList object --> Sentence.string", "# add a period (improves parser accuracy)", "_raw", "=", "\" \"", ".", "join", ...
Return the lemma of each word in this WordList. Currently using NLTKPunktTokenizer() for all lemmatization tasks. This might cause slightly different tokenization results compared to the TextBlob.words property.
[ "Return", "the", "lemma", "of", "each", "word", "in", "this", "WordList", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L305-L318
markuskiller/textblob-de
textblob_de/blob.py
BaseBlob.tokenize
def tokenize(self, tokenizer=None): """Return a list of tokens, using ``tokenizer``. :param tokenizer: (optional) A tokenizer object. If None, defaults to this blob's default tokenizer. """ t = tokenizer if tokenizer is not None else self.tokenizer return WordList(t...
python
def tokenize(self, tokenizer=None): """Return a list of tokens, using ``tokenizer``. :param tokenizer: (optional) A tokenizer object. If None, defaults to this blob's default tokenizer. """ t = tokenizer if tokenizer is not None else self.tokenizer return WordList(t...
[ "def", "tokenize", "(", "self", ",", "tokenizer", "=", "None", ")", ":", "t", "=", "tokenizer", "if", "tokenizer", "is", "not", "None", "else", "self", ".", "tokenizer", "return", "WordList", "(", "t", ".", "tokenize", "(", "self", ".", "raw", ")", "...
Return a list of tokens, using ``tokenizer``. :param tokenizer: (optional) A tokenizer object. If None, defaults to this blob's default tokenizer.
[ "Return", "a", "list", "of", "tokens", "using", "tokenizer", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L405-L413
markuskiller/textblob-de
textblob_de/blob.py
BaseBlob.noun_phrases
def noun_phrases(self): """Returns a list of noun phrases for this blob.""" return WordList([phrase.strip() for phrase in self.np_extractor.extract(self.raw) if len(phrase.split()) > 1])
python
def noun_phrases(self): """Returns a list of noun phrases for this blob.""" return WordList([phrase.strip() for phrase in self.np_extractor.extract(self.raw) if len(phrase.split()) > 1])
[ "def", "noun_phrases", "(", "self", ")", ":", "return", "WordList", "(", "[", "phrase", ".", "strip", "(", ")", "for", "phrase", "in", "self", ".", "np_extractor", ".", "extract", "(", "self", ".", "raw", ")", "if", "len", "(", "phrase", ".", "split"...
Returns a list of noun phrases for this blob.
[ "Returns", "a", "list", "of", "noun", "phrases", "for", "this", "blob", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L456-L460
markuskiller/textblob-de
textblob_de/blob.py
BaseBlob.pos_tags
def pos_tags(self): """Returns an list of tuples of the form (word, POS tag). Example: :: [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN')] :rtype: list of tuples """ return [(Word(...
python
def pos_tags(self): """Returns an list of tuples of the form (word, POS tag). Example: :: [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN')] :rtype: list of tuples """ return [(Word(...
[ "def", "pos_tags", "(", "self", ")", ":", "return", "[", "(", "Word", "(", "word", ",", "pos_tag", "=", "t", ")", ",", "unicode", "(", "t", ")", ")", "for", "word", ",", "t", "in", "self", ".", "pos_tagger", ".", "tag", "(", "self", ".", "raw",...
Returns an list of tuples of the form (word, POS tag). Example: :: [('At', 'IN'), ('eight', 'CD'), ("o'clock", 'JJ'), ('on', 'IN'), ('Thursday', 'NNP'), ('morning', 'NN')] :rtype: list of tuples
[ "Returns", "an", "list", "of", "tuples", "of", "the", "form", "(", "word", "POS", "tag", ")", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L463-L479
markuskiller/textblob-de
textblob_de/blob.py
BaseBlob.word_counts
def word_counts(self): """Dictionary of word frequencies in this text.""" counts = defaultdict(int) stripped_words = [lowerstrip(word) for word in self.words] for word in stripped_words: counts[word] += 1 return counts
python
def word_counts(self): """Dictionary of word frequencies in this text.""" counts = defaultdict(int) stripped_words = [lowerstrip(word) for word in self.words] for word in stripped_words: counts[word] += 1 return counts
[ "def", "word_counts", "(", "self", ")", ":", "counts", "=", "defaultdict", "(", "int", ")", "stripped_words", "=", "[", "lowerstrip", "(", "word", ")", "for", "word", "in", "self", ".", "words", "]", "for", "word", "in", "stripped_words", ":", "counts", ...
Dictionary of word frequencies in this text.
[ "Dictionary", "of", "word", "frequencies", "in", "this", "text", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L484-L490
markuskiller/textblob-de
textblob_de/blob.py
Sentence.dict
def dict(self): """The dict representation of this sentence.""" return { 'raw': self.raw, 'start_index': self.start_index, 'end_index': self.end_index, 'stripped': self.stripped, 'noun_phrases': self.noun_phrases, 'polarity': self.p...
python
def dict(self): """The dict representation of this sentence.""" return { 'raw': self.raw, 'start_index': self.start_index, 'end_index': self.end_index, 'stripped': self.stripped, 'noun_phrases': self.noun_phrases, 'polarity': self.p...
[ "def", "dict", "(", "self", ")", ":", "return", "{", "'raw'", ":", "self", ".", "raw", ",", "'start_index'", ":", "self", ".", "start_index", ",", "'end_index'", ":", "self", ".", "end_index", ",", "'stripped'", ":", "self", ".", "stripped", ",", "'nou...
The dict representation of this sentence.
[ "The", "dict", "representation", "of", "this", "sentence", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L614-L624
markuskiller/textblob-de
textblob_de/blob.py
TextBlobDE.words
def words(self): """Return a list of word tokens. This excludes punctuation characters. If you want to include punctuation characters, access the ``tokens`` property. :returns: A :class:`WordList <WordList>` of word tokens. """ return WordList( word_tokenize...
python
def words(self): """Return a list of word tokens. This excludes punctuation characters. If you want to include punctuation characters, access the ``tokens`` property. :returns: A :class:`WordList <WordList>` of word tokens. """ return WordList( word_tokenize...
[ "def", "words", "(", "self", ")", ":", "return", "WordList", "(", "word_tokenize", "(", "self", ".", "raw", ",", "self", ".", "tokenizer", ",", "include_punc", "=", "False", ")", ")" ]
Return a list of word tokens. This excludes punctuation characters. If you want to include punctuation characters, access the ``tokens`` property. :returns: A :class:`WordList <WordList>` of word tokens.
[ "Return", "a", "list", "of", "word", "tokens", ".", "This", "excludes", "punctuation", "characters", ".", "If", "you", "want", "to", "include", "punctuation", "characters", "access", "the", "tokens", "property", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L650-L659
markuskiller/textblob-de
textblob_de/blob.py
TextBlobDE.sentiment
def sentiment(self): """Return a tuple of form (polarity, subjectivity ) where polarity is a float within the range [-1.0, 1.0] and subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective. :rtype: named tuple of the form ``Senti...
python
def sentiment(self): """Return a tuple of form (polarity, subjectivity ) where polarity is a float within the range [-1.0, 1.0] and subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective. :rtype: named tuple of the form ``Senti...
[ "def", "sentiment", "(", "self", ")", ":", "#: Enhancement Issue #2", "#: adapted from 'textblob.en.sentiments.py'", "#: Return type declaration", "_RETURN_TYPE", "=", "namedtuple", "(", "'Sentiment'", ",", "[", "'polarity'", ",", "'subjectivity'", "]", ")", "_polarity", ...
Return a tuple of form (polarity, subjectivity ) where polarity is a float within the range [-1.0, 1.0] and subjectivity is a float within the range [0.0, 1.0] where 0.0 is very objective and 1.0 is very subjective. :rtype: named tuple of the form ``Sentiment(polarity=0.0, subjectivity=...
[ "Return", "a", "tuple", "of", "form", "(", "polarity", "subjectivity", ")", "where", "polarity", "is", "a", "float", "within", "the", "range", "[", "-", "1", ".", "0", "1", ".", "0", "]", "and", "subjectivity", "is", "a", "float", "within", "the", "r...
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L667-L692
markuskiller/textblob-de
textblob_de/blob.py
TextBlobDE.to_json
def to_json(self, *args, **kwargs): """Return a json representation (str) of this blob. Takes the same arguments as json.dumps. .. versionadded:: 0.5.1 (``textblob``) """ return json.dumps(self.serialized, *args, **kwargs)
python
def to_json(self, *args, **kwargs): """Return a json representation (str) of this blob. Takes the same arguments as json.dumps. .. versionadded:: 0.5.1 (``textblob``) """ return json.dumps(self.serialized, *args, **kwargs)
[ "def", "to_json", "(", "self", ",", "*", "args", ",", "*", "*", "kwargs", ")", ":", "return", "json", ".", "dumps", "(", "self", ".", "serialized", ",", "*", "args", ",", "*", "*", "kwargs", ")" ]
Return a json representation (str) of this blob. Takes the same arguments as json.dumps. .. versionadded:: 0.5.1 (``textblob``)
[ "Return", "a", "json", "representation", "(", "str", ")", "of", "this", "blob", ".", "Takes", "the", "same", "arguments", "as", "json", ".", "dumps", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L728-L735
markuskiller/textblob-de
textblob_de/blob.py
TextBlobDE._create_sentence_objects
def _create_sentence_objects(self): """Returns a list of Sentence objects from the raw text.""" sentence_objects = [] sentences = sent_tokenize(self.raw, tokenizer=self.tokenizer) char_index = 0 # Keeps track of character index within the blob for sent in sentences: ...
python
def _create_sentence_objects(self): """Returns a list of Sentence objects from the raw text.""" sentence_objects = [] sentences = sent_tokenize(self.raw, tokenizer=self.tokenizer) char_index = 0 # Keeps track of character index within the blob for sent in sentences: ...
[ "def", "_create_sentence_objects", "(", "self", ")", ":", "sentence_objects", "=", "[", "]", "sentences", "=", "sent_tokenize", "(", "self", ".", "raw", ",", "tokenizer", "=", "self", ".", "tokenizer", ")", "char_index", "=", "0", "# Keeps track of character ind...
Returns a list of Sentence objects from the raw text.
[ "Returns", "a", "list", "of", "Sentence", "objects", "from", "the", "raw", "text", "." ]
train
https://github.com/markuskiller/textblob-de/blob/1b427b2cdd7e5e9fd3697677a98358fae4aa6ad1/textblob_de/blob.py#L748-L779