Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature/phrase search #6

Open
wants to merge 10 commits into
base: main
Choose a base branch
from
Open

Feature/phrase search #6

wants to merge 10 commits into from

Conversation

mobinbr
Copy link
Collaborator

@mobinbr mobinbr commented Aug 4, 2024

No description provided.

@mobinbr mobinbr requested review from AliSK81 and HamedSY August 4, 2024 09:34
Copy link

@AliSK81 AliSK81 left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

خسته نباشید

Comment on lines +16 to +19
ArgumentNullException.ThrowIfNull(searcher);
ArgumentNullException.ThrowIfNull(parser);
_searcher = searcher;
_parser = parser;
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

_searcher = searcher ?? throw new ArgumentNullException(nameof(searcher));

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

به نظرمون روش ما readabilityش بالاتره
باز اگه دلیل خاصی براش دارین لطفا بیشتر توضیح بدین

var optionalWords = new List<Keyword>();
var excludedWords = new List<Keyword>();

var regex = new Regex(@"[+-]?\b\w+\b|[+-]?""[^""]+""");
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

این میتونه const تعریف بشه یا حتی یک سرویس داشته باشیم که regexی که میخوایم رو provide میکنه
بهتره یه summary داشته باشیم که این ریجکس چیکار میکنه

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

اصلاح شد


public static class Logging
{
public static ILogger Logger{get; private set;}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

میتونه جنریک تعریف بشه که برای هر کلاس تایپ اونو بدیم

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

ILogger<ClassType>

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

اصلاح شد

Comment on lines +7 to +8
HashSet<string> AllDocuments { get; }
HashSet<string> GetDocumentsByKeyword(Keyword keyword);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

اگه بخوایم مکان هر کلمه توی سند رو هم بدونیم و بخوایم توسعه بدیم لازم میشه ریترن تایپ رو عوض کنیم
در صورتی که بجای string میتونستیم یه تایپ از کلاس جدیدی که wrapper برای string هست ریترن کنیم (یعنی کلاسی که داخلش متغیر شماره سند باشه و بعدا بتونیم مثلا شماره خط یا.. هم اضافه کنیم)

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

صرفا برای اینکه گوشه ذهنمون باشه گفتم نیاز به تغییرات نیست

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

اوکی ممنون

Comment on lines 49 to 73
private bool Equals(AdvancedInvertedIndex other)
{
if (_invertedIndexMap.Count != other._invertedIndexMap.Count)
return false;

foreach (var kvp in _invertedIndexMap)
{
if (!other._invertedIndexMap.TryGetValue(kvp.Key, out var otherSet))
return false;

if (!kvp.Value.SetEquals(otherSet))
return false;
}

var areDocumentsEqual = AllDocuments.SetEquals(other.AllDocuments);
return areDocumentsEqual;
}

public override bool Equals(object? obj)
{
if (ReferenceEquals(null, obj)) return false;
if (ReferenceEquals(this, obj)) return true;
if (obj.GetType() != this.GetType()) return false;
return Equals((AdvancedInvertedIndex)obj);
}
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

چرا GetHashCode رو اورراید نکردیم؟ ارتباطش با Equals چیه؟

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

نیازه این کلاس IEquatable رو هم ایمپلمنت کنه؟

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

اینو تست کردیم؟

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

اصلاح شد

Comment on lines +37 to +38
Assert.Equal(["doc1"], documents1);
Assert.Equal(["doc2"], documents2);
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

با SequenceEqual نمیشه؟

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

میشه زد ولی خوانایی همین به نظرمون بهتره


yield return
[
"-arshad -arshada ali",
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

😂❤️


[Theory]
[MemberData(nameof(GetTestData))]
public void ExtractKeywords_ShouldTokenizeText_WhenStringContainsSingleQuotation(string text, List<Keyword> expectedKeywords)
Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

فکر کنم single quote + space باید باشه با توجه به تست کیس اول

Copy link

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

بهتر نبود delimitter رو کسی که میخواد tokenize کنه مشخص کنه

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

اصلاح شد

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants