示例#1
0
 public NotenizerDependency(TypedDependency typedDependency)
 {
     _dependent = new NotenizerWord(typedDependency.dep());
     _governor = new NotenizerWord(typedDependency.gov());
     _relation = new NotenizerRelation(typedDependency.reln());
     _originalDependency = typedDependency;
 }
示例#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;
 }
示例#3
0
 public NoteParticle(NotenizerDependency dependency)
 {
     _tokenType = dependency.TokenType;
     _noteDependency = dependency.Clone();
     _noteWord = dependency.CorrespondingWord;
     //_noteWordValue = MakeWordConsiderRelation(_noteWord, _noteDependency.Relation);
     _noteWordValue = _noteWord.Word;
 }
示例#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; ;
        }
示例#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;
 }
示例#6
0
 public static bool SamePartOfSpeechTag(NotenizerWord firstW, NotenizerWord secondW)
 {
     return firstW.POS.Tag == secondW.POS.Tag;
 }
示例#7
0
 public static bool SameNER(NotenizerWord firstW, NotenizerWord secondW)
 {
     return firstW.NamedEntity.Value == secondW.NamedEntity.Value;
 }
示例#8
0
 public static bool SameLemma(NotenizerWord firstW, NotenizerWord secondW)
 {
     return firstW.Lemma == secondW.Lemma;
 }
示例#9
0
 public static bool SameIndex(NotenizerWord firstW, NotenizerWord secondW)
 {
     return firstW.Index == secondW.Index;
 }
示例#10
0
 public static double CalculateClosenessWords(NotenizerWord firstW, NotenizerWord secondW, double comparisonValue, int count)
 {
     return CalculateCloseness(firstW.Index, secondW.Index, comparisonValue, count);
 }
示例#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;
        }
示例#12
0
 public NoteParticle(String noteWordValue, NotenizerWord noteWord, NotenizerDependency noteDependency)
 {
     _noteWordValue = noteWordValue;
     _noteWord = noteWord;
     _noteDependency = noteDependency.Clone();
 }
示例#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;
        }