-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathSentenceTree.h
35 lines (23 loc) · 1.54 KB
/
SentenceTree.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
#include "ParseASentence.h"
#include "Dictionary.h"
#include "SentimentLabels.h"
#include "RNNParam.h"
#include<string>
#include<unordered_map>
using namespace std;
/**
* Contains methods which interact with a given sentence's tree.
*/
// Given a sentence, construct its semantic tree by combining the words using the tanh rule.
Tree* constructTreeForASentence(string sentence, vector<vector<double>> weights, vector<vector<double>> weightScore, Vocabulary *vocab, vector<double> biasSentimentMatrix);
// Given a string of digits and | symbols, return the target tree represented by that string.
Tree* constructTargetTree(string treeText, string sentence, Dictionary* dictionary, SentimentLabels* sentimentLabels);
RNNParam* backprop(Tree * targetTree, Tree * computedTree, vector<vector<double>>
weightScoresMatrix, vector<vector<double>> weightsMatrix, vector<double> parentError, vector<double> biasSentimentMatrix);
// Read from the PreprocessedDatasetSentences.txt.
unordered_map<long long, string> readParsedTrees();
// Use the parsing tring in the forward propogation.
Tree* useParserForCreatingTheTree(string treeText, string sentence, Vocabulary* vocab, vector<vector<double>> weightScoresMatrix,
vector<vector<double>> weightsMatrix, vector<double> biasSentimentMatrix, vector<double> biasWeights);
double computeErrorForTree(Tree* computedTree, Tree* targetTree, vector<vector<double>> weightScoresMatrix, vector<double> biasWeights);
long long getTotalNumberOfInnerNodesCorrectlyPredictted(Tree* targetTree, Tree* computedTree);