Skip to content

Fix Stanza - #494

Merged
argosopentech merged 1 commit into
argosopentech:masterfrom
yudelevi:fix-stanza-split
Sep 14, 2025
Merged

Fix Stanza#494
argosopentech merged 1 commit into
argosopentech:masterfrom
yudelevi:fix-stanza-split

Conversation

@yudelevi

Copy link
Copy Markdown
Contributor

More context: https://community.libretranslate.com/t/sentence-boundary-detection-for-machine-translation/606/49

  • Reset tokenize_pretokenized to False
  • Look if MWT is available for language to avoid flood of warnings if it needs to be added
  • Set up stanza.DownloadMethod.REUSE_RESOURCES to avoid downloading resources.json for every language
dyudelevich@ai-01:~/argos-translate/tests$ export ARGOS_DEBUG=1
dyudelevich@ai-01:~/argos-translate/tests$ TEXT="HMS Queen Mary was the last battlecruiser built by the Royal Navy before the First World War. The sole member of her class, Queen Mary was completed in 1913. She never left the North Sea once the war started, participating in the Battle of Heligoland Bight in 1914 as part of the Grand Fleet. Queen Mary unsuccessfully attempted to intercept a German force that bombarded the North Sea coast of England that December. She was refitting in early 1915 and missed the Battle of Dogger Bank in January. Queen Mary was sunk in the largest fleet action of the war, the Battle of Jutland, in mid-1916. Twice hit by the German battlecruiser Derfflinger during the early part of the battle, her magazines exploded, sinking her. The wreck was discovered in 1991 and rests in pieces on the floor of the North Sea. Her wreck is designated as a protected place under the Protection of Military Remains Act 1986 as it is the grave of 1,266 men."
dyudelevich@ai-01:~/argos-translate/tests$ argos-translate -f en -t es "$TEXT"
('Looking for cached Spacy xx_sent_ud_sm.',)
('get_installed_languages',)
("Stanza pipeline failed for language 'bn': 'packages'",)
('Falling back to SpaCy sentence boundary detection for bn',)
2025-09-10 04:39:43 WARNING: Unsupported language: ms  If trying to add a new language, consider using allow_unknown_language=True
("Stanza pipeline failed for language 'ms': No processors to load for language ms.  Language ms is currently unsupported",)
('Falling back to SpaCy sentence boundary detection for ms',)
2025-09-10 04:39:45 WARNING: Unsupported language: eo  If trying to add a new language, consider using allow_unknown_language=True
("Stanza pipeline failed for language 'eo': No processors to load for language eo.  Language eo is currently unsupported",)
('Falling back to SpaCy sentence boundary detection for eo',)
2025-09-10 04:39:46 WARNING: Unsupported language: tl  If trying to add a new language, consider using allow_unknown_language=True
("Stanza pipeline failed for language 'tl': No processors to load for language tl.  Language tl is currently unsupported",)
('Falling back to SpaCy sentence boundary detection for tl',)
2025-09-10 04:39:48 WARNING: Unsupported language: az  If trying to add a new language, consider using allow_unknown_language=True
("Stanza pipeline failed for language 'az': No processors to load for language az.  Language az is currently unsupported",)
('Falling back to SpaCy sentence boundary detection for az',)
('paragraphs:', ['HMS Queen Mary was the last battlecruiser built by the Royal Navy before the First World War. The sole member of her class, Queen Mary was completed in 1913. She never left the North Sea once the war started, participating in the Battle of Heligoland Bight in 1914 as part of the Grand Fleet. Queen Mary unsuccessfully attempted to intercept a German force that bombarded the North Sea coast of England that December. She was refitting in early 1915 and missed the Battle of Dogger Bank in January. Queen Mary was sunk in the largest fleet action of the war, the Battle of Jutland, in mid-1916. Twice hit by the German battlecruiser Derfflinger during the early part of the battle, her magazines exploded, sinking her. The wreck was discovered in 1991 and rests in pieces on the floor of the North Sea. Her wreck is designated as a protected place under the Protection of Military Remains Act 1986 as it is the grave of 1,266 men.'])
('apply_packaged_translation', 'HMS Queen Mary was the last battlecruiser built by the Royal Navy before the First World War. The sole member of her class, Queen Mary was completed in 1913. She never left the North Sea once the war started, participating in the Battle of Heligoland Bight in 1914 as part of the Grand Fleet. Queen Mary unsuccessfully attempted to intercept a German force that bombarded the North Sea coast of England that December. She was refitting in early 1915 and missed the Battle of Dogger Bank in January. Queen Mary was sunk in the largest fleet action of the war, the Battle of Jutland, in mid-1916. Twice hit by the German battlecruiser Derfflinger during the early part of the battle, her magazines exploded, sinking her. The wreck was discovered in 1991 and rests in pieces on the floor of the North Sea. Her wreck is designated as a protected place under the Protection of Military Remains Act 1986 as it is the grave of 1,266 men.')
('sentences', ['HMS Queen Mary was the last battlecruiser built by the Royal Navy before the First World War.', 'The sole member of her class, Queen Mary was completed in 1913.', 'She never left the North Sea once the war started, participating in the Battle of Heligoland Bight in 1914 as part of the Grand Fleet.', 'Queen Mary unsuccessfully attempted to intercept a German force that bombarded the North Sea coast of England that December.', 'She was refitting in early 1915 and missed the Battle of Dogger Bank in January.', 'Queen Mary was sunk in the largest fleet action of the war, the Battle of Jutland, in mid-1916.', 'Twice hit by the German battlecruiser Derfflinger during the early part of the battle, her magazines exploded, sinking her.', 'The wreck was discovered in 1991 and rests in pieces on the floor of the North Sea.', 'Her wreck is designated as a protected place under the Protection of Military Remains Act 1986 as it is the grave of 1,266 men.'])
('tokenized', [['▁H', 'MS', '▁Queen', '▁Mary', '▁was', '▁the', '▁last', '▁battle', 'cru', 'is', 'er', '▁built', '▁by', '▁the', '▁Royal', '▁Navy', '▁before', '▁the', '▁First', '▁World', '▁War', '.'], ['▁The', '▁sole', '▁member', '▁of', '▁her', '▁class', ',', '▁Queen', '▁Mary', '▁was', '▁completed', '▁in', '▁19', '13', '.'], ['▁She', '▁never', '▁left', '▁the', '▁North', '▁Sea', '▁once', '▁the', '▁war', '▁started', ',', '▁participating', '▁in', '▁the', '▁Battle', '▁of', '▁He', 'lig', 'o', 'land', '▁B', 'ight', '▁in', '▁19', '14', '▁as', '▁part', '▁of', '▁the', '▁Grand', '▁Fle', 'et', '.'], ['▁Queen', '▁Mary', '▁un', 's', 'uc', 'ces', 's', 'fully', '▁attempted', '▁to', '▁intercept', '▁a', '▁German', '▁force', '▁that', '▁bombard', 'ed', '▁the', '▁North', '▁Sea', '▁coast', '▁of', '▁England', '▁that', '▁December', '.'], ['▁She', '▁was', '▁re', 'fit', 'ting', '▁in', '▁early', '▁19', '15', '▁and', '▁missed', '▁the', '▁Battle', '▁of', '▁Do', 'gger', '▁Bank', '▁in', '▁January', '.'], ['▁Queen', '▁Mary', '▁was', '▁su', 'nk', '▁in', '▁the', '▁largest', '▁fleet', '▁action', '▁of', '▁the', '▁war', ',', '▁the', '▁Battle', '▁of', '▁Ju', 't', 'land', ',', '▁in', '▁mid', '-19', '16', '.'], ['▁T', 'wi', 'ce', '▁hit', '▁by', '▁the', '▁German', '▁battle', 'cru', 'is', 'er', '▁Der', 'ff', 'ling', 'er', '▁during', '▁the', '▁early', '▁part', '▁of', '▁the', '▁battle', ',', '▁her', '▁magazine', 's', '▁explode', 'd', ',', '▁sin', 'king', '▁her', '.'], ['▁The', '▁wreck', '▁was', '▁discovered', '▁in', '▁1991', '▁and', '▁rest', 's', '▁in', '▁pieces', '▁on', '▁the', '▁floor', '▁of', '▁the', '▁North', '▁Sea', '.'], ['▁Her', '▁wreck', '▁is', '▁designated', '▁as', '▁a', '▁protected', '▁place', '▁under', '▁the', '▁Protection', '▁of', '▁Military', '▁Re', 'main', 's', '▁Act', '▁1986', '▁as', '▁it', '▁is', '▁the', '▁grave', '▁of', '▁1,2', '66', '▁men', '.']])
('translated_batches', [TranslationResult(hypotheses=[['▁H', 'MS', '▁Queen', '▁Mary', '▁fue', '▁el', '▁último', '▁crucero', '▁de', '▁batalla', '▁construido', '▁por', '▁la', '▁Marina', '▁Real', '▁antes', '▁de', '▁la', '▁Primera', '▁Guerra', '▁Mundial', '.']], scores=[-4.84660005569458], attention=[], logits=[]), TranslationResult(hypotheses=[['▁El', '▁único', '▁miembro', '▁de', '▁su', '▁clase', ',', '▁la', '▁reina', '▁María', '▁fue', '▁termina', 'da', '▁en', '▁19', '13', '.']], scores=[-2.966782331466675], attention=[], logits=[]), TranslationResult(hypotheses=[['▁Nunca', '▁abandon', 'ó', '▁el', '▁Mar', '▁del', '▁Norte', '▁una', '▁vez', '▁que', '▁comenzó', '▁la', '▁guerra', ',', '▁participando', '▁en', '▁la', '▁batalla', '▁de', '▁He', 'lig', 'o', 'land', '▁B', 'ight', '▁en', '▁19', '14', '▁como', '▁parte', '▁de', '▁la', '▁Gran', '▁Flo', 'ta', '.']], scores=[-4.191306114196777], attention=[], logits=[]), TranslationResult(hypotheses=[['▁La', '▁reina', '▁María', '▁trató', '▁sin', '▁éxito', '▁de', '▁intercept', 'ar', '▁una', '▁fuerza', '▁alemana', '▁que', '▁bombard', 'e', 'ó', '▁la', '▁costa', '▁del', '▁Mar', '▁del', '▁Norte', '▁de', '▁Inglaterra', '▁en', '▁diciembre', '.']], scores=[-4.29277229309082], attention=[], logits=[]), TranslationResult(hypotheses=[['▁Se', '▁rea', 'just', 'ó', '▁a', '▁principios', '▁de', '▁19', '15', '▁y', '▁perdió', '▁la', '▁Bat', 'al', 'la', '▁del', '▁Banco', '▁Do', 'gger', '▁en', '▁enero', '.']], scores=[-4.720661163330078], attention=[], logits=[]), TranslationResult(hypotheses=[['▁La', '▁reina', '▁María', '▁fue', '▁hu', 'ndida', '▁en', '▁la', '▁mayor', '▁acción', '▁de', '▁la', '▁flota', '▁de', '▁la', '▁guerra', ',', '▁la', '▁batalla', '▁de', '▁Ju', 't', 'land', ',', '▁a', '▁mediados', '▁de', '▁19', '16', '.']], scores=[-4.347515106201172], attention=[], logits=[]), TranslationResult(hypotheses=[['▁Dos', '▁veces', '▁golpe', 'ada', '▁por', '▁el', '▁cazador', '▁de', '▁batalla', '▁alemán', '▁Der', 'ff', 'ling', 'er', '▁durante', '▁la', '▁parte', '▁temprana', '▁de', '▁la', '▁batalla', ',', '▁sus', '▁revista', 's', '▁explotar', 'on', ',', '▁hu', 'nd', 'iendo', '▁ella', '.']], scores=[-6.525444507598877], attention=[], logits=[]), TranslationResult(hypotheses=[['▁El', '▁na', 'u', 'fra', 'gio', '▁fue', '▁descubierto', '▁en', '▁1991', '▁y', '▁descansa', '▁en', '▁pedazo', 's', '▁en', '▁el', '▁suelo', '▁del', '▁Mar', '▁del', '▁Norte', '.']], scores=[-3.2046566009521484], attention=[], logits=[]), TranslationResult(hypotheses=[['▁Su', '▁na', 'u', 'fra', 'gio', '▁es', '▁designado', '▁como', '▁lugar', '▁protegido', '▁bajo', '▁la', '▁Ley', '▁de', '▁protección', '▁de', '▁restos', '▁militares', '▁de', '▁1986', ',', '▁ya', '▁que', '▁es', '▁la', '▁tumba', '▁de', '▁1.2', '66', '▁hombres', '.']], scores=[-5.136685848236084], attention=[], logits=[])])
('value_hypotheses:', [('HMS Queen Mary fue el último crucero de batalla construido por la Marina Real antes de la Primera Guerra Mundial. El único miembro de su clase, la reina María fue terminada en 1913. Nunca abandonó el Mar del Norte una vez que comenzó la guerra, participando en la batalla de Heligoland Bight en 1914 como parte de la Gran Flota. La reina María trató sin éxito de interceptar una fuerza alemana que bombardeó la costa del Mar del Norte de Inglaterra en diciembre. Se reajustó a principios de 1915 y perdió la Batalla del Banco Dogger en enero. La reina María fue hundida en la mayor acción de la flota de la guerra, la batalla de Jutland, a mediados de 1916. Dos veces golpeada por el cazador de batalla alemán Derfflinger durante la parte temprana de la batalla, sus revistas explotaron, hundiendo ella. El naufragio fue descubierto en 1991 y descansa en pedazos en el suelo del Mar del Norte. Su naufragio es designado como lugar protegido bajo la Ley de protección de restos militares de 1986, ya que es la tumba de 1.266 hombres.', -40.23242402076721)])
('translated_paragraphs:', [[('HMS Queen Mary fue el último crucero de batalla construido por la Marina Real antes de la Primera Guerra Mundial. El único miembro de su clase, la reina María fue terminada en 1913. Nunca abandonó el Mar del Norte una vez que comenzó la guerra, participando en la batalla de Heligoland Bight en 1914 como parte de la Gran Flota. La reina María trató sin éxito de interceptar una fuerza alemana que bombardeó la costa del Mar del Norte de Inglaterra en diciembre. Se reajustó a principios de 1915 y perdió la Batalla del Banco Dogger en enero. La reina María fue hundida en la mayor acción de la flota de la guerra, la batalla de Jutland, a mediados de 1916. Dos veces golpeada por el cazador de batalla alemán Derfflinger durante la parte temprana de la batalla, sus revistas explotaron, hundiendo ella. El naufragio fue descubierto en 1991 y descansa en pedazos en el suelo del Mar del Norte. Su naufragio es designado como lugar protegido bajo la Ley de protección de restos militares de 1986, ya que es la tumba de 1.266 hombres.', -40.23242402076721)]])
('hypotheses_to_return:', [('HMS Queen Mary fue el último crucero de batalla construido por la Marina Real antes de la Primera Guerra Mundial. El único miembro de su clase, la reina María fue terminada en 1913. Nunca abandonó el Mar del Norte una vez que comenzó la guerra, participando en la batalla de Heligoland Bight en 1914 como parte de la Gran Flota. La reina María trató sin éxito de interceptar una fuerza alemana que bombardeó la costa del Mar del Norte de Inglaterra en diciembre. Se reajustó a principios de 1915 y perdió la Batalla del Banco Dogger en enero. La reina María fue hundida en la mayor acción de la flota de la guerra, la batalla de Jutland, a mediados de 1916. Dos veces golpeada por el cazador de batalla alemán Derfflinger durante la parte temprana de la batalla, sus revistas explotaron, hundiendo ella. El naufragio fue descubierto en 1991 y descansa en pedazos en el suelo del Mar del Norte. Su naufragio es designado como lugar protegido bajo la Ley de protección de restos militares de 1986, ya que es la tumba de 1.266 hombres.', -40.23242402076721)])
HMS Queen Mary fue el último crucero de batalla construido por la Marina Real antes de la Primera Guerra Mundial. El único miembro de su clase, la reina María fue terminada en 1913. Nunca abandonó el Mar del Norte una vez que comenzó la guerra, participando en la batalla de Heligoland Bight en 1914 como parte de la Gran Flota. La reina María trató sin éxito de interceptar una fuerza alemana que bombardeó la costa del Mar del Norte de Inglaterra en diciembre. Se reajustó a principios de 1915 y perdió la Batalla del Banco Dogger en enero. La reina María fue hundida en la mayor acción de la flota de la guerra, la batalla de Jutland, a mediados de 1916. Dos veces golpeada por el cazador de batalla alemán Derfflinger durante la parte temprana de la batalla, sus revistas explotaron, hundiendo ella. El naufragio fue descubierto en 1991 y descansa en pedazos en el suelo del Mar del Norte. Su naufragio es designado como lugar protegido bajo la Ley de protección de restos militares de 1986, ya que es la tumba de 1.266 hombres.

- look if mwt is avail for languge to avoid warning if it needs to be added
@argosopentech
argosopentech merged commit 238b0ce into argosopentech:master Sep 14, 2025
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants