classivax 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Luiz Felipe Fernandes Neves
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.4
2
+ Name: classivax
3
+ Version: 0.1.0
4
+ Summary: Classify vaccine-related news headlines into topic categories using a Recognizing Textual Entailment (RTE) approach.
5
+ Author: Luiz Felipe Fernandes Neves
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/lffernandes08/classivax
8
+ Project-URL: Repository, https://github.com/lffernandes08/classivax
9
+ Project-URL: Model, https://huggingface.co/LuizNeves/BERT-NLI-vaccine-v2
10
+ Project-URL: Paper, https://doi.org/10.5117/CCR2025.1.1.NEVE
11
+ Keywords: nlp,text-classification,natural-language-inference,textual-entailment,vaccine,science-communication,computational-social-science
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: transformers>=4.30
21
+ Requires-Dist: torch>=2.0
22
+ Requires-Dist: pandas>=1.5
23
+ Dynamic: license-file
24
+
25
+ # ClassiVax
26
+
27
+ Classify vaccine-related news headlines into topic categories using a **Recognizing Textual Entailment (RTE)** approach, powered by the [`LuizNeves/BERT-NLI-vaccine-v2`](https://huggingface.co/LuizNeves/BERT-NLI-vaccine-v2) model.
28
+
29
+ Built on the method described in:
30
+
31
+ > Neves, L. F. F., Camargo, C. Q., & Massarani, L. (2025). Boosting Transformers: Recognizing Textual Entailment for Classification of Vaccine News Coverage. *Computational Communication Research*, 7(1), 1–32. https://doi.org/10.5117/CCR2025.1.1.NEVE
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install classivax
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ### Default classes (10 vaccine-related topics from the paper)
42
+
43
+ ```python
44
+ from classivax import ClassiVaxClassifier
45
+
46
+ clf = ClassiVaxClassifier()
47
+
48
+ result = clf.classify("Twitter will begin removing vaccine misinformation")
49
+ print(result["class"]) # "Vaccine Hesitancy and Mis-/Disinformation"
50
+ print(result["score"]) # e.g. 0.999
51
+ ```
52
+
53
+ ### Batch classification
54
+
55
+ ```python
56
+ headlines = [
57
+ "Twitter will begin removing vaccine misinformation",
58
+ "Britain begins coronavirus vaccine rollout",
59
+ "COVID-19 vaccination key to economic recovery",
60
+ ]
61
+
62
+ df = clf.classify_batch(headlines)
63
+ print(df)
64
+ ```
65
+
66
+ ### Custom classes
67
+
68
+ The underlying RTE approach also supports classifying text against any set of natural-language class descriptions you define — not just the original 10 classes.
69
+
70
+ ```python
71
+ custom_classes = {
72
+ "Vaccine Safety Debate": "The headline discusses concerns, controversies, or debates about vaccine safety",
73
+ "Vaccine Logistics": "The headline discusses shipping, storage, cold chain, or distribution logistics for vaccines",
74
+ }
75
+
76
+ clf = ClassiVaxClassifier(classes=custom_classes)
77
+ result = clf.classify("Cold storage shortages delay vaccine shipments to rural areas")
78
+ print(result["class"]) # "Vaccine Logistics"
79
+ ```
80
+
81
+ **Note:** the underlying model was fine-tuned specifically on English-language, vaccine-related headlines from 2020–2021. Using custom classes outside this domain is supported, but accuracy has not been formally evaluated beyond the original study's scope — treat results on very different domains with appropriate caution.
82
+
83
+ ## The 10 default classes
84
+
85
+ | Class | Description |
86
+ |---|---|
87
+ | Global Access to Vaccine | Initiatives for equal access to COVID-19 vaccines (e.g., COVAX), and/or the need to combat inequity, ensure global distribution, and contain the disease, especially in low- and middle-income countries |
88
+ | Science and Technology | The science behind vaccine development, including research, studies, safety and efficacy trials, emergency approval, and side effects |
89
+ | Public Health Policies | Vaccine mandates, vaccine passports, and/or other public health policies such as social distancing, quarantine, lockdowns, and mask mandates |
90
+ | Vaccination Rollout/Campaign | Vaccination rollout, campaigns, priority groups, vaccine deals, and/or the monitoring of vaccination rates |
91
+ | Vaccine Hesitancy and Mis-/Disinformation | The circulation of disinformation and misinformation regarding vaccines, which contribute to vaccine hesitancy and reluctance |
92
+ | Public Endorsement to Vaccine | Public endorsement and incentive for vaccines, such as celebrities and artists getting vaccinated |
93
+ | Institutional Affairs | Institutional and governmental issues, political disputes, conflicts, political authorities, and export bans |
94
+ | Problems in Vaccination | Problems in vaccination, such as delays, fraud, disparities, vaccine shortages |
95
+ | Public Perception of Vaccine | Opinion polls and surveys on the public perception of vaccines and/or willingness to get vaccinated |
96
+ | Economic Consequences | The impacts and benefits of vaccination on the economy |
97
+
98
+ ## How it works
99
+
100
+ For each headline, the classifier tests it against every class description as a text-hypothesis pair, following the entailment framework: the headline is the *text* (T), and each class description is a candidate *hypothesis* (H). The class whose description achieves the highest entailment score is selected as the prediction.
101
+
102
+ ## Citation
103
+
104
+ If you use this library or the underlying model in your research, please cite:
105
+
106
+ ```bibtex
107
+ @article{neves2025boosting,
108
+ title={Boosting Transformers: Recognizing Textual Entailment for Classification of Vaccine News Coverage},
109
+ author={Neves, Luiz F. F. and Camargo, Chico Q. and Massarani, Luisa},
110
+ journal={Computational Communication Research},
111
+ volume={7},
112
+ number={1},
113
+ pages={1--32},
114
+ year={2025},
115
+ doi={10.5117/CCR2025.1.1.NEVE}
116
+ }
117
+ ```
118
+
119
+ ## License
120
+
121
+ MIT
@@ -0,0 +1,97 @@
1
+ # ClassiVax
2
+
3
+ Classify vaccine-related news headlines into topic categories using a **Recognizing Textual Entailment (RTE)** approach, powered by the [`LuizNeves/BERT-NLI-vaccine-v2`](https://huggingface.co/LuizNeves/BERT-NLI-vaccine-v2) model.
4
+
5
+ Built on the method described in:
6
+
7
+ > Neves, L. F. F., Camargo, C. Q., & Massarani, L. (2025). Boosting Transformers: Recognizing Textual Entailment for Classification of Vaccine News Coverage. *Computational Communication Research*, 7(1), 1–32. https://doi.org/10.5117/CCR2025.1.1.NEVE
8
+
9
+ ## Installation
10
+
11
+ ```bash
12
+ pip install classivax
13
+ ```
14
+
15
+ ## Usage
16
+
17
+ ### Default classes (10 vaccine-related topics from the paper)
18
+
19
+ ```python
20
+ from classivax import ClassiVaxClassifier
21
+
22
+ clf = ClassiVaxClassifier()
23
+
24
+ result = clf.classify("Twitter will begin removing vaccine misinformation")
25
+ print(result["class"]) # "Vaccine Hesitancy and Mis-/Disinformation"
26
+ print(result["score"]) # e.g. 0.999
27
+ ```
28
+
29
+ ### Batch classification
30
+
31
+ ```python
32
+ headlines = [
33
+ "Twitter will begin removing vaccine misinformation",
34
+ "Britain begins coronavirus vaccine rollout",
35
+ "COVID-19 vaccination key to economic recovery",
36
+ ]
37
+
38
+ df = clf.classify_batch(headlines)
39
+ print(df)
40
+ ```
41
+
42
+ ### Custom classes
43
+
44
+ The underlying RTE approach also supports classifying text against any set of natural-language class descriptions you define — not just the original 10 classes.
45
+
46
+ ```python
47
+ custom_classes = {
48
+ "Vaccine Safety Debate": "The headline discusses concerns, controversies, or debates about vaccine safety",
49
+ "Vaccine Logistics": "The headline discusses shipping, storage, cold chain, or distribution logistics for vaccines",
50
+ }
51
+
52
+ clf = ClassiVaxClassifier(classes=custom_classes)
53
+ result = clf.classify("Cold storage shortages delay vaccine shipments to rural areas")
54
+ print(result["class"]) # "Vaccine Logistics"
55
+ ```
56
+
57
+ **Note:** the underlying model was fine-tuned specifically on English-language, vaccine-related headlines from 2020–2021. Using custom classes outside this domain is supported, but accuracy has not been formally evaluated beyond the original study's scope — treat results on very different domains with appropriate caution.
58
+
59
+ ## The 10 default classes
60
+
61
+ | Class | Description |
62
+ |---|---|
63
+ | Global Access to Vaccine | Initiatives for equal access to COVID-19 vaccines (e.g., COVAX), and/or the need to combat inequity, ensure global distribution, and contain the disease, especially in low- and middle-income countries |
64
+ | Science and Technology | The science behind vaccine development, including research, studies, safety and efficacy trials, emergency approval, and side effects |
65
+ | Public Health Policies | Vaccine mandates, vaccine passports, and/or other public health policies such as social distancing, quarantine, lockdowns, and mask mandates |
66
+ | Vaccination Rollout/Campaign | Vaccination rollout, campaigns, priority groups, vaccine deals, and/or the monitoring of vaccination rates |
67
+ | Vaccine Hesitancy and Mis-/Disinformation | The circulation of disinformation and misinformation regarding vaccines, which contribute to vaccine hesitancy and reluctance |
68
+ | Public Endorsement to Vaccine | Public endorsement and incentive for vaccines, such as celebrities and artists getting vaccinated |
69
+ | Institutional Affairs | Institutional and governmental issues, political disputes, conflicts, political authorities, and export bans |
70
+ | Problems in Vaccination | Problems in vaccination, such as delays, fraud, disparities, vaccine shortages |
71
+ | Public Perception of Vaccine | Opinion polls and surveys on the public perception of vaccines and/or willingness to get vaccinated |
72
+ | Economic Consequences | The impacts and benefits of vaccination on the economy |
73
+
74
+ ## How it works
75
+
76
+ For each headline, the classifier tests it against every class description as a text-hypothesis pair, following the entailment framework: the headline is the *text* (T), and each class description is a candidate *hypothesis* (H). The class whose description achieves the highest entailment score is selected as the prediction.
77
+
78
+ ## Citation
79
+
80
+ If you use this library or the underlying model in your research, please cite:
81
+
82
+ ```bibtex
83
+ @article{neves2025boosting,
84
+ title={Boosting Transformers: Recognizing Textual Entailment for Classification of Vaccine News Coverage},
85
+ author={Neves, Luiz F. F. and Camargo, Chico Q. and Massarani, Luisa},
86
+ journal={Computational Communication Research},
87
+ volume={7},
88
+ number={1},
89
+ pages={1--32},
90
+ year={2025},
91
+ doi={10.5117/CCR2025.1.1.NEVE}
92
+ }
93
+ ```
94
+
95
+ ## License
96
+
97
+ MIT
@@ -0,0 +1,7 @@
1
+ """ClassiVax — classify vaccine-related news headlines using textual entailment."""
2
+
3
+ from .classifier import ClassiVaxClassifier
4
+ from .classes_default import DEFAULT_CLASSES
5
+
6
+ __all__ = ["ClassiVaxClassifier", "DEFAULT_CLASSES"]
7
+ __version__ = "0.1.0"
@@ -0,0 +1,62 @@
1
+ """
2
+ Default topic classes for vaccine-related news headline classification.
3
+
4
+ These 10 classes and their descriptions were defined and validated in:
5
+
6
+ Neves, L. F. F., Camargo, C. Q., & Massarani, L. (2025). Boosting
7
+ Transformers: Recognizing Textual Entailment for Classification of
8
+ Vaccine News Coverage. Computational Communication Research, 7(1), 1-32.
9
+ https://doi.org/10.5117/CCR2025.1.1.NEVE
10
+
11
+ See Table 3 of the paper for the full description and illustrative
12
+ headlines for each class.
13
+ """
14
+
15
+ DEFAULT_CLASSES = {
16
+ "Global Access to Vaccine": (
17
+ "The headline addresses initiatives for equal access to covid-19 "
18
+ "vaccines, such as COVAX, and/or the need to combat inequity, "
19
+ "ensure global distribution, and contain the disease, especially "
20
+ "to low and middle-income countries"
21
+ ),
22
+ "Science and Technology": (
23
+ "The headline addresses the science behind vaccine development, "
24
+ "including research, studies, safety and efficacy trials, "
25
+ "emergency approval, and side effects"
26
+ ),
27
+ "Public Health Policies": (
28
+ "The headline addresses vaccine mandates, vaccine passports, "
29
+ "and/or other public health policies such as social distancing, "
30
+ "quarantine, lockdowns, and mask mandates"
31
+ ),
32
+ "Vaccination Rollout/Campaign": (
33
+ "The headline addresses vaccination rollout, campaigns, priority "
34
+ "groups, vaccine deals, and/or the monitoring of vaccination rates"
35
+ ),
36
+ "Vaccine Hesitancy and Mis-/Disinformation": (
37
+ "The headline addresses the circulation of disinformation and "
38
+ "misinformation regarding vaccines, which contribute to vaccine "
39
+ "hesitancy and reluctance"
40
+ ),
41
+ "Public Endorsement to Vaccine": (
42
+ "The headline addresses public endorsement and incentive for "
43
+ "vaccines, such as celebrities and artists getting vaccinated"
44
+ ),
45
+ "Institutional Affairs": (
46
+ "The headline addresses institutional and governmental issues, "
47
+ "political disputes, conflicts, political authorities, and "
48
+ "export bans"
49
+ ),
50
+ "Problems in Vaccination": (
51
+ "The headline addresses problems in vaccination, such as delays, "
52
+ "fraud, disparities, vaccine shortages"
53
+ ),
54
+ "Public Perception of Vaccine": (
55
+ "The headline addresses opinion polls and surveys on the public "
56
+ "perception of vaccines and/or willingness to get vaccinated"
57
+ ),
58
+ "Economic Consequences": (
59
+ "The headline addresses the impacts and benefits of vaccination "
60
+ "on the economy"
61
+ ),
62
+ }
@@ -0,0 +1,100 @@
1
+ """Core classifier for ClassiVax."""
2
+
3
+ from __future__ import annotations
4
+
5
+ from typing import Dict, List, Optional
6
+
7
+ from transformers import pipeline
8
+
9
+ from .classes_default import DEFAULT_CLASSES
10
+
11
+ DEFAULT_MODEL = "LuizNeves/BERT-NLI-vaccine-v2"
12
+
13
+
14
+ class ClassiVaxClassifier:
15
+ """Classify news headlines into topic classes using a Recognizing
16
+ Textual Entailment (RTE) approach.
17
+
18
+ By default, this uses the 10 vaccine-related classes described in
19
+ Neves, Camargo & Massarani (2025) and the fine-tuned model published
20
+ at https://huggingface.co/LuizNeves/BERT-NLI-vaccine-v2.
21
+
22
+ Custom classes can be supplied to adapt the classifier to other
23
+ domains or research questions. Note that the underlying model was
24
+ fine-tuned specifically on vaccine-related headlines, so accuracy on
25
+ very different domains is not guaranteed — see the project README
26
+ for details.
27
+
28
+ Parameters
29
+ ----------
30
+ classes:
31
+ Optional mapping of ``{class_name: natural_language_description}``.
32
+ If omitted, the 10 default vaccine-related classes are used.
33
+ model_name:
34
+ Hugging Face model identifier to load. Defaults to
35
+ ``LuizNeves/BERT-NLI-vaccine-v2``.
36
+ """
37
+
38
+ def __init__(
39
+ self,
40
+ classes: Optional[Dict[str, str]] = None,
41
+ model_name: str = DEFAULT_MODEL,
42
+ ) -> None:
43
+ self.classes = classes if classes is not None else DEFAULT_CLASSES
44
+ self.model_name = model_name
45
+ self._pipe = pipeline("text-classification", model=model_name)
46
+
47
+ def classify(self, text: str) -> Dict:
48
+ """Classify a single headline.
49
+
50
+ Returns
51
+ -------
52
+ dict
53
+ ``{"class": str, "score": float, "all_scores": dict}``.
54
+ ``class`` and ``score`` refer to the class with the highest
55
+ entailment score. ``all_scores`` maps every class name to its
56
+ raw ``(label, score)`` result, for inspection.
57
+ """
58
+ all_results = {}
59
+ best_class = None
60
+ best_score = -1.0
61
+
62
+ for class_name, description in self.classes.items():
63
+ result = self._pipe({"text": text, "text_pair": description})
64
+ all_results[class_name] = {
65
+ "label": result["label"],
66
+ "score": result["score"],
67
+ }
68
+ entailment_score = (
69
+ result["score"] if result["label"] == "entailment" else 0.0
70
+ )
71
+ if entailment_score > best_score:
72
+ best_score = entailment_score
73
+ best_class = class_name
74
+
75
+ return {
76
+ "class": best_class,
77
+ "score": all_results[best_class]["score"] if best_class else None,
78
+ "all_scores": all_results,
79
+ }
80
+
81
+ def classify_batch(self, texts: List[str]):
82
+ """Classify a list of headlines.
83
+
84
+ Returns
85
+ -------
86
+ pandas.DataFrame
87
+ One row per input text, with columns ``text``, ``class``, and
88
+ ``score``.
89
+ """
90
+ import pandas as pd
91
+
92
+ rows = []
93
+ for text in texts:
94
+ result = self.classify(text)
95
+ rows.append({
96
+ "text": text,
97
+ "class": result["class"],
98
+ "score": result["score"],
99
+ })
100
+ return pd.DataFrame(rows)
@@ -0,0 +1,121 @@
1
+ Metadata-Version: 2.4
2
+ Name: classivax
3
+ Version: 0.1.0
4
+ Summary: Classify vaccine-related news headlines into topic categories using a Recognizing Textual Entailment (RTE) approach.
5
+ Author: Luiz Felipe Fernandes Neves
6
+ License: MIT
7
+ Project-URL: Homepage, https://github.com/lffernandes08/classivax
8
+ Project-URL: Repository, https://github.com/lffernandes08/classivax
9
+ Project-URL: Model, https://huggingface.co/LuizNeves/BERT-NLI-vaccine-v2
10
+ Project-URL: Paper, https://doi.org/10.5117/CCR2025.1.1.NEVE
11
+ Keywords: nlp,text-classification,natural-language-inference,textual-entailment,vaccine,science-communication,computational-social-science
12
+ Classifier: Programming Language :: Python :: 3
13
+ Classifier: License :: OSI Approved :: MIT License
14
+ Classifier: Operating System :: OS Independent
15
+ Classifier: Intended Audience :: Science/Research
16
+ Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
17
+ Requires-Python: >=3.9
18
+ Description-Content-Type: text/markdown
19
+ License-File: LICENSE
20
+ Requires-Dist: transformers>=4.30
21
+ Requires-Dist: torch>=2.0
22
+ Requires-Dist: pandas>=1.5
23
+ Dynamic: license-file
24
+
25
+ # ClassiVax
26
+
27
+ Classify vaccine-related news headlines into topic categories using a **Recognizing Textual Entailment (RTE)** approach, powered by the [`LuizNeves/BERT-NLI-vaccine-v2`](https://huggingface.co/LuizNeves/BERT-NLI-vaccine-v2) model.
28
+
29
+ Built on the method described in:
30
+
31
+ > Neves, L. F. F., Camargo, C. Q., & Massarani, L. (2025). Boosting Transformers: Recognizing Textual Entailment for Classification of Vaccine News Coverage. *Computational Communication Research*, 7(1), 1–32. https://doi.org/10.5117/CCR2025.1.1.NEVE
32
+
33
+ ## Installation
34
+
35
+ ```bash
36
+ pip install classivax
37
+ ```
38
+
39
+ ## Usage
40
+
41
+ ### Default classes (10 vaccine-related topics from the paper)
42
+
43
+ ```python
44
+ from classivax import ClassiVaxClassifier
45
+
46
+ clf = ClassiVaxClassifier()
47
+
48
+ result = clf.classify("Twitter will begin removing vaccine misinformation")
49
+ print(result["class"]) # "Vaccine Hesitancy and Mis-/Disinformation"
50
+ print(result["score"]) # e.g. 0.999
51
+ ```
52
+
53
+ ### Batch classification
54
+
55
+ ```python
56
+ headlines = [
57
+ "Twitter will begin removing vaccine misinformation",
58
+ "Britain begins coronavirus vaccine rollout",
59
+ "COVID-19 vaccination key to economic recovery",
60
+ ]
61
+
62
+ df = clf.classify_batch(headlines)
63
+ print(df)
64
+ ```
65
+
66
+ ### Custom classes
67
+
68
+ The underlying RTE approach also supports classifying text against any set of natural-language class descriptions you define — not just the original 10 classes.
69
+
70
+ ```python
71
+ custom_classes = {
72
+ "Vaccine Safety Debate": "The headline discusses concerns, controversies, or debates about vaccine safety",
73
+ "Vaccine Logistics": "The headline discusses shipping, storage, cold chain, or distribution logistics for vaccines",
74
+ }
75
+
76
+ clf = ClassiVaxClassifier(classes=custom_classes)
77
+ result = clf.classify("Cold storage shortages delay vaccine shipments to rural areas")
78
+ print(result["class"]) # "Vaccine Logistics"
79
+ ```
80
+
81
+ **Note:** the underlying model was fine-tuned specifically on English-language, vaccine-related headlines from 2020–2021. Using custom classes outside this domain is supported, but accuracy has not been formally evaluated beyond the original study's scope — treat results on very different domains with appropriate caution.
82
+
83
+ ## The 10 default classes
84
+
85
+ | Class | Description |
86
+ |---|---|
87
+ | Global Access to Vaccine | Initiatives for equal access to COVID-19 vaccines (e.g., COVAX), and/or the need to combat inequity, ensure global distribution, and contain the disease, especially in low- and middle-income countries |
88
+ | Science and Technology | The science behind vaccine development, including research, studies, safety and efficacy trials, emergency approval, and side effects |
89
+ | Public Health Policies | Vaccine mandates, vaccine passports, and/or other public health policies such as social distancing, quarantine, lockdowns, and mask mandates |
90
+ | Vaccination Rollout/Campaign | Vaccination rollout, campaigns, priority groups, vaccine deals, and/or the monitoring of vaccination rates |
91
+ | Vaccine Hesitancy and Mis-/Disinformation | The circulation of disinformation and misinformation regarding vaccines, which contribute to vaccine hesitancy and reluctance |
92
+ | Public Endorsement to Vaccine | Public endorsement and incentive for vaccines, such as celebrities and artists getting vaccinated |
93
+ | Institutional Affairs | Institutional and governmental issues, political disputes, conflicts, political authorities, and export bans |
94
+ | Problems in Vaccination | Problems in vaccination, such as delays, fraud, disparities, vaccine shortages |
95
+ | Public Perception of Vaccine | Opinion polls and surveys on the public perception of vaccines and/or willingness to get vaccinated |
96
+ | Economic Consequences | The impacts and benefits of vaccination on the economy |
97
+
98
+ ## How it works
99
+
100
+ For each headline, the classifier tests it against every class description as a text-hypothesis pair, following the entailment framework: the headline is the *text* (T), and each class description is a candidate *hypothesis* (H). The class whose description achieves the highest entailment score is selected as the prediction.
101
+
102
+ ## Citation
103
+
104
+ If you use this library or the underlying model in your research, please cite:
105
+
106
+ ```bibtex
107
+ @article{neves2025boosting,
108
+ title={Boosting Transformers: Recognizing Textual Entailment for Classification of Vaccine News Coverage},
109
+ author={Neves, Luiz F. F. and Camargo, Chico Q. and Massarani, Luisa},
110
+ journal={Computational Communication Research},
111
+ volume={7},
112
+ number={1},
113
+ pages={1--32},
114
+ year={2025},
115
+ doi={10.5117/CCR2025.1.1.NEVE}
116
+ }
117
+ ```
118
+
119
+ ## License
120
+
121
+ MIT
@@ -0,0 +1,12 @@
1
+ LICENSE
2
+ README.md
3
+ pyproject.toml
4
+ classivax/__init__.py
5
+ classivax/classes_default.py
6
+ classivax/classifier.py
7
+ classivax.egg-info/PKG-INFO
8
+ classivax.egg-info/SOURCES.txt
9
+ classivax.egg-info/dependency_links.txt
10
+ classivax.egg-info/requires.txt
11
+ classivax.egg-info/top_level.txt
12
+ tests/test_classifier.py
@@ -0,0 +1,3 @@
1
+ transformers>=4.30
2
+ torch>=2.0
3
+ pandas>=1.5
@@ -0,0 +1 @@
1
+ classivax
@@ -0,0 +1,44 @@
1
+ [build-system]
2
+ requires = ["setuptools>=68.0", "wheel"]
3
+ build-backend = "setuptools.build_meta"
4
+
5
+ [project]
6
+ name = "classivax"
7
+ version = "0.1.0"
8
+ description = "Classify vaccine-related news headlines into topic categories using a Recognizing Textual Entailment (RTE) approach."
9
+ readme = "README.md"
10
+ requires-python = ">=3.9"
11
+ license = { text = "MIT" }
12
+ authors = [
13
+ { name = "Luiz Felipe Fernandes Neves" }
14
+ ]
15
+ keywords = [
16
+ "nlp",
17
+ "text-classification",
18
+ "natural-language-inference",
19
+ "textual-entailment",
20
+ "vaccine",
21
+ "science-communication",
22
+ "computational-social-science",
23
+ ]
24
+ classifiers = [
25
+ "Programming Language :: Python :: 3",
26
+ "License :: OSI Approved :: MIT License",
27
+ "Operating System :: OS Independent",
28
+ "Intended Audience :: Science/Research",
29
+ "Topic :: Scientific/Engineering :: Artificial Intelligence",
30
+ ]
31
+ dependencies = [
32
+ "transformers>=4.30",
33
+ "torch>=2.0",
34
+ "pandas>=1.5",
35
+ ]
36
+
37
+ [project.urls]
38
+ Homepage = "https://github.com/lffernandes08/classivax"
39
+ Repository = "https://github.com/lffernandes08/classivax"
40
+ Model = "https://huggingface.co/LuizNeves/BERT-NLI-vaccine-v2"
41
+ Paper = "https://doi.org/10.5117/CCR2025.1.1.NEVE"
42
+
43
+ [tool.setuptools.packages.find]
44
+ include = ["classivax*"]
@@ -0,0 +1,4 @@
1
+ [egg_info]
2
+ tag_build =
3
+ tag_date = 0
4
+
@@ -0,0 +1,56 @@
1
+ """
2
+ Basic tests for ClassiVaxClassifier.
3
+
4
+ These tests download the model from the Hugging Face Hub on first run,
5
+ so they require an internet connection and may take a while the first
6
+ time they execute.
7
+ """
8
+
9
+ import pandas as pd
10
+ import pytest
11
+
12
+ from classivax import ClassiVaxClassifier, DEFAULT_CLASSES
13
+
14
+
15
+ @pytest.fixture(scope="module")
16
+ def classifier():
17
+ return ClassiVaxClassifier()
18
+
19
+
20
+ def test_default_classes_loaded(classifier):
21
+ assert classifier.classes == DEFAULT_CLASSES
22
+ assert len(classifier.classes) == 10
23
+
24
+
25
+ def test_classify_single_headline(classifier):
26
+ headline = "Twitter will begin removing vaccine misinformation"
27
+ result = classifier.classify(headline)
28
+
29
+ assert result["class"] == "Vaccine Hesitancy and Mis-/Disinformation"
30
+ assert result["score"] > 0.9
31
+ assert len(result["all_scores"]) == 10
32
+
33
+
34
+ def test_classify_batch(classifier):
35
+ headlines = [
36
+ "Twitter will begin removing vaccine misinformation",
37
+ "Britain begins coronavirus vaccine rollout",
38
+ ]
39
+ df = classifier.classify_batch(headlines)
40
+
41
+ assert isinstance(df, pd.DataFrame)
42
+ assert len(df) == 2
43
+ assert list(df.columns) == ["text", "class", "score"]
44
+
45
+
46
+ def test_custom_classes():
47
+ custom_classes = {
48
+ "Sports": "The headline is about a sports event or athlete",
49
+ "Weather": "The headline is about weather conditions or forecasts",
50
+ }
51
+ clf = ClassiVaxClassifier(classes=custom_classes)
52
+
53
+ assert clf.classes == custom_classes
54
+
55
+ result = clf.classify("Storm expected to hit the coast this weekend")
56
+ assert result["class"] in custom_classes