Exemplo n.º 1
0
 public NotenizerDependency(TypedDependency typedDependency)
 {
     _dependent = new NotenizerWord(typedDependency.dep());
     _governor = new NotenizerWord(typedDependency.gov());
     _relation = new NotenizerRelation(typedDependency.reln());
     _originalDependency = typedDependency;
 }
Exemplo n.º 2
0
 public NoteParticle(String noteWordValue, NotenizerDependency dependency, TokenType tokenType)
 {
     _tokenType = tokenType;
     _noteDependency = dependency.Clone();
     _noteDependency.TokenType = tokenType;
     _noteWordValue = noteWordValue;
     _noteWord = tokenType == TokenType.Dependent ? dependency.Dependent : dependency.Governor;
 }
Exemplo n.º 3
0
 public NoteParticle(NotenizerDependency dependency)
 {
     _tokenType = dependency.TokenType;
     _noteDependency = dependency.Clone();
     _noteWord = dependency.CorrespondingWord;
     //_noteWordValue = MakeWordConsiderRelation(_noteWord, _noteDependency.Relation);
     _noteWordValue = _noteWord.Word;
 }
Exemplo n.º 4
0
        public NoteParticle(NotenizerDependency dependency, TokenType tokenType, bool considerRelationInWordValueMaking = false)
        {
            if (tokenType == TokenType.Unidentified)
                throw new Exception("Can't make NoteParticle from token of type " + tokenType.ToString());

            _tokenType = tokenType;
            _noteDependency = dependency.Clone();
            _noteDependency.TokenType = tokenType;
            _noteWord = _tokenType == TokenType.Dependent ? dependency.Dependent : dependency.Governor;
            _noteWordValue = considerRelationInWordValueMaking ? MakeWordConsiderRelation(_noteWord, _noteDependency.Relation) : _noteWord.Word; ;
        }
Exemplo n.º 5
0
 public NotenizerDependency(
     NotenizerWord governor,
     NotenizerWord dependent,
     NotenizerRelation relation,
     int position,
     ComparisonType comparisonType,
     TokenType tokenType)
 {
     _governor = governor;
     _dependent = dependent;
     _relation = relation;
     _position = position;
     _comparisonType = comparisonType;
     _tokenType = tokenType;
 }
Exemplo n.º 6
0
 public static bool SamePartOfSpeechTag(NotenizerWord firstW, NotenizerWord secondW)
 {
     return firstW.POS.Tag == secondW.POS.Tag;
 }
Exemplo n.º 7
0
 public static bool SameNER(NotenizerWord firstW, NotenizerWord secondW)
 {
     return firstW.NamedEntity.Value == secondW.NamedEntity.Value;
 }
Exemplo n.º 8
0
 public static bool SameLemma(NotenizerWord firstW, NotenizerWord secondW)
 {
     return firstW.Lemma == secondW.Lemma;
 }
Exemplo n.º 9
0
 public static bool SameIndex(NotenizerWord firstW, NotenizerWord secondW)
 {
     return firstW.Index == secondW.Index;
 }
Exemplo n.º 10
0
 public static double CalculateClosenessWords(NotenizerWord firstW, NotenizerWord secondW, double comparisonValue, int count)
 {
     return CalculateCloseness(firstW.Index, secondW.Index, comparisonValue, count);
 }
Exemplo n.º 11
0
        /// <summary>
        /// Create dependencies from deocument.
        /// </summary>
        /// <param name="dbEntry"></param>
        /// <param name="noteFieldName"></param>
        /// <returns></returns>
        private static NotenizerDependencies ParseDependencies(BsonDocument dbEntry, String noteFieldName)
        {
            int position;
            TokenType tokenType;
            NotenizerWord governor;
            NotenizerWord dependent;
            BsonDocument governorDoc;
            BsonDocument dependantDoc;
            NotenizerRelation relation;
            ComparisonType comparisonType;
            NotenizerDependency dependency;
            NotenizerDependencies dependencies = new NotenizerDependencies();
            // foreach note dependency
            foreach (BsonDocument documentLoop in dbEntry[noteFieldName].AsBsonArray)
            {
                relation = new NotenizerRelation(documentLoop[DBConstants.RelationNameFieldName].AsString);

                // foreach dependency in array of dependencies with same relation name
                foreach (BsonDocument dependencyDocLoop in documentLoop[DBConstants.DependenciesFieldName].AsBsonArray)
                {
                    governorDoc = dependencyDocLoop[DBConstants.GovernorFieldName].AsBsonDocument;
                    dependantDoc = dependencyDocLoop[DBConstants.DependentFieldName].AsBsonDocument;
                    position = dependencyDocLoop[DBConstants.PositionFieldName].AsInt32;
                    comparisonType = dependencyDocLoop.GetValue(DBConstants.ComparisonTypeFieldName, ComparisonType.Unidentified).AsInt32.ToEnum<ComparisonType>();
                    tokenType = dependencyDocLoop.GetValue(DBConstants.TokenTypeFieldName, TokenType.Unidentified).AsInt32.ToEnum<TokenType>();

                    governor = new NotenizerWord(
                        governorDoc[DBConstants.POSFieldName].AsString,
                        governorDoc[DBConstants.IndexFieldName].AsInt32,
                        governorDoc[DBConstants.LemmaFieldName].AsString,
                        governorDoc[DBConstants.NERFieldName].AsString);

                    dependent = new NotenizerWord(
                        dependantDoc[DBConstants.POSFieldName].AsString,
                        dependantDoc[DBConstants.IndexFieldName].AsInt32,
                        dependantDoc[DBConstants.LemmaFieldName].AsString,
                        dependantDoc[DBConstants.NERFieldName].AsString);

                    dependency = new NotenizerDependency(governor, dependent, relation, position, comparisonType, tokenType);

                    dependencies.Add(dependency);
                }
            }

            return dependencies;
        }
Exemplo n.º 12
0
 public NoteParticle(String noteWordValue, NotenizerWord noteWord, NotenizerDependency noteDependency)
 {
     _noteWordValue = noteWordValue;
     _noteWord = noteWord;
     _noteDependency = noteDependency.Clone();
 }
Exemplo n.º 13
0
        /// <summary>
        /// Create word with considering special relations.
        /// </summary>
        /// <param name="noteWord"></param>
        /// <param name="relation"></param>
        /// <returns></returns>
        private String MakeWordConsiderRelation(NotenizerWord noteWord, NotenizerRelation relation)
        {
            String word = String.Empty;

            if (relation.ShortName == GrammaticalConstants.NominalModifier)
                word = relation.AdjustedSpecific + NotenizerConstants.WordDelimeter + noteWord.Word;
            else
                word = noteWord.Word;

            return word;
        }