Skip to content

Commit

Permalink
Implemented t-hspace element (proycon/folia#88)
Browse files Browse the repository at this point in the history
  • Loading branch information
proycon committed Mar 24, 2021
1 parent 3b093f6 commit 9e1f5a7
Showing 1 changed file with 34 additions and 2 deletions.
36 changes: 34 additions & 2 deletions folia/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,7 +120,7 @@ class Attrib:
#foliaspec:annotationtype
#Defines all annotation types (as part of the AnnotationType enumeration)
class AnnotationType:
TEXT, TOKEN, DIVISION, PARAGRAPH, HEAD, LIST, FIGURE, WHITESPACE, LINEBREAK, SENTENCE, POS, LEMMA, DOMAIN, SENSE, SYNTAX, CHUNKING, ENTITY, CORRECTION, ERRORDETECTION, PHON, SUBJECTIVITY, MORPHOLOGICAL, EVENT, DEPENDENCY, TIMESEGMENT, GAP, QUOTE, NOTE, REFERENCE, RELATION, SPANRELATION, COREFERENCE, SEMROLE, METRIC, LANG, STRING, TABLE, STYLE, PART, UTTERANCE, ENTRY, TERM, DEFINITION, EXAMPLE, PHONOLOGICAL, PREDICATE, OBSERVATION, SENTIMENT, STATEMENT, ALTERNATIVE, RAWCONTENT, COMMENT, DESCRIPTION, HYPHENATION, HIDDENTOKEN, MODALITY, EXTERNAL = range(57)
TEXT, TOKEN, DIVISION, PARAGRAPH, HEAD, LIST, FIGURE, WHITESPACE, LINEBREAK, SENTENCE, POS, LEMMA, DOMAIN, SENSE, SYNTAX, CHUNKING, ENTITY, CORRECTION, ERRORDETECTION, PHON, SUBJECTIVITY, MORPHOLOGICAL, EVENT, DEPENDENCY, TIMESEGMENT, GAP, QUOTE, NOTE, REFERENCE, RELATION, SPANRELATION, COREFERENCE, SEMROLE, METRIC, LANG, STRING, TABLE, STYLE, PART, UTTERANCE, ENTRY, TERM, DEFINITION, EXAMPLE, PHONOLOGICAL, PREDICATE, OBSERVATION, SENTIMENT, STATEMENT, ALTERNATIVE, RAWCONTENT, COMMENT, DESCRIPTION, HYPHENATION, HIDDENTOKEN, MODALITY, EXTERNAL, HSPACE = range(58)



Expand Down Expand Up @@ -4284,6 +4284,25 @@ class TextMarkupError(AbstractTextMarkup):
class TextMarkupStyle(AbstractTextMarkup):
"""Markup element to style text content (:class:`TextContent`), e.g. make text bold, italics, underlined, coloured, etc.."""

class TextMarkupWhitespace(AbstractTextMarkup):
"""Whitespace element, signals a vertical whitespace"""

def text(self, cls='current', retaintokenisation=False, previousdelimiter="", strict=False, correctionhandling=None, normalize_spaces=False, hidden=False):
if normalize_spaces:
return " "
else:
return previousdelimiter.strip(' ') + "\n\n"

class TextMarkupHSpace(AbstractTextMarkup):
"""Whitespace element, signals a horizontal whitespace"""

def text(self, cls='current', retaintokenisation=False, previousdelimiter="", strict=False, correctionhandling=None, normalize_spaces=False, hidden=False):
if normalize_spaces:
return " "
else:
return previousdelimiter.strip(' ') + " "


class AbstractContentAnnotation(AbstractElement):
"""Abstract element for content annotation (TextContent and PhonContent)"""
pass
Expand Down Expand Up @@ -4914,6 +4933,7 @@ def text(self, cls='current', retaintokenisation=False, previousdelimiter="", st
return previousdelimiter.strip(' ') + "\n\n"



class Word(AbstractStructureElement, AbstractWord, AllowCorrections):
"""Word (aka token) element. Holds a word/token and all its related token annotations."""

Expand Down Expand Up @@ -9216,7 +9236,7 @@ def validate(filename,schema=None,deep=False):
#================================= FOLIA SPECIFICATION ==========================================================

#foliaspec:header
#This file was last updated according to the FoLiA specification for version 2.5.0 on 2021-03-12 14:23:09, using foliaspec.py
#This file was last updated according to the FoLiA specification for version 2.5.0 on 2021-03-24 21:06:56, using foliaspec.py
#Code blocks after a foliaspec comment (until the next newline) are automatically generated. **DO NOT EDIT THOSE** and **DO NOT REMOVE ANY FOLIASPEC COMMENTS** !!!

#foliaspec:structurescope:STRUCTURESCOPE
Expand Down Expand Up @@ -9278,6 +9298,7 @@ def validate(filename,schema=None,deep=False):
AnnotationType.TABLE: "table" ,
AnnotationType.TERM: "term" ,
AnnotationType.TEXT: "t" ,
AnnotationType.HSPACE: "t-hspace" ,
AnnotationType.STYLE: "t-style" ,
AnnotationType.TIMESEGMENT: "timesegment" ,
AnnotationType.UTTERANCE: "utt" ,
Expand Down Expand Up @@ -9379,9 +9400,11 @@ def validate(filename,schema=None,deep=False):
"t-correction": TextMarkupCorrection,
"t-error": TextMarkupError,
"t-gap": TextMarkupGap,
"t-hspace": TextMarkupHSpace,
"t-ref": TextMarkupReference,
"t-str": TextMarkupString,
"t-style": TextMarkupStyle,
"t-whitespace": TextMarkupWhitespace,
"timesegment": TimeSegment,
"timing": TimingLayer,
"utt": Utterance,
Expand Down Expand Up @@ -10084,6 +10107,10 @@ def validate(filename,schema=None,deep=False):
TextMarkupGap.ANNOTATIONTYPE = AnnotationType.GAP
TextMarkupGap.PRIMARYELEMENT = False
TextMarkupGap.XMLTAG = "t-gap"
#------ TextMarkupHSpace -------
TextMarkupHSpace.ANNOTATIONTYPE = AnnotationType.HSPACE
TextMarkupHSpace.TEXTDELIMITER = " "
TextMarkupHSpace.XMLTAG = "t-hspace"
#------ TextMarkupReference -------
TextMarkupReference.ANNOTATIONTYPE = AnnotationType.REFERENCE
TextMarkupReference.PRIMARYELEMENT = False
Expand All @@ -10097,6 +10124,11 @@ def validate(filename,schema=None,deep=False):
TextMarkupStyle.ANNOTATIONTYPE = AnnotationType.STYLE
TextMarkupStyle.PRIMARYELEMENT = True
TextMarkupStyle.XMLTAG = "t-style"
#------ TextMarkupWhitespace -------
TextMarkupWhitespace.ANNOTATIONTYPE = AnnotationType.WHITESPACE
TextMarkupWhitespace.PRIMARYELEMENT = False
TextMarkupWhitespace.TEXTDELIMITER = ""
TextMarkupWhitespace.XMLTAG = "t-whitespace"
#------ TimeFeature -------
TimeFeature.SUBSET = "time"
TimeFeature.XMLTAG = None
Expand Down

0 comments on commit 9e1f5a7

Please sign in to comment.