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
Martín Miranda
2023-10-10 10:10:11 -0300
Browse Files
Options
Browse Files
Download
Plain Diff
Commit
ca3fce70312b7cac9aa1909455c84fd10d4ca661
ca3fce70
2 parents
97b74a83
a67fda36
Merge branch 'fix/utils' into 'develop'
fix/utils.contador See merge request
!70
Show 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 @
ca3fce7
...
...
@@ -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 @
ca3fce7
...
...
@@ -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