From 8773f6b58f127057a1d12bb03a0ae386e5cebdbe Mon Sep 17 00:00:00 2001 From: Tim Van Baak Date: Tue, 23 Apr 2019 23:56:59 -0700 Subject: [PATCH] Add title-turn uniqueness check --- lexipython/article.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lexipython/article.py b/lexipython/article.py index 2a6da84..4490809 100644 --- a/lexipython/article.py +++ b/lexipython/article.py @@ -172,6 +172,13 @@ class LexiconArticle: Fills out fields on articles that require other articles for context. Creates phantom articles. """ + # Preliminary assertion that title/turn is unique + keys = set() + for article in lexicon_articles: + if (article.title, article.turn) in keys: + raise ValueError("Found two articles with title '{}' and turn '{}'".format( + article.title, article.turn)) + keys.add((article.title, article.turn)) # Sort out which articles are addendums and which titles are phantoms written_titles = set() cited_titles = set()