diff options
-rw-r--r-- | src/client/ClientRecommender.tsx | 14 | ||||
-rw-r--r-- | src/client/cognitive_services/CognitiveServices.ts | 8 | ||||
-rw-r--r-- | src/client/util/SearchUtil.ts | 2 | ||||
-rw-r--r-- | src/client/views/Recommendations.tsx | 17 |
4 files changed, 26 insertions, 15 deletions
diff --git a/src/client/ClientRecommender.tsx b/src/client/ClientRecommender.tsx index b4a496563..9ce7df366 100644 --- a/src/client/ClientRecommender.tsx +++ b/src/client/ClientRecommender.tsx @@ -126,6 +126,14 @@ export class ClientRecommender extends React.Component<RecommenderProps> { return meanVector; } + public processVector(vector: number[], dataDoc: Doc, mainDoc: boolean) { + if (vector.length > 0) { + const internalDoc: RecommenderDocument = { actualDoc: dataDoc, vectorDoc: vector, score: 0 }; + if (mainDoc) ClientRecommender.Instance.mainDoc = internalDoc; + ClientRecommender.Instance.addToDocSet(internalDoc); + } + } + private addToDocSet(internalDoc: RecommenderDocument) { if (ClientRecommender.Instance.docVectors) { ClientRecommender.Instance.docVectors.add(internalDoc); @@ -149,6 +157,7 @@ export class ClientRecommender extends React.Component<RecommenderProps> { let keyPhrases = doc.keyPhrases; keyPhrases.map((kp: string) => { const frequency = this.countFrequencies(kp, data); + keyterms.push(kp); if (frequency > high) { high = frequency; highKP = [kp]; @@ -159,7 +168,7 @@ export class ClientRecommender extends React.Component<RecommenderProps> { let words = kp.split(" "); // separates phrase into words words = this.removeStopWords(words); // removes stop words if they appear in phrases words.forEach((word) => { - keyterms.push(word); + //keyterms.push(word); for (let i = 0; i < frequency; i++) { keyterms_counted.push(word); } @@ -170,7 +179,8 @@ export class ClientRecommender extends React.Component<RecommenderProps> { //console.log(highKP); const kts_counted = new List<string>(); keyterms_counted.forEach(kt => kts_counted.push(kt.toLowerCase())); - const values = await this.sendRequest(highKP); + let values = ""; + if (!internal) values = await this.sendRequest(highKP); return { keyterms: keyterms, keyterms_counted: kts_counted, values }; }; if (data != "") { diff --git a/src/client/cognitive_services/CognitiveServices.ts b/src/client/cognitive_services/CognitiveServices.ts index e391b98d2..c138c68b7 100644 --- a/src/client/cognitive_services/CognitiveServices.ts +++ b/src/client/cognitive_services/CognitiveServices.ts @@ -272,12 +272,12 @@ export namespace CognitiveServices { if (wordvecs) { let indices = Object.keys(wordvecs); console.log("successful vectorization!"); - var vectorValues = new Set<number[]>(); + var vectorValues = new List<number>(); indices.forEach((ind: any) => { //console.log(wordvec.word); - vectorValues.add(wordvecs[ind]); + vectorValues.push(wordvecs[ind]); }); - ClientRecommender.Instance.mean(vectorValues, dataDoc, mainDoc); + ClientRecommender.Instance.processVector(vectorValues, dataDoc, mainDoc); } // adds document to internal doc set else { console.log("unsuccessful :( word(s) not in vocabulary"); @@ -295,7 +295,7 @@ export namespace CognitiveServices { target[keys[0]] = keyterms; console.log("analyzed!"); if (internal) { - await vectorize(keyterms_counted, dataDoc, mainDoc, data); + await vectorize(keyterms, dataDoc, mainDoc, data); } else { return values; } diff --git a/src/client/util/SearchUtil.ts b/src/client/util/SearchUtil.ts index d65ec3f40..fb3189069 100644 --- a/src/client/util/SearchUtil.ts +++ b/src/client/util/SearchUtil.ts @@ -127,7 +127,7 @@ export namespace SearchUtil { }); let result: IdSearchResult = JSON.parse(response); const { ids, numFound, highlighting } = result; - console.log(ids.length); + //console.log(ids.length); const docMap = await DocServer.GetRefFields(ids); const docs: Doc[] = []; for (const id of ids) { diff --git a/src/client/views/Recommendations.tsx b/src/client/views/Recommendations.tsx index c44dfc032..5dc62105d 100644 --- a/src/client/views/Recommendations.tsx +++ b/src/client/views/Recommendations.tsx @@ -77,25 +77,26 @@ export class RecommendationsBox extends React.Component<FieldViewProps> { onPointerEnter={action(() => this._displayDim = this._useIcons ? 50 : Number(SEARCH_THUMBNAIL_SIZE))} onPointerLeave={action(() => this._displayDim = 50)} > */} <DocumentView - fitToBox={StrCast(doc.type).indexOf(DocumentType.COL) !== -1} - Document={newRenderDoc} + fitToBox={StrCast(doc).indexOf(DocumentType.COL) !== -1} + Document={doc} addDocument={returnFalse} removeDocument={returnFalse} + ruleProvider={undefined} ScreenToLocalTransform={Transform.Identity} addDocTab={returnFalse} + pinToPres={returnFalse} renderDepth={1} PanelWidth={returnXDimension} PanelHeight={returnYDimension} focus={emptyFunction} backgroundColor={returnEmptyString} - // selectOnLoad={false} - pinToPres={emptyFunction} parentActive={returnFalse} whenActiveChanged={returnFalse} bringToFront={emptyFunction} zoomToScale={emptyFunction} getScale={returnOne} ContainingCollectionView={undefined} + ContainingCollectionDoc={undefined} ContentScaling={scale} /> </div>; @@ -170,16 +171,16 @@ export class RecommendationsBox extends React.Component<FieldViewProps> { {DocListCast(this.props.Document.data).map(doc => { return ( <div className="content"> - <span style={{ height: NumCast(this.props.Document.documentIconHeight) }} className="image-background"> + {/* <span style={{ height: NumCast(this.props.Document.documentIconHeight) }} className="image-background"> {this.DocumentIcon(doc)} - </span> + </span> */} <span className="score">{NumCast(doc.score).toFixed(4)}</span> <div style={{ marginRight: 50 }} onClick={() => DocumentManager.Instance.jumpToDocument(doc, false)}> <FontAwesomeIcon className="documentdecorations-icon" icon={"bullseye"} size="sm" /> </div> - <div style={{ marginRight: 50 }} onClick={() => DocUtils.MakeLink(this.props.Document.sourceDoc as Doc, doc, undefined, "User Selected Link", "Generated from Recommender", undefined)}> + {/* <div style={{ marginRight: 50 }} onClick={() => DocUtils.MakeLink({ doc: this.props.Document.sourceDoc as Doc }, { doc: doc }, "User Selected Link", "Generated from Recommender", undefined)}> <FontAwesomeIcon className="documentdecorations-icon" icon={"link"} size="sm" /> - </div> + </div> */} </div> ); })} |