Skip to content

Commit

Permalink
Minor fix
Browse files Browse the repository at this point in the history
  • Loading branch information
isc-lperezra committed Aug 23, 2024
1 parent f017bcb commit aa2179f
Show file tree
Hide file tree
Showing 3 changed files with 14 additions and 12 deletions.
10 changes: 6 additions & 4 deletions encoder-ui/src/app/analysis/analysis.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -85,32 +85,34 @@ export class AnalysisComponent implements OnInit{
var textHTML = textSelected;
this.textToMark = textSelected;
this.loading = true;
var regex = /[.,;:¿?!¡]/g;

this.irisService.getAnalysisDetails(idAnalysis).subscribe({next: res => {
if (res.length > 0){
this.diagnostics = this.diagnostics.concat(res);
}
this.diagnostics.forEach((diagnostic, indexDiag) => {
let phrase: string = "";
if (diagnostic.RawText.split(" ").length == 3){
const matchValue = textSelected.match(new RegExp(diagnostic.RawText.split(" ")[0] + " (.{0,100}) " +diagnostic.RawText.split(" ")[2],"ig"));
const matchValue = textSelected.toLowerCase().replace(regex,"").match(new RegExp(diagnostic.RawText.split(" ")[0] + "(.{0,100})" +diagnostic.RawText.split(" ")[2],"ig"));
if (matchValue) {
phrase = matchValue[0];
}
}
else if (diagnostic.RawText.split(" ").length == 2){
const matchValue = textSelected.match(new RegExp(diagnostic.RawText.split(" ")[0] + " (.{0,100}) " +diagnostic.RawText.split(" ")[1],"ig"));
const matchValue = textSelected.toLowerCase().replace(regex,"").match(new RegExp(diagnostic.RawText.split(" ")[0] + "(.{0,100})" +diagnostic.RawText.split(" ")[1],"ig"));
if (matchValue) {
phrase = matchValue[0];
}
}
else if (diagnostic.RawText.split(" ").length == 4){
const matchValue = textSelected.match(new RegExp(diagnostic.RawText.split(" ")[0] + " (.{0,100}) " +diagnostic.RawText.split(" ")[3],"ig"));
const matchValue = textSelected.toLowerCase().replace(regex,"").match(new RegExp(diagnostic.RawText.split(" ")[0] + "(.{0,100})" +diagnostic.RawText.split(" ")[3],"ig"));
if (matchValue) {
phrase = matchValue[0];
}
}
else if (diagnostic.RawText.split(" ").length == 1){
const matchValue = textSelected.match(diagnostic.RawText);
const matchValue = textSelected.toLowerCase().replace(regex,"").match(diagnostic.RawText);
if (matchValue) {
phrase = matchValue[0];
}
Expand Down
9 changes: 5 additions & 4 deletions encoder-ui/src/app/analyzer/analyzer.component.ts
Original file line number Diff line number Diff line change
Expand Up @@ -53,6 +53,7 @@ export class AnalyzerComponent {
this.totalReceived = 0;
this.error = false;
this.loading = true;
var regex = /[.,;:¿?!¡]/g;
this.textAndDiagnosticList = [];
const rawText = {
"Text": textOriginal
Expand All @@ -77,25 +78,25 @@ export class AnalyzerComponent {
this.diagnostics.forEach((diagnostic, indexDiag) => {
let phrase: string = "";
if (diagnostic.RawText.split(" ").length == 3){
const matchValue = textOriginal.match(new RegExp(diagnostic.RawText.split(" ")[0] + " (.{0,100}) " +diagnostic.RawText.split(" ")[2],"ig"));
const matchValue = textOriginal.toLowerCase().replace(regex,"").match(new RegExp(diagnostic.RawText.split(" ")[0] + "(.{0,100})" +diagnostic.RawText.split(" ")[2],"ig"));
if (matchValue) {
phrase = matchValue[0];
}
}
else if (diagnostic.RawText.split(" ").length == 2){
const matchValue = textOriginal.match(new RegExp(diagnostic.RawText.split(" ")[0] + " (.{0,100}) " +diagnostic.RawText.split(" ")[1],"ig"));
const matchValue = textOriginal.toLowerCase().replace(regex,"").match(new RegExp(diagnostic.RawText.split(" ")[0] + "(.{0,100})" +diagnostic.RawText.split(" ")[1],"ig"));
if (matchValue) {
phrase = matchValue[0];
}
}
else if (diagnostic.RawText.split(" ").length == 4){
const matchValue = textOriginal.match(new RegExp(diagnostic.RawText.split(" ")[0] + " (.{0,100}) " +diagnostic.RawText.split(" ")[3],"ig"));
const matchValue = textOriginal.toLowerCase().replace(regex,"").match(new RegExp(diagnostic.RawText.split(" ")[0] + "(.{0,100})" +diagnostic.RawText.split(" ")[3],"ig"));
if (matchValue) {
phrase = matchValue[0];
}
}
else if (diagnostic.RawText.split(" ").length == 1){
const matchValue = textOriginal.match(diagnostic.RawText);
const matchValue = textOriginal.toLowerCase().replace(regex,"").match(diagnostic.RawText);
if (matchValue) {
phrase = matchValue[0];
}
Expand Down
7 changes: 3 additions & 4 deletions src/ENCODER/BP/AnalyzeTextProcess.cls
Original file line number Diff line number Diff line change
Expand Up @@ -35,14 +35,13 @@ Method AnalyzeText(text As %String, analysisId As %String, language As %String)
lexical_tokens = [t.lower() for t in words if t.isalpha()]
phrase = " ".join(lexical_tokens)
result = ""
words = phrase.split(" ")
totalWords = len(words)
totalWords = len(lexical_tokens)
i = 0
texts = []
while i + 3 <= totalWords :
texts.append(words[i]+" "+words[i+1]+" "+words[i+2])
texts.append(lexical_tokens[i]+" "+lexical_tokens[i+1]+" "+lexical_tokens[i+2])
i = i + 1
if len(texts) == 0 :
if totalWords < 3 :
texts.append(phrase)

embeddings = model.encode(texts, normalize_embeddings=True)
Expand Down

0 comments on commit aa2179f

Please sign in to comment.