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
92d36906
Commit
92d36906
authored
6 years ago
by
Simon Will
Browse files
Options
Downloads
Patches
Plain Diff
Begin implementing meters
parent
42d41352
No related branches found
No related tags found
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
allzweckmesser/meters.py
+59
-1
59 additions, 1 deletion
allzweckmesser/meters.py
with
59 additions
and
1 deletion
allzweckmesser/meters.py
+
59
−
1
View file @
92d36906
#!/usr/bin/env python3
# -*- coding: utf-8 -*-
ALL_METERS
=
[]
import
re
from
.model
import
Reading
def
caesurae_together
(
positions
,
reward
):
def
get_reward
(
meter
:
Meter
,
reading
:
Reading
):
# TODO: Check if caesurae occur.
return
reward
return
get_reward
def
bridge
(
position
,
reward
):
def
get_reward
(
meter
:
Meter
,
reading
:
Reading
):
# TODO: Check if bridge occurs.
return
reward
return
get_reward
class
Meter
:
def
__init__
(
self
,
name
:
str
,
schema
:
str
,
conditions
:
list
=
None
,
short_name
:
str
=
None
):
self
.
name
=
name
self
.
schema
=
schema
self
.
conditions
=
([
cond
.
__get__
(
self
)
for
cond
in
conditions
]
if
conditions
else
[])
self
.
short_name
=
short_name
def
match_reading
(
self
,
reading
:
Reading
):
return
re
.
match
(
self
.
schema
,
reading
.
get_syllable_schema
())
def
get_rewards
(
self
,
reading
:
Reading
):
return
sum
(
cond
(
reading
)
for
cond
in
self
.
conditions
)
ALL_METERS
=
[
Meter
(
'
Catalectic Dactylic Hexameter
'
,
r
'
(–)(⏑⏑|–)(–)(⏑⏑|–)(–)(⏑⏑|–)(–)(⏑⏑|–)(–)(⏑⏑|–)(⏑|–)
'
,
phenomena
=
{
caesurae_together
([(
'
mora
'
,
6
,
'
Trithemimeral
'
),
(
'
mora
'
,
14
,
'
Hephthemimeral
'
)],
2
),
caesurae_together
([(
'
mora
'
,
10
,
'
Penthemimeral
'
)],
1
),
caesurae_together
([(
'
mora
'
,
16
,
'
Bucolic Diaeresis
'
)],
1
),
bridge
((
'
mora
'
,
15
,
'
Hermann’s Bridge
'
),
1
)
},
short_name
=
'
6da‸
'
),
Meter
(
'
Iambic Trimeter
'
,
r
'
(⏑|⏑⏑|–)(⏑⏑|–)(⏑)(⏑⏑|–)(⏑|⏑⏑|–)(⏑⏑|–)(⏑)(⏑⏑|–)(⏑|⏑⏑|–)(⏑⏑|–)(⏑)(⏑|–)
'
,
phenomena
=
{
caesurae_together
([(
'
element
'
,
4
,
'
After fourth element
'
)],
1
),
caesurae_together
([(
'
element
'
,
8
,
'
After eighth element
'
)],
1
),
},
short_name
=
'
3ia
'
),
]
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