Toggle navigation
Toggle navigation
This project
Loading...
Sign in
Marta Miranda
/
boletin_api
Go to a project
Toggle navigation
Projects
Groups
Snippets
Help
Toggle navigation pinning
Project
Activity
Repository
Pipelines
Graphs
Issues
0
Merge Requests
0
Wiki
Network
Create a new issue
Builds
Commits
Authored by
Enzo Yair
2023-10-10 07:13:23 -0300
Browse Files
Options
Browse Files
Download
Email Patches
Plain Diff
Commit
a67fda360c29294f36c567692cb5edb58d6c2915
a67fda36
1 parent
97b74a83
fix/utils.contador
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
with
4 additions
and
5 deletions
project/apps/edicto/tests/tests_edicto.py
project/apps/edicto/utils.py
project/apps/edicto/tests/tests_edicto.py
View file @
a67fda3
...
...
@@ -5,6 +5,6 @@ from edicto.models import Edicto
class
ContadorTestCase
(
TestCase
):
def
test_contador
(
self
):
edicto
=
"Texto de prueba con palabras números y expresiones 58. (...) (entre paréntesis [y corchetes])"
edicto
=
"Texto de prueba con palabras números y expresiones 58. (...) (entre paréntesis [y corchetes])
x=345
"
resultado
=
contador
(
edicto
)
self
.
assertEqual
(
resultado
,
1
6
)
self
.
assertEqual
(
resultado
,
1
5
)
...
...
project/apps/edicto/utils.py
View file @
a67fda3
...
...
@@ -2,8 +2,7 @@ import re
def
contador
(
edicto
):
expresiones
=
re
.
findall
(
r'
\
(
\
.
\
.
\
.'
,
edicto
)
edicto_sin_guiones
=
re
.
sub
(
r'(?<!
\
w)-|-(?!
\
w)'
,
' '
,
edicto
)
palabras
=
re
.
split
(
r'
\
s+'
,
edicto_sin_guiones
)
total_palabras
=
len
(
palabras
)
+
len
(
expresiones
)
palabras
=
edicto_sin_guiones
.
split
()
total_palabras
=
len
(
palabras
)
return
total_palabras
...
...
Please
register
or
login
to post a comment