Ejemplo n.º 1
0
 /**
  * <summary> Constructor of VectorizedNerInstanceGenerator which takes input a {@link VectorizedDictionary}, a window size
  * and a word format and sets corresponding attributes with these inputs.</summary>
  * <param name="fsm">Morphological analyzer used to create multi-word expressions.</param>
  * <param name="wordNet">WordNet for checking multii-word and single-word expressions.</param>
  * <param name="dictionary">Dictionary in the vector form. Each word is stored in vector form in this dictionary.</param>
  * <param name="windowSize">Number of previous (next) words to be considered in adding attributes.</param>
  * <param name="format">Word vector format.</param>
  */
 public VectorizedSemanticInstanceGenerator(FsmMorphologicalAnalyzer fsm, WordNet.WordNet wordNet,
                                            VectorizedDictionary dictionary, int windowSize, WordFormat format) : base(fsm, wordNet)
 {
     this._format     = format;
     this._dictionary = dictionary;
     this.windowSize  = windowSize;
 }
Ejemplo n.º 2
0
 /**
  * <summary> Constructor of VectorizedNerInstanceGenerator which takes input a {@link VectorizedDictionary}, a window size
  * and a word format and sets corresponding attributes with these inputs.</summary>
  * <param name="dictionary">Dictionary in the vector form. Each word is stored in vector form in this dictionary.</param>
  * <param name="windowSize">Number of previous (next) words to be considered in adding attributes.</param>
  * <param name="format">Word vector format.</param>
  */
 public VectorizedShallowParseInstanceGenerator(VectorizedDictionary dictionary, int windowSize,
                                                WordFormat format)
 {
     this._format     = format;
     this._dictionary = dictionary;
     this.windowSize  = windowSize;
 }
Ejemplo n.º 3
0
        /**
         * <summary>Main method for training the Word2Vec algorithm. Depending on the training parameter, CBox or SkipGram algorithm
         * is applied.</summary>
         * <returns>Dictionary of word vectors.</returns>
         */
        public VectorizedDictionary Train()
        {
            var result = new VectorizedDictionary(new TurkishWordComparator());

            if (_parameter.IsCbow())
            {
                TrainCbow();
            }
            else
            {
                TrainSkipGram();
            }

            for (var i = 0; i < _vocabulary.Size(); i++)
            {
                result.AddWord(new VectorizedWord(_vocabulary.GetWord(i).GetName(), _wordVectors.GetRow(i)));
            }

            return(result);
        }