public void AddEntity(EntityName entityName, EntityForm canonicalForm, EntityForm[] otherForms)
        {
            foreach (var entitySpecification in _entitySpecifications)
            {
                entitySpecification.AssertDoesNotConflictWith(entityName, canonicalForm, otherForms);
            }

            _entitySpecifications.Add(new EntitySpecification(entityName, canonicalForm, otherForms));
        }
Exemple #2
0
        public void AssertDoesNotConflictWith(EntityName entityName, EntityForm value, EntityForm[] otherForms)
        {
            var externalPhrases = new[] { value }.Concat(otherForms);

            ;
            foreach (var internalPhrase in _allForms)
            {
                if (externalPhrases.Contains(internalPhrase))
                {
                    throw new ConflictingEntityException(entityName, _entityName, internalPhrase);
                }
            }
        }
Exemple #3
0
 public EntitySpecification(EntityName entityName, EntityForm canonicalForm, EntityForm[] synonyms)
 {
     _entityName    = entityName;
     _canonicalForm = canonicalForm;
     _allForms      = new[] { canonicalForm }.Concat(synonyms);
 }
Exemple #4
0
 public ConflictingEntityException(EntityName attemptedEntityName, EntityName existingEntityName, EntityForm conflictingForm)
     : base($"The phrase '{conflictingForm}' cannot be added for the entity '{attemptedEntityName}', " +
            $"because it is already present for entity '{existingEntityName}', which would be matched earlier")
 {
 }
 public RecognizedEntity(EntityName entityName, EntityForm recognizedValue, EntityForm canonicalForm)
 {
     Entity          = entityName;
     RecognizedValue = recognizedValue;
     CanonicalForm   = canonicalForm;
 }
 public static RecognizedEntity ByCanonicalForm(EntityName entityName, EntityForm canonicalForm)
 {
     return(new RecognizedEntity(entityName, canonicalForm, canonicalForm));
 }
 public static RecognizedEntity Value(EntityName name, EntityForm recognizedValue, EntityForm canonicalForm)
 {
     return(new RecognizedEntity(name, recognizedValue, canonicalForm));
 }
 public void AddEntity(EntityName entityName, EntityForm canonicalForm)
 {
     AddEntity(entityName, canonicalForm, new EntityForm[] { });
 }
Exemple #9
0
 public void AddEntity(string entityName, string value)
 {
     _recognitionModel.AddEntity(EntityName.Value(entityName), EntityForm.Value(value));
 }
Exemple #10
0
 public void AddEntity(string entityName, string value, string[] synonyms)
 {
     _recognitionModel.AddEntity(EntityName.Value(entityName), EntityForm.Value(value), synonyms.Select(EntityForm.Value).ToArray());
 }