Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
Allzweckmesser
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Messerschleifer
Allzweckmesser
Commits
88c2b038
Commit
88c2b038
authored
6 years ago
by
Simon Will
Browse files
Options
Downloads
Patches
Plain Diff
Add after_syllable Position classmethod
parent
97583a07
No related branches found
Branches containing commit
No related tags found
No related merge requests found
Changes
2
Hide whitespace changes
Inline
Side-by-side
Showing
2 changed files
allzweckmesser/meters.py
+3
-3
3 additions, 3 deletions
allzweckmesser/meters.py
allzweckmesser/model.py
+37
-0
37 additions, 0 deletions
allzweckmesser/model.py
with
40 additions
and
3 deletions
allzweckmesser/meters.py
+
3
−
3
View file @
88c2b038
...
...
@@ -119,15 +119,15 @@ ALL_METERS = {
'
hendecasyllables
'
:
Meter
(
'
Phalaecian Hendecasyllable
'
,
AEOLIC_BASE
+
r
'
(–)(⏑)(⏑)(–)(⏑)(–)(⏑)(–)(⏑|–)
'
,
breaks
=
[[(
'
element
'
,
6
,
'
After sixth
element
'
)]],
breaks
=
[[(
'
syllable
'
,
6
,
'
After sixth
syllable
'
)]],
short_name
=
'
hendecasyllables
'
,
id
=
6
),
'
scazon
'
:
Meter
(
'
Choliamb
'
,
r
'
(⏑|–)(–)(⏑)(–)(⏑|–)(–)(⏑)(–)(⏑)(–)(–)(⏑|–)
'
,
breaks
=
[[(
'
element
'
,
5
,
'
After
sixth element
'
)],
[(
'
element
'
,
7
,
'
After s
ixth element
'
)]],
breaks
=
[[(
'
syllable
'
,
5
,
'
After
fifth syllable
'
)],
[(
'
syllable
'
,
7
,
'
After s
eventh syllable
'
)]],
short_name
=
'
scazon
'
,
id
=
7
),
...
...
This diff is collapsed.
Click to expand it.
allzweckmesser/model.py
+
37
−
0
View file @
88c2b038
...
...
@@ -575,11 +575,48 @@ class Position:
# TODO: Implement this.
pass
@classmethod
def
after_syllable
(
cls
,
reading
:
Reading
,
syll_num
:
int
)
->
'
Position
'
:
morae
=
0
syllables
=
0
punctuation
=
''
for
token
in
reading
.
tokens
:
if
token
.
is_punct
():
punctuation
+=
token
.
text
for
i
,
syllable
in
enumerate
(
token
.
syllables
):
word_boundary
=
i
==
0
if
syllables
==
syll_num
and
syllable
.
syllable_length
>
0
:
position
=
cls
(
reading
=
reading
,
mora
=
morae
,
token
=
token
,
syllable
=
syllable
,
word_boundary
=
word_boundary
,
punctuation
=
punctuation
)
return
position
else
:
morae
+=
syllable
.
syllable_length
if
syllable
.
syllable_length
>
0
:
syllables
+=
1
punctuation
=
''
else
:
# The position has not been found. There are two possibilities:
if
syllables
==
syll_num
:
# The position is at the end of the sentence.
position
=
cls
(
reading
=
reading
,
mora
=
morae
,
token
=
None
,
syllable
=
None
,
word_boundary
=
True
,
punctuation
=
punctuation
)
return
position
else
:
# There is no syllable boundary at the given syllable.
return
None
@classmethod
def
after
(
cls
,
type
:
str
,
reading
:
Reading
,
position_number
:
int
,
meter
:
'
.meters.Meter
'
)
->
'
Position
'
:
if
type
==
'
mora
'
:
return
cls
.
after_mora
(
reading
,
position_number
)
elif
type
==
'
syllable
'
:
return
cls
.
after_syllable
(
reading
,
meter
,
position_number
)
elif
type
==
'
element
'
:
return
cls
.
after_element
(
reading
,
meter
,
position_number
)
else
:
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment