-
Notifications
You must be signed in to change notification settings - Fork 32
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
Галичев Артем #20
Open
S4MPAI
wants to merge
23
commits into
kontur-courses:master
Choose a base branch
from
S4MPAI:master
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Open
Галичев Артем #20
Changes from 1 commit
Commits
Show all changes
23 commits
Select commit
Hold shift + click to select a range
d46831a
add projects from TagsCloudLayouter
S4MPAI b3b0b3c
add new project TagsCloudConsole
S4MPAI 244c344
add words handlers
S4MPAI 8a0f5f7
add interfaces
S4MPAI 21f48f1
change namespace of CloudLayouters
S4MPAI ee0791b
add DefaultColorFactory.cs
S4MPAI fd73b9e
add TagLayouter.cs
S4MPAI f5426c1
add TagsCloudImageCreator.cs
S4MPAI 46f8179
add russian dictionary for WordList
S4MPAI d96e3a4
add PngSaver.cs
S4MPAI f1e1748
take out TagLayouter.cs options in class
S4MPAI 27a14e9
add ContainerBuilderExtensions.cs
S4MPAI 5ffc2e8
add TagsCloudVisualizationOptions.cs
S4MPAI 9f22d1d
add TagVisualizer.cs
S4MPAI e4993fd
add TxtReader.cs
S4MPAI 8abcb06
implement classes in TagsCloudVisualization.csproj
S4MPAI 4ae31cc
add new tests for TagsCloudVisualization
S4MPAI 6f76418
fix startup configurations
S4MPAI 6cf46bf
add tag cloud templates
S4MPAI 73ca1d4
fix TagsCloudVisualization logic
S4MPAI 2a68341
fix container build logic in TagsCloudConsole
S4MPAI 67f839f
fix CartesianVisualizer.cs
S4MPAI ef74dcc
fix tests
S4MPAI File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -2,13 +2,13 @@ namespace TagsCloudVisualization.TextReaders; | |
|
||
public class TxtReader : ITextReader | ||
{ | ||
public bool IsCanRead(string filePath) | ||
{ | ||
throw new NotImplementedException(); | ||
} | ||
public bool IsCanRead(string filePath) => | ||
filePath.EndsWith(".txt"); | ||
|
||
public string ReadWords(string filePath) | ||
{ | ||
throw new NotImplementedException(); | ||
using var reader = new StreamReader(filePath); | ||
|
||
return reader.ReadToEnd(); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Можно без стрима, просто |
||
} | ||
} |
29 changes: 29 additions & 0 deletions
29
TagsCloudVisualization/Visualizers/CartesianTagVisualizer.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,29 @@ | ||
using System.Drawing; | ||
using TagsCloudVisualization.ColorFactories; | ||
using TagsCloudVisualization.Models; | ||
|
||
namespace TagsCloudVisualization.Visualizers; | ||
|
||
public class CartesianTagVisualizer(IColorFactory colorFactory, Size imageSize) : ITagVisualizer | ||
{ | ||
private readonly Point _centerOffset = new Point(imageSize.Width / 2, imageSize.Height / 2); | ||
private readonly Size _imageSize = imageSize; | ||
|
||
public Bitmap Visualize(IEnumerable<Tag> tags) | ||
{ | ||
var bitmap = new Bitmap(_imageSize.Width, _imageSize.Height); | ||
using var graphics = Graphics.FromImage(bitmap); | ||
|
||
foreach (var tag in tags) | ||
{ | ||
var brush = new SolidBrush(colorFactory.GetColor()); | ||
var font = new Font(tag.FontFamily, tag.FontSize); | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Эти штуки тоже |
||
var rectangle = tag.Rectangle; | ||
rectangle.Offset(_centerOffset); | ||
|
||
graphics.DrawString(tag.Content, font, brush, tag.Rectangle); | ||
} | ||
|
||
return bitmap; | ||
} | ||
} |
This file was deleted.
Oops, something went wrong.
23 changes: 10 additions & 13 deletions
23
TagsCloudVisualization/WordsHandlers/BoringWordsHandler.cs
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,20 +1,17 @@ | ||
using DeepMorphy; | ||
|
||
namespace TagsCloudVisualization.WordsHandlers; | ||
|
||
public class BoringWordsHandler(Mystem.Net.Mystem mystem) : IWordHandler | ||
public class BoringWordsHandler : IWordHandler | ||
{ | ||
private static readonly MorphAnalyzer Analyzer = new(); | ||
private static readonly HashSet<string> CorrectSpeechParts = ["сущ", "инф_гл", "прил", "деепр"]; | ||
|
||
public IEnumerable<string> Handle(IEnumerable<string> words) | ||
{ | ||
foreach (var word in words) | ||
{ | ||
var lemma = mystem.Mystem.Analyze(word).Result![0]; | ||
|
||
var grammeme = lemma.AnalysisResults.First().Grammeme!; | ||
var speechPart = grammeme[..grammeme.IndexOf(',')]; | ||
|
||
if (speechPart != "S" && speechPart != "V") | ||
continue; | ||
|
||
yield return word; | ||
} | ||
return Analyzer | ||
.Parse(words) | ||
.Where(x => CorrectSpeechParts.Contains(x["чр"].BestGramKey)) | ||
.Select(x => x.Text); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,4 +1,5 @@ | ||
<wpf:ResourceDictionary xml:space="preserve" xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml" xmlns:s="clr-namespace:System;assembly=mscorlib" xmlns:ss="urn:shemas-jetbrains-com:settings-storage-xaml" xmlns:wpf="http://schemas.microsoft.com/winfx/2006/xaml/presentation"> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=archimedean/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=layouter/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=layouters/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=layouters/@EntryIndexedValue">True</s:Boolean> | ||
<s:Boolean x:Key="/Default/UserDictionary/Words/=_0434_0435_0435_043F_0440/@EntryIndexedValue">True</s:Boolean></wpf:ResourceDictionary> |
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Не обработал кейс, когда словарь не смогли подгрузить, надо пользователю сказать, что не так и что нужно сделать