From 987cda05a5ffe05c04156f808fbe4cee37a3aef2 Mon Sep 17 00:00:00 2001 From: ChiaraDipi Date: Tue, 13 Oct 2020 18:11:06 +0200 Subject: [PATCH 1/4] Add WordParser --- src/app/models/evt-models.ts | 4 ++++ src/app/services/xml-parsers/basic-parsers.ts | 18 +++++++++++++++++- src/app/services/xml-parsers/index.ts | 5 +++-- 3 files changed, 24 insertions(+), 3 deletions(-) diff --git a/src/app/models/evt-models.ts b/src/app/models/evt-models.ts index dd041e2ba..29ca9260f 100644 --- a/src/app/models/evt-models.ts +++ b/src/app/models/evt-models.ts @@ -318,3 +318,7 @@ export type SicType = 'crux'; // sic types supported in specific ways export class Sic extends GenericElement { sicType?: SicType | string; } + +export class Word extends GenericElement { + lemma?: string; +} diff --git a/src/app/services/xml-parsers/basic-parsers.ts b/src/app/services/xml-parsers/basic-parsers.ts index fe920fa9d..b991f2a4a 100644 --- a/src/app/services/xml-parsers/basic-parsers.ts +++ b/src/app/services/xml-parsers/basic-parsers.ts @@ -1,7 +1,7 @@ import { AttributesMap } from 'ng-dynamic-component'; import { Addition, Attributes, Damage, Gap, GenericElement, Lb, Note, NoteLayout, - Paragraph, PlacementType, Supplied, Text, Verse, XMLElement, + Paragraph, PlacementType, Supplied, Text, Verse, Word, XMLElement, } from '../../models/evt-models'; import { isNestedInElem, xpath } from '../../utils/dom-utils'; import { replaceMultispaces } from '../../utils/xml-utils'; @@ -223,3 +223,19 @@ export class AdditionParser extends EmptyParser implements Parser { }; } } + +export class WordParser extends EmptyParser implements Parser { + attributeParser = createParser(AttributeParser, this.genericParse); + parse(xml: XMLElement): Word { + const attributes = this.attributeParser.parse(xml); + const { lemma } = attributes; + + return { + type: Word, + lemma, + class: getClass(xml), + content: parseChildren(xml, this.genericParse), + attributes: this.attributeParser.parse(xml), + }; + } +} diff --git a/src/app/services/xml-parsers/index.ts b/src/app/services/xml-parsers/index.ts index d37cf6d99..b29c7e366 100644 --- a/src/app/services/xml-parsers/index.ts +++ b/src/app/services/xml-parsers/index.ts @@ -2,7 +2,7 @@ import { Comment, GenericElement, HTML, XMLElement } from '../../models/evt-mode import { AppParser, RdgParser } from './app-parser'; import { AdditionParser, DamageParser, ElementParser, GapParser, LBParser, NoteParser, ParagraphParser, - PtrParser, SuppliedParser, TextParser, VerseParser, + PtrParser, SuppliedParser, TextParser, VerseParser, WordParser, } from './basic-parsers'; import { CharParser, GlyphParser, GParser } from './character-declarations-parser'; import { ChoiceParser } from './choice-parser'; @@ -16,7 +16,7 @@ import { createParser, Parser, ParseResult } from './parser-models'; type SupportedTagNames = 'add' | 'app' | 'char' | 'choice' | 'damage' | 'event' | 'g' | 'gap' | 'geogname' | 'glyph' | 'graphic' | 'l' | 'lb' | 'lem' | 'note' | 'orgname' | 'p' | 'persname' | 'placename' | 'ptr' | 'person' | 'personGrp' | 'place' | 'org' | 'rdg' | 'sic' | 'surface' | - 'supplied' | 'surplus' | 'zone'; + 'supplied' | 'surplus' | 'w' | 'zone'; export const parseF: { [T in SupportedTagNames]: Parser } = { add: createParser(AdditionParser, parse), @@ -49,6 +49,7 @@ export const parseF: { [T in SupportedTagNames]: Parser } = { surface: createParser(SurfaceParser, parse), supplied: createParser(SuppliedParser, parse), surplus: createParser(SurplusParser, parse), + w: createParser(WordParser, parse), zone: createParser(ZoneParser, parse), }; From 06f6233aa72b39d4c729354e935ea794a0c9547a Mon Sep 17 00:00:00 2001 From: ChiaraDipi Date: Tue, 13 Oct 2020 18:12:12 +0200 Subject: [PATCH 2/4] Add WordComponent --- src/app/app.module.ts | 2 ++ src/app/components/word/word.component.html | 5 ++++ src/app/components/word/word.component.scss | 0 .../components/word/word.component.spec.ts | 25 +++++++++++++++++++ src/app/components/word/word.component.ts | 17 +++++++++++++ 5 files changed, 49 insertions(+) create mode 100644 src/app/components/word/word.component.html create mode 100644 src/app/components/word/word.component.scss create mode 100644 src/app/components/word/word.component.spec.ts create mode 100644 src/app/components/word/word.component.ts diff --git a/src/app/app.module.ts b/src/app/app.module.ts index 752504f04..bd734523d 100644 --- a/src/app/app.module.ts +++ b/src/app/app.module.ts @@ -53,6 +53,7 @@ import { SuppliedComponent } from './components/supplied/supplied.component'; import { SurplusComponent } from './components/surplus/surplus.component'; import { TextComponent } from './components/text/text.component'; import { VerseComponent } from './components/verse/verse.component'; +import { WordComponent } from './components/word/word.component'; import { EditorialConventionLayoutDirective } from './directives/editorial-convention-layout.directive'; import { HighlightDirective } from './directives/highlight.directive'; import { HtmlAttributesDirective } from './directives/html-attributes.directive'; @@ -148,6 +149,7 @@ export function initializeApp(appConfig: AppConfig) { VerseComponent, VersionPanelComponent, WitnessPanelComponent, + WordComponent, XmlBeautifyPipe, ], imports: [ diff --git a/src/app/components/word/word.component.html b/src/app/components/word/word.component.html new file mode 100644 index 000000000..3e1ba4dcf --- /dev/null +++ b/src/app/components/word/word.component.html @@ -0,0 +1,5 @@ + + + + \ No newline at end of file diff --git a/src/app/components/word/word.component.scss b/src/app/components/word/word.component.scss new file mode 100644 index 000000000..e69de29bb diff --git a/src/app/components/word/word.component.spec.ts b/src/app/components/word/word.component.spec.ts new file mode 100644 index 000000000..db0ba4d0f --- /dev/null +++ b/src/app/components/word/word.component.spec.ts @@ -0,0 +1,25 @@ +import { async, ComponentFixture, TestBed } from '@angular/core/testing'; + +import { WordComponent } from './word.component'; + +describe('WordComponent', () => { + let component: WordComponent; + let fixture: ComponentFixture; + + beforeEach(async(() => { + TestBed.configureTestingModule({ + declarations: [ WordComponent ], + }) + .compileComponents(); + })); + + beforeEach(() => { + fixture = TestBed.createComponent(WordComponent); + component = fixture.componentInstance; + fixture.detectChanges(); + }); + + it('should create', () => { + expect(component).toBeTruthy(); + }); +}); diff --git a/src/app/components/word/word.component.ts b/src/app/components/word/word.component.ts new file mode 100644 index 000000000..36149facf --- /dev/null +++ b/src/app/components/word/word.component.ts @@ -0,0 +1,17 @@ +import { Component, Input } from '@angular/core'; + +import { Word } from '../../models/evt-models'; +import { register } from '../../services/component-register.service'; +import { EditionlevelSusceptible, Highlightable } from '../components-mixins'; + +export interface WordComponent extends EditionlevelSusceptible, Highlightable { } + +@Component({ + selector: 'evt-word', + templateUrl: './word.component.html', + styleUrls: ['./word.component.scss'], +}) +@register(Word) +export class WordComponent { + @Input() data: Word; +} From bb7557ec243b80e96f5a4f5d924558d7e0783529 Mon Sep 17 00:00:00 2001 From: ChiaraDipi Date: Tue, 13 Oct 2020 18:13:07 +0200 Subject: [PATCH 3/4] Add normalization when word broken between two lines --- src/app/components/word/word.component.html | 2 +- src/app/components/word/word.component.ts | 19 ++++++++++++++++++- 2 files changed, 19 insertions(+), 2 deletions(-) diff --git a/src/app/components/word/word.component.html b/src/app/components/word/word.component.html index 3e1ba4dcf..dbaeaf3c5 100644 --- a/src/app/components/word/word.component.html +++ b/src/app/components/word/word.component.html @@ -1,5 +1,5 @@ - \ No newline at end of file diff --git a/src/app/components/word/word.component.ts b/src/app/components/word/word.component.ts index 36149facf..b4b809910 100644 --- a/src/app/components/word/word.component.ts +++ b/src/app/components/word/word.component.ts @@ -1,6 +1,6 @@ import { Component, Input } from '@angular/core'; -import { Word } from '../../models/evt-models'; +import { GenericElement, Lb, Word } from '../../models/evt-models'; import { register } from '../../services/component-register.service'; import { EditionlevelSusceptible, Highlightable } from '../components-mixins'; @@ -14,4 +14,21 @@ export interface WordComponent extends EditionlevelSusceptible, Highlightable { @register(Word) export class WordComponent { @Input() data: Word; + + get word() { + if (this.editionLevel === 'diplomatic') { + return this.data.content; + } + + const lbIndex = this.data.content.findIndex((el: GenericElement) => el.type === Lb); + if (lbIndex >= 0) { + const wordContent = [...this.data.content]; + wordContent.splice(lbIndex, 1); + wordContent.push(this.data.content[lbIndex]); + + return wordContent; + } + + return this.data.content; + } } From cd526182cbabe1f5cf40df525b332406bd623757 Mon Sep 17 00:00:00 2001 From: ChiaraDipi Date: Sat, 17 Oct 2020 10:13:57 +0200 Subject: [PATCH 4/4] Update change log --- CHANGELOG.md | 2 ++ 1 file changed, 2 insertions(+) diff --git a/CHANGELOG.md b/CHANGELOG.md index 9f1e4ad76..08c10f0da 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -10,6 +10,8 @@ and this project adheres to [Semantic Versioning](https://semver.org/spec/v2.0.0 - Updated to Angular 9 ### Added +- Multiple line words normalization in interpretative and critical edition +- Word visualization - Incurable corruptions visualization - Verses/Prose toggler - Addition vizualization