Add files using upload-large-folder tool
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- llmeval-env/lib/python3.10/site-packages/nltk/classify/__init__.py +101 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/__pycache__/__init__.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/__pycache__/europarl_raw.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/__pycache__/util.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/__init__.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/aligned.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/api.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/bcp47.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/bnc.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/bracket_parse.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/categorized_sents.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/chasen.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/childes.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/chunked.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/cmudict.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/comparative_sents.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/conll.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/crubadan.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/dependency.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/framenet.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/ieer.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/indian.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/ipipan.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/knbc.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/lin.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/markdown.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/mte.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/nkjp.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/nombank.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/nps_chat.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/opinion_lexicon.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/panlex_lite.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/panlex_swadesh.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/pl196x.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/plaintext.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/ppattach.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/propbank.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/pros_cons.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/reviews.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/rte.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/semcor.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/senseval.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/sentiwordnet.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/sinica_treebank.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/string_category.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/switchboard.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/tagged.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/timit.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/toolbox.cpython-310.pyc +0 -0
- llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/twitter.cpython-310.pyc +0 -0
llmeval-env/lib/python3.10/site-packages/nltk/classify/__init__.py
ADDED
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
# Natural Language Toolkit: Classifiers
|
2 |
+
#
|
3 |
+
# Copyright (C) 2001-2023 NLTK Project
|
4 |
+
# Author: Edward Loper <[email protected]>
|
5 |
+
# URL: <https://www.nltk.org/>
|
6 |
+
# For license information, see LICENSE.TXT
|
7 |
+
|
8 |
+
"""
|
9 |
+
Classes and interfaces for labeling tokens with category labels (or
|
10 |
+
"class labels"). Typically, labels are represented with strings
|
11 |
+
(such as ``'health'`` or ``'sports'``). Classifiers can be used to
|
12 |
+
perform a wide range of classification tasks. For example,
|
13 |
+
classifiers can be used...
|
14 |
+
|
15 |
+
- to classify documents by topic
|
16 |
+
- to classify ambiguous words by which word sense is intended
|
17 |
+
- to classify acoustic signals by which phoneme they represent
|
18 |
+
- to classify sentences by their author
|
19 |
+
|
20 |
+
Features
|
21 |
+
========
|
22 |
+
In order to decide which category label is appropriate for a given
|
23 |
+
token, classifiers examine one or more 'features' of the token. These
|
24 |
+
"features" are typically chosen by hand, and indicate which aspects
|
25 |
+
of the token are relevant to the classification decision. For
|
26 |
+
example, a document classifier might use a separate feature for each
|
27 |
+
word, recording how often that word occurred in the document.
|
28 |
+
|
29 |
+
Featuresets
|
30 |
+
===========
|
31 |
+
The features describing a token are encoded using a "featureset",
|
32 |
+
which is a dictionary that maps from "feature names" to "feature
|
33 |
+
values". Feature names are unique strings that indicate what aspect
|
34 |
+
of the token is encoded by the feature. Examples include
|
35 |
+
``'prevword'``, for a feature whose value is the previous word; and
|
36 |
+
``'contains-word(library)'`` for a feature that is true when a document
|
37 |
+
contains the word ``'library'``. Feature values are typically
|
38 |
+
booleans, numbers, or strings, depending on which feature they
|
39 |
+
describe.
|
40 |
+
|
41 |
+
Featuresets are typically constructed using a "feature detector"
|
42 |
+
(also known as a "feature extractor"). A feature detector is a
|
43 |
+
function that takes a token (and sometimes information about its
|
44 |
+
context) as its input, and returns a featureset describing that token.
|
45 |
+
For example, the following feature detector converts a document
|
46 |
+
(stored as a list of words) to a featureset describing the set of
|
47 |
+
words included in the document:
|
48 |
+
|
49 |
+
>>> # Define a feature detector function.
|
50 |
+
>>> def document_features(document):
|
51 |
+
... return dict([('contains-word(%s)' % w, True) for w in document])
|
52 |
+
|
53 |
+
Feature detectors are typically applied to each token before it is fed
|
54 |
+
to the classifier:
|
55 |
+
|
56 |
+
>>> # Classify each Gutenberg document.
|
57 |
+
>>> from nltk.corpus import gutenberg
|
58 |
+
>>> for fileid in gutenberg.fileids(): # doctest: +SKIP
|
59 |
+
... doc = gutenberg.words(fileid) # doctest: +SKIP
|
60 |
+
... print(fileid, classifier.classify(document_features(doc))) # doctest: +SKIP
|
61 |
+
|
62 |
+
The parameters that a feature detector expects will vary, depending on
|
63 |
+
the task and the needs of the feature detector. For example, a
|
64 |
+
feature detector for word sense disambiguation (WSD) might take as its
|
65 |
+
input a sentence, and the index of a word that should be classified,
|
66 |
+
and return a featureset for that word. The following feature detector
|
67 |
+
for WSD includes features describing the left and right contexts of
|
68 |
+
the target word:
|
69 |
+
|
70 |
+
>>> def wsd_features(sentence, index):
|
71 |
+
... featureset = {}
|
72 |
+
... for i in range(max(0, index-3), index):
|
73 |
+
... featureset['left-context(%s)' % sentence[i]] = True
|
74 |
+
... for i in range(index, max(index+3, len(sentence))):
|
75 |
+
... featureset['right-context(%s)' % sentence[i]] = True
|
76 |
+
... return featureset
|
77 |
+
|
78 |
+
Training Classifiers
|
79 |
+
====================
|
80 |
+
Most classifiers are built by training them on a list of hand-labeled
|
81 |
+
examples, known as the "training set". Training sets are represented
|
82 |
+
as lists of ``(featuredict, label)`` tuples.
|
83 |
+
"""
|
84 |
+
|
85 |
+
from nltk.classify.api import ClassifierI, MultiClassifierI
|
86 |
+
from nltk.classify.decisiontree import DecisionTreeClassifier
|
87 |
+
from nltk.classify.maxent import (
|
88 |
+
BinaryMaxentFeatureEncoding,
|
89 |
+
ConditionalExponentialClassifier,
|
90 |
+
MaxentClassifier,
|
91 |
+
TypedMaxentFeatureEncoding,
|
92 |
+
)
|
93 |
+
from nltk.classify.megam import call_megam, config_megam
|
94 |
+
from nltk.classify.naivebayes import NaiveBayesClassifier
|
95 |
+
from nltk.classify.positivenaivebayes import PositiveNaiveBayesClassifier
|
96 |
+
from nltk.classify.rte_classify import RTEFeatureExtractor, rte_classifier, rte_features
|
97 |
+
from nltk.classify.scikitlearn import SklearnClassifier
|
98 |
+
from nltk.classify.senna import Senna
|
99 |
+
from nltk.classify.textcat import TextCat
|
100 |
+
from nltk.classify.util import accuracy, apply_features, log_likelihood
|
101 |
+
from nltk.classify.weka import WekaClassifier, config_weka
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (10.3 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/__pycache__/europarl_raw.cpython-310.pyc
ADDED
Binary file (1.19 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/__pycache__/util.cpython-310.pyc
ADDED
Binary file (4.54 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/__init__.cpython-310.pyc
ADDED
Binary file (5.72 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/aligned.cpython-310.pyc
ADDED
Binary file (4.26 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/api.cpython-310.pyc
ADDED
Binary file (18.8 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/bcp47.cpython-310.pyc
ADDED
Binary file (6.92 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/bnc.cpython-310.pyc
ADDED
Binary file (9.32 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/bracket_parse.cpython-310.pyc
ADDED
Binary file (9.83 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/categorized_sents.cpython-310.pyc
ADDED
Binary file (6.01 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/chasen.cpython-310.pyc
ADDED
Binary file (5 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/childes.cpython-310.pyc
ADDED
Binary file (18.4 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/chunked.cpython-310.pyc
ADDED
Binary file (8.76 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/cmudict.cpython-310.pyc
ADDED
Binary file (3.79 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/comparative_sents.cpython-310.pyc
ADDED
Binary file (10 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/conll.cpython-310.pyc
ADDED
Binary file (16.8 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/crubadan.cpython-310.pyc
ADDED
Binary file (3.98 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/dependency.cpython-310.pyc
ADDED
Binary file (4.16 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/framenet.cpython-310.pyc
ADDED
Binary file (105 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/ieer.cpython-310.pyc
ADDED
Binary file (3.85 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/indian.cpython-310.pyc
ADDED
Binary file (3.64 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/ipipan.cpython-310.pyc
ADDED
Binary file (11.2 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/knbc.cpython-310.pyc
ADDED
Binary file (6.02 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/lin.cpython-310.pyc
ADDED
Binary file (5.89 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/markdown.cpython-310.pyc
ADDED
Binary file (14.9 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/mte.cpython-310.pyc
ADDED
Binary file (15.4 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/nkjp.cpython-310.pyc
ADDED
Binary file (14.9 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/nombank.cpython-310.pyc
ADDED
Binary file (13.8 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/nps_chat.cpython-310.pyc
ADDED
Binary file (3.98 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/opinion_lexicon.cpython-310.pyc
ADDED
Binary file (4.49 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/panlex_lite.cpython-310.pyc
ADDED
Binary file (5.93 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/panlex_swadesh.cpython-310.pyc
ADDED
Binary file (4.01 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/pl196x.cpython-310.pyc
ADDED
Binary file (8 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/plaintext.cpython-310.pyc
ADDED
Binary file (8.67 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/ppattach.cpython-310.pyc
ADDED
Binary file (3.26 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/propbank.cpython-310.pyc
ADDED
Binary file (15.3 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/pros_cons.cpython-310.pyc
ADDED
Binary file (4.69 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/reviews.cpython-310.pyc
ADDED
Binary file (12.1 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/rte.cpython-310.pyc
ADDED
Binary file (4.92 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/semcor.cpython-310.pyc
ADDED
Binary file (9.04 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/senseval.cpython-310.pyc
ADDED
Binary file (5.39 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/sentiwordnet.cpython-310.pyc
ADDED
Binary file (5.24 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/sinica_treebank.cpython-310.pyc
ADDED
Binary file (3.09 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/string_category.cpython-310.pyc
ADDED
Binary file (1.95 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/switchboard.cpython-310.pyc
ADDED
Binary file (5.98 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/tagged.cpython-310.pyc
ADDED
Binary file (10.7 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/timit.cpython-310.pyc
ADDED
Binary file (16.6 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/toolbox.cpython-310.pyc
ADDED
Binary file (2.33 kB). View file
|
|
llmeval-env/lib/python3.10/site-packages/nltk/corpus/reader/__pycache__/twitter.cpython-310.pyc
ADDED
Binary file (4.67 kB). View file
|
|