Esempio n. 1
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.ReferenceType != ReferenceType.InternetDocument)
            {
                return(false);
            }

            var onlineAddress = citation.Reference.OnlineAddress;

            if (string.IsNullOrEmpty(onlineAddress))
            {
                return(false);
            }

            //note: if you do not specify the whole word, but rather its first characters, do NOT use * as a wildcard, but
            //\\w*, which means "zero or more word characters"
            var wordList = new string[] {
                "wikipedia.org"
            };
            var regEx = new Regex(@"\b(" + string.Join("|", wordList) + @")\b");

            return(regEx.IsMatch(onlineAddress));
        }
Esempio n. 2
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(true);
            }
            if (citation.Reference == null)
            {
                return(true);
            }

            PlaceholderCitation thisCitation = citation as PlaceholderCitation;

            if (thisCitation == null)
            {
                return(true);                                  //only PlaceholderCitations can be part of a caption and can have a predecessor-PlaceholderCitation that can be part of a caption
            }
            //caution: the property thisCitation.PreviousPlaceholderCitation may give wrong results and should currently (C6.7) not be used
            PlaceholderCitation previousCitation = thisCitation.PreviousCitation as PlaceholderCitation;

            if (previousCitation == null)
            {
                return(true);                                      //ditto
            }
            if (previousCitation.IsPartOfCaption)
            {
                return(false);
            }

            return(true);
        }
Esempio n. 3
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            bool activateOnPages      = false;                                  //Seitennummern
            bool activateOnColumns    = false;                                  //Spaltennummern
            bool activateOnParagraphs = true;                                   //Paragraphen
            bool activateOnMargins    = false;                                  //Randnummern
            bool activateOnOthers     = false;                                  //Andere

            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.PageRange == null)
            {
                return(false);
            }

            if
            (
                (activateOnPages && citation.Reference.PageRange.NumberingType == NumberingType.Page) ||
                (activateOnColumns && citation.Reference.PageRange.NumberingType == NumberingType.Column) ||
                (activateOnParagraphs && citation.Reference.PageRange.NumberingType == NumberingType.Paragraph) ||
                (activateOnMargins && citation.Reference.PageRange.NumberingType == NumberingType.Margin) ||
                (activateOnOthers && citation.Reference.PageRange.NumberingType == NumberingType.Other)
            )
            {
                return(true);
            }

            return(false);
        }
Esempio n. 4
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            if (string.IsNullOrEmpty(citation.Reference.YearResolved))
            {
                return(false);
            }

            DateTime result;

            if (!DateTimeInformation.TryParse(citation.Reference.YearResolved, out result))
            {
                return(false);
            }

            if (result.Year > 1800)
            {
                return(false);
            }
            return(true);
        }
Esempio n. 5
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.ReferenceType != ReferenceType.CourtDecision)
            {
                return(false);
            }

            var organizations = citation.Reference.Organizations;

            if (organizations == null || organizations.Count == 0)
            {
                return(false);
            }

            //note: if you do not specify the whole word, but rather its first characters, do NOT use * as a wildcard, but
            //\\w*, which means "zero or more word characters"
            var wordList = new string[] {
                "BVerfG"
            };
            var regEx = new Regex(@"\b(" + string.Join("|", wordList) + @")\b");

            return(organizations.Any(item => regEx.IsMatch(item.LastName) || regEx.IsMatch(item.Abbreviation)));
        }
Esempio n. 6
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }


            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;

            if (placeholderCitation == null)
            {
                return(false);
            }
            if (!placeholderCitation.NoPar)
            {
                return(false);
            }
            if (!placeholderCitation.PersonOnly)
            {
                return(false);
            }

            //all conditions met
            return(true);
        }
Esempio n. 7
0
        //Reference is an indirect quotation
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            PlaceholderCitation placeholderCitation = citation as PlaceholderCitation;

            if (placeholderCitation == null)
            {
                return(false);
            }

            if (placeholderCitation.Entry == null)
            {
                return(false);
            }

            return(placeholderCitation.Entry.QuotationType == QuotationType.IndirectQuotation);
        }
Esempio n. 8
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.ReferenceType != ReferenceType.CourtDecision)
            {
                return(false);
            }

            var field = citation.Reference.SpecificField3;

            //note: if you do not specify the whole word, but rather its first characters, do NOT use * as a wildcard, but
            //\\w*, which means "zero or more word characters"
            var wordList1 = new string[] {
                "Schreiben",
                "Erlass",
                "Verfügung"
            };

            var regEx1 = new Regex(@"\b(" + string.Join("|", wordList1) + @")\b", RegexOptions.IgnoreCase);

            if (regEx1.IsMatch(field))
            {
                return(true);
            }
            return(false);
        }
Esempio n. 9
0
        //Version 1.1 Considers series title of parent reference, if applicable
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            SeriesTitle seriesTitle = null;

            if (citation.Reference.HasCoreField(ReferenceTypeCoreFieldId.SeriesTitle))
            {
                seriesTitle = citation.Reference.SeriesTitle;
            }
            else
            {
                if (citation.Reference.ParentReference != null && citation.Reference.ParentReference.HasCoreField(ReferenceTypeCoreFieldId.SeriesTitle))
                {
                    seriesTitle = citation.Reference.ParentReference.SeriesTitle;
                }
            }

            if (seriesTitle == null)
            {
                return(false);
            }

            return(string.Equals(seriesTitle.Name, "NAME", StringComparison.OrdinalIgnoreCase));
            //return seriesTitle.Name.StartsWith("NAME", StringComparison.OrdinalIgnoreCase);
            //return seriesTitle.Name.EndsWith("NAME", StringComparison.OrdinalIgnoreCase);
        }
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            FootnoteCitation currentFootnoteCitation = citation as FootnoteCitation;

            if (currentFootnoteCitation == null)
            {
                return(false);
            }

            FootnoteCitation previousFootnoteCitation = currentFootnoteCitation.PreviousFootnoteCitation;

            if (previousFootnoteCitation == null)
            {
                //there is no previous citation in a footnote, so this is the first one (disregarding reference-less footnotes)
                return(true);
            }

            while (previousFootnoteCitation != null)
            {
                if (previousFootnoteCitation.FootnoteIndex != currentFootnoteCitation.FootnoteIndex)
                {
                    if (previousFootnoteCitation.PageInPublication == currentFootnoteCitation.PageInPublication)
                    {
                        //a different previous footnote on the same page > this citation cannot be in the first footnote on the page
                        return(false);
                    }
                    else
                    {
                        //a different previous footnote on other page > this citation is in first footnote on page (disregarding reference-less footnotes)
                        return(true);
                    }
                }
                else
                {
                    if (previousFootnoteCitation.PageInPublication == currentFootnoteCitation.PageInPublication)
                    {
                        //the previous citation is in the same footnote on the same page; we cannot say anything yet
                    }
                    else
                    {
                        //the previous citation is in the same footnote, but on a different page: can we really detect page breaks INSIDE footnotes?
                        return(true);
                    }
                }

                previousFootnoteCitation = previousFootnoteCitation.PreviousFootnoteCitation;
            }

            //still here? false!
            return(false);
        }
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            if (citation.Reference.ReferenceType == ReferenceType.LegalCommentary)
            {
                return(string.IsNullOrWhiteSpace(citation.Reference.SpecificField1));
            }

            if (citation.Reference.ReferenceType == ReferenceType.ContributionInLegalCommentary)
            {
                if (citation.Reference.ParentReference == null)
                {
                    return(false);
                }
                return(string.IsNullOrWhiteSpace(citation.Reference.ParentReference.SpecificField1));
            }

            return(false);
        }
Esempio n. 12
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.ParentReference == null)
            {
                return(false);
            }
            if (string.IsNullOrEmpty(citation.Reference.ParentReference.CustomField1))
            {
                return(false);
            }

            string test = citation.Reference.ParentReference.CustomField1;

            //note: if you do not specify the whole word, but rather its first characters, do NOT use * as a wildcard, but
            //\\w*, which means "zero or more word characters"
            var wordList = new string[] {
                "Lexikon\\w*",                                  //z.B. auch Wörter wie "Lexikonartikel" usw.
                "Enzyklopädie\\w*",
                "Encyclopedia",
                "encyclopédie"
            };
            var regEx = new Regex(@"\b(" + string.Join("|", wordList) + @")\b", RegexOptions.IgnoreCase);

            return(regEx.IsMatch(test));
        }
Esempio n. 13
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }

            var reference = citation.Reference;

            if (reference == null)
            {
                return(false);
            }

            var parentReference = citation.Reference.ParentReference;

            if (reference.HasCoreField(ReferenceTypeCoreFieldId.Edition))
            {
                return(!string.IsNullOrWhiteSpace(reference.Edition));
            }
            else if (parentReference != null && parentReference.HasCoreField(ReferenceTypeCoreFieldId.Edition))
            {
                return(!string.IsNullOrWhiteSpace(parentReference.Edition));
            }
            else
            {
                return(false);
            }
        }
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            //Just fill in those attribute that you would like to search for or leave empty
            //The following information must be filled in exactly as in the "Edit person" dialog
            string lastName     = "Doe";
            string firstName    = "";
            string middleName   = "";
            string prefix       = "";
            string suffix       = "";
            string abbreviation = "";

            //If you do not wish the above person to be checked as the publisher of the superordinate work,
            //then enter"= false;" in the following line:
            bool checkParentReference = true;


            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }


            var authors   = citation.Reference.AuthorsOrEditorsOrOrganizations;
            var hasAuthor = hasPerson(authors, lastName, firstName, middleName, prefix, suffix, abbreviation);

            if (hasAuthor)
            {
                return(true);
            }

            var parentReference = citation.Reference.ParentReference;

            if (parentReference == null)
            {
                return(false);
            }


            if (checkParentReference)
            {
                var editors   = parentReference.AuthorsOrEditorsOrOrganizations;
                var hasEditor = hasPerson(editors, lastName, firstName, middleName, prefix, suffix, abbreviation);

                if (hasEditor)
                {
                    return(true);
                }
            }
            else
            {
                return(false);
            }

            return(false);
        }
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            //Another contribution from the same parent reference has already been cited in the same footnote.
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.ParentReference == null)
            {
                return(false);
            }

            var thisFootnoteCitation = citation as FootnoteCitation;

            if (thisFootnoteCitation == null)
            {
                return(false);
            }

            var previousFootnoteCitation = thisFootnoteCitation.PreviousFootnoteCitation;

            if (previousFootnoteCitation == null)
            {
                return(false);
            }

            if (previousFootnoteCitation.FootnoteIndex != thisFootnoteCitation.FootnoteIndex)
            {
                return(false);
            }
            if (previousFootnoteCitation.Reference == null)
            {
                return(false);
            }
            if (previousFootnoteCitation.Reference == thisFootnoteCitation.Reference)
            {
                return(false);
            }
            if (previousFootnoteCitation.Reference.ParentReference == null)
            {
                return(false);
            }
            if (previousFootnoteCitation.Reference.ParentReference != thisFootnoteCitation.Reference.ParentReference)
            {
                return(false);
            }


            //all conditions met
            return(true);
        }
Esempio n. 16
0
        //Editors == Translators (applicable for collected works/edited books etc. AND contributions therein)
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            Reference currentReference = citation.Reference;
            Reference parentReference  = currentReference.ParentReference;

            bool currentReferenceHasEditors =
                currentReference.HasCoreField(ReferenceTypeCoreFieldId.Editors) &&
                currentReference.Editors != null &&
                currentReference.Editors.Any();

            bool currentReferenceHasTranslators =
                currentReference.Translators != null &&
                currentReference.Translators.Any();

            bool parentReferenceHasEditors =
                parentReference != null &&
                parentReference.HasCoreField(ReferenceTypeCoreFieldId.Editors) &&
                parentReference.Editors != null &&
                parentReference.Editors.Any();

            bool parentReferenceHasTranslators =
                parentReference != null &&
                parentReference.Translators != null &&
                parentReference.Translators.Any();


            if (currentReferenceHasTranslators && currentReferenceHasEditors)
            {
                return(CollectionUtility.ContentEquals(currentReference.Translators, currentReference.Editors, false));
            }

            if (currentReferenceHasTranslators && parentReferenceHasEditors)
            {
                return(CollectionUtility.ContentEquals(currentReference.Translators, parentReference.Editors, false));
            }

            if (parentReferenceHasTranslators && parentReferenceHasEditors)
            {
                return(CollectionUtility.ContentEquals(parentReference.Translators, parentReference.Editors, false));
            }


            //still here? then condition is not fulfilled
            return(false);
        }
Esempio n. 17
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            return(citation.Reference.CitationKeyUpdateType != 0);
        }
Esempio n. 18
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            return(!BuiltInTemplateCondition.PlaceholderCitationEmptyQuotationPageRange.IsMet(template, citation));
        }
Esempio n. 19
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.Periodical == null)
            {
                return(false);
            }

            return(citation.Reference.Periodical.Name.StartsWith("Journal Name"));
        }
Esempio n. 20
0
        //Die unmittelbar vorhergehende Fußnote ist von demselben Titel. Außerdem ist der Titel der unmittelbar vorhergehenden Fußnote bereits weiter oben schon einmal zitiert worden. Daher handelt es sich bei der aktuellen Fußnote um mindestens die dritte Erwähnung dieses Titels.

        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            var thisFootnoteCitation = citation as FootnoteCitation;

            if (thisFootnoteCitation == null)
            {
                return(false);
            }

            var previousFootnoteCitation = thisFootnoteCitation.PreviousFootnoteCitation;

            if (previousFootnoteCitation == null)
            {
                return(false);
            }

            if (thisFootnoteCitation.IsUniqueFootnote)
            {
                return(false);
            }
            if (!thisFootnoteCitation.IsRepeatingFootnote)
            {
                return(false);
            }

            if (previousFootnoteCitation.Reference != thisFootnoteCitation.Reference)
            {
                return(false);
            }
            if (!previousFootnoteCitation.IsRepeatingFootnote)
            {
                return(false);
            }

            return(true);
        }
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null) return false;
            if (citation.Reference == null) return false;
            if (string.IsNullOrEmpty(citation.Reference.TitleSupplement)) return false;

            var field = citation.Reference.TitleSupplement;

            //note: if you do not specify the whole word, but rather its first characters, do NOT use * as a wildcard, but
            //\\w*, which means "zero or more word characters"
            var wordList = new string[] {
                "Dissertation",
                "Doktor\\w*",					//z.B. auch Wörter wie "Doktorarbeit" usw.
                "Doctoral\\w*",					//z.B. auch Wörter wie "Doctoral dissertations" usw.
                "Master\\w*"					//z.B. auch Wörter wie "Masterarbeit" oder "Master's dissertations" usw.
            };
            var regEx = new Regex(@"\b(" + string.Join("|", wordList) + @")\b", RegexOptions.IgnoreCase);
            return regEx.IsMatch(field);
        }
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.ParentReference == null)
            {
                return(false);
            }

            var CustomField1 = citation.Reference.ParentReference.CustomField1;

            return(!string.IsNullOrEmpty(CustomField1));
        }
Esempio n. 23
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            //Titel ist nur einmal in der FN zitiert
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            FootnoteCitation footnoteCitation = citation as FootnoteCitation;

            if (footnoteCitation == null)
            {
                return(false);
            }

            return(footnoteCitation.IsUniqueFootnote);
        }
Esempio n. 24
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            //exactly 4 authors, editors, organizations
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            var authors = citation.Reference.AuthorsOrEditorsOrOrganizations;

            if (authors == null || authors.Count == 0)
            {
                return(false);
            }

            return(authors.Count() == 4);
        }
Esempio n. 25
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }

            var reference = citation.Reference;

            if (reference == null)
            {
                return(false);
            }

            var parentReference = citation.Reference.ParentReference;


            string editionNumberResolved;

            if (reference.HasCoreField(ReferenceTypeCoreFieldId.Edition))
            {
                editionNumberResolved = citation.Reference.EditionNumberResolved;
            }
            else if (parentReference != null && parentReference.HasCoreField(ReferenceTypeCoreFieldId.Edition))
            {
                editionNumberResolved = citation.Reference.ParentReference.EditionNumberResolved;
            }
            else
            {
                return(false);
            }

            //ONLY if edition number is 1
            if (editionNumberResolved == "1")
            {
                return(true);
            }

            return(false);
        }
Esempio n. 26
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }

            var reference = citation.Reference as Reference;

            if (reference == null)
            {
                return(false);
            }

            IEnumerable <ReferencePropertyId> fieldsToCheck =
                (from kvp in FieldsToCheck
                 where kvp.Value == Ensure.IsEmpty || kvp.Value == Ensure.IsNotEmpty
                 select kvp.Key).ToList();

            if (!fieldsToCheck.Any())
            {
                return(false);
            }

            foreach (ReferencePropertyId propertyId in fieldsToCheck)
            {
                ReferencePropertyDescriptor property = ReferencePropertyDescriptor.GetPropertyDescriptor(propertyId);
                if (property == null)
                {
                    continue;
                }

                if (!IsConditionMet(reference, property, FieldsToCheck[propertyId]))
                {
                    return(false);
                }
            }

            return(true);
        }
Esempio n. 27
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.ParentReference == null)
            {
                return(false);
            }

            if (!citation.Reference.ParentReference.ReferenceType.CoreFields.Contains(ReferenceTypeCoreFieldId.Authors))
            {
                return(false);
            }

            return(citation.Reference.ParentReference.Authors.Count == 0);
        }
Esempio n. 28
0
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }
            if (citation.Reference.ParentReference == null)
            {
                return(false);
            }

            if (citation.Reference.ParentReference.Groups == null || !citation.Reference.ParentReference.Groups.Any())
            {
                return(false);
            }

            return(citation.Reference.ParentReference.Groups.Any(item => item.Name.Equals("Group Name")));
        }
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }

            var reference = citation.Reference;

            if (reference == null)
            {
                return(false);
            }

            var placeholderCitation = citation as PlaceholderCitation;

            if (placeholderCitation == null)
            {
                return(false);
            }

            return(placeholderCitation.PageRange == null || string.IsNullOrWhiteSpace(placeholderCitation.PageRange.OriginalString));
        }
        public bool IsTemplateForReference(ConditionalTemplate template, Citation citation)
        {
            if (citation == null)
            {
                return(false);
            }
            if (citation.Reference == null)
            {
                return(false);
            }

            FootnoteCitation currentFootnoteCitation = citation as FootnoteCitation;

            if (currentFootnoteCitation == null)
            {
                return(false);
            }

            FootnoteCitation previousFootnoteCitation = currentFootnoteCitation.PreviousFootnoteCitation;

            while (previousFootnoteCitation != null)
            {
                if (previousFootnoteCitation.PageInPublication != currentFootnoteCitation.PageInPublication)
                {
                    return(false);
                }
                if (previousFootnoteCitation.Reference != null && previousFootnoteCitation.Reference.Equals(currentFootnoteCitation.Reference))
                {
                    return(true);
                }

                previousFootnoteCitation = previousFootnoteCitation.PreviousFootnoteCitation;
            }

            //still here, then we had no luck iterating on same page & looking for same reference
            return(false);
        }