Compare commits

..

No commits in common. "40a292d05e1fc547183bc7fd5beeb1200cda6e2e" and "4f777f00031b8b95c5e842fc48636588014888c2" have entirely different histories.

View File

@ -75,19 +75,14 @@ class ChatInputComponent extends HTMLElement {
authors.forEach(author => {
const lowerAuthor = author.toLowerCase();
let distance = this.levenshteinDistance(lowerMention, lowerAuthor);
if(!this.isSubsequence(lowerMention,lowerAuthor)) {
distance += 10
distance += 1
}
console.warn([ mention, author, distance ]);
if (distance < minDistance) {
minDistance = distance;
closestAuthor = author;
console.info({ mention, closestAuthor, distance });
}
});
return { mention, closestAuthor, distance: minDistance };
@ -129,9 +124,11 @@ levenshteinDistance(a, b) {
const mentions = this.extractMentions(text);
const matches = this.matchMentionsToAuthors(mentions, authors);
console.info(matches)
let updatedText = text;
matches.forEach(({ mention, closestAuthor }) => {
const mentionRegex = new RegExp(`@${mention}`, 'g');
console.info(closestAuthor)
updatedText = updatedText.replace(mentionRegex, `@${closestAuthor}`);
});