Skip to content

Commit df8ce24

Browse files
feat: Refactoring of the reverse scored questions code 👽
1 parent 28fa106 commit df8ce24

10 files changed

Lines changed: 589 additions & 835 deletions

File tree

.coveragerc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[run]
22
branch = True
3-
omit = setup.py, quiz.py
3+
omit = setup.py, ipipneo/__init__.py, ipipneo/quiz.py
44

55
[report]
66
skip_empty = True

README.md

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
<img src="https://raw.githubusercontent.com/neural7/five-factor-e/main/doc/neural7.png" align="right" width="80" height="70"/>
22

3-
# Five Factor E Library 📦 🇧🇷
3+
# Five Factor E Library 📦 🌊
44

55
![version 1.5.0][img_version]
66
![python 3.7 | 3.8 | 3.9 | 3.10 | 3.11][python_version]
@@ -163,6 +163,7 @@ An example of the output of the results:
163163
{
164164
"Openness":{
165165
"O":24.29091080263288,
166+
"score": "low",
166167
"traits":[
167168
{
168169
"trait":1,
@@ -228,7 +229,7 @@ $ pip install five-factor-e[quiz]
228229
Example output with graphics:
229230

230231
<p align="center">
231-
<img src="https://raw.githubusercontent.com/neural7/five-factor-e/feature/v1.5.0/doc/sample-light-1.png" alt="Representation of the Big Five"/>
232+
<img src="https://raw.githubusercontent.com/neural7/five-factor-e/feature/v1.5.0/doc/sample-light-1.png" alt="Big Five Results" border="1"/>
232233
</p>
233234

234235
*The complete result is saved in the run folder in json format*.

RELEASES.md

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,13 @@
11
<img src="https://raw.githubusercontent.com/neural7/five-factor-e/main/doc/neural7.png" align="right" width="80" height="70"/>
22

3-
### Releases
3+
### Releases 🎈
4+
5+
Release **[1.6.0](https://github.com/neural7/five-factor-e/releases/tag/v1.6.0)**:
6+
7+
* Added to the return with the big-five averages: (low, average, high);
8+
* Refactoring of the reverse scored questions code;
9+
* Added to the quiz program, the verification of the translation of the questions (120 or 300);
10+
* Added new topics to PyPI setup.
411

512
Release **[1.5.0](https://github.com/neural7/five-factor-e/releases/tag/v1.5.0)**:
613

ipipneo/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
"""Import of the classes to be used."""
22

33
__name__ = "five-factor-e"
4-
__version__ = "1.5.0"
4+
__version__ = "1.6.0"
55

66
from ipipneo.ipipneo import IpipNeo

ipipneo/facet.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -191,3 +191,24 @@ def personality(self, size: int, big5: dict, traits: dict, label: str) -> dict:
191191
raise BaseException(f"The number of questions setting is wrong: {str(e)}")
192192

193193
return create_big5_dict(label=label, big5=big5, x=X, y=Y) or {}
194+
195+
def big_five_level(self, big5: dict, label: str) -> dict:
196+
"""
197+
Add the average for each Big-Five.
198+
199+
Args:
200+
- big5: Dictionary of personality Big-Five.
201+
- label: Capital letter referring to the Big-Five to be checked the average.
202+
"""
203+
big5_ocean_is_valid(label=label)
204+
205+
score = big5.get(label, 0)
206+
207+
if score < FacetLevel.LOW.value:
208+
big5["score"] = "low"
209+
if score >= FacetLevel.LOW.value and score <= FacetLevel.HIGH.value:
210+
big5["score"] = "average"
211+
if score > FacetLevel.HIGH.value:
212+
big5["score"] = "high"
213+
214+
return big5

ipipneo/ipipneo.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
__copyright__ = "Copyright Neural7 2022, Big 5 Personality Traits"
66
__credits__ = ["John A. Johnson", "Dhiru Kholia"]
77
__license__ = "MIT"
8-
__version__ = "1.5.0"
8+
__version__ = "1.6.0"
99
__status__ = "production"
1010

1111
import copy
@@ -88,11 +88,11 @@ def evaluator(self, sex: str, age: int, score: list) -> dict:
8888
"age": age,
8989
"result": {
9090
"personalities": [
91-
{"Openness": O},
92-
{"Conscientiousness": C},
93-
{"Extraversion": E},
94-
{"Agreeableness": A},
95-
{"Neuroticism": N},
91+
{"Openness": self.big_five_level(big5=O, label="O")},
92+
{"Conscientiousness": self.big_five_level(big5=C, label="C")},
93+
{"Extraversion": self.big_five_level(big5=E, label="E")},
94+
{"Agreeableness": self.big_five_level(big5=A, label="A")},
95+
{"Neuroticism": self.big_five_level(big5=N, label="N")},
9696
]
9797
},
9898
},

ipipneo/quiz.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,11 +77,16 @@ def get_select(lang: int, question: int) -> list:
7777
]
7878

7979

80-
def question_translate() -> list:
81-
"""Return the available question translations."""
80+
def question_translate_120() -> list:
81+
"""Return the available question translations (120)."""
8282
return ["0. IPIP-NEO Original", "1. EN-US", "2. PT-BR", "3. ES-ES"]
8383

8484

85+
def question_translate_300() -> list:
86+
"""Return the available question translations (300)."""
87+
return ["0. IPIP-NEO Original"]
88+
89+
8590
def quiz(inventory: int, sex: str, age: int, shuffle: str, lang: int) -> None:
8691
"""
8792
Inventory / quiz of questions.
@@ -399,7 +404,10 @@ def main() -> None:
399404
shuffle = str(next(filter(yes_or_no.__contains__, replies)))
400405

401406
print("\n====================================================================")
402-
print(*question_translate(), sep="\n")
407+
if inventory == 120:
408+
print(*question_translate_120(), sep="\n")
409+
elif inventory == 300:
410+
print(*question_translate_300(), sep="\n")
403411

404412
replies = map(
405413
input,

0 commit comments

Comments
 (0)