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

Reolução exercício oportunidade #70

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file not shown.

Large diffs are not rendered by default.

Binary file not shown.
Binary file not shown.
Binary file not shown.
Binary file not shown.
79 changes: 79 additions & 0 deletions MinutoSeguradoraOportunidade/MinutoSeguradoraOportunidade.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,79 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.29806.167
MinimumVisualStudioVersion = 10.0.40219.1
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Domain", "Domain", "{EFC553B6-8BB9-45C2-B158-09123F98B3F6}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Service", "Service", "{80F9A540-B8B7-4248-AAFB-B6CC9C1EDDED}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Infrastructure", "Infrastructure", "{C5DCB809-380B-48D9-8206-BDBB55CFA0DB}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Interface", "Interface", "{7165634D-F412-49EF-A8B8-DC568A7F8533}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "Test", "Test", "{DAEA2212-C779-4BA9-9A32-FC8C85DA0097}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinutoSeguradoraOportunidade.Domain", "src\MinutoSeguradoraOportunidade.Domain\MinutoSeguradoraOportunidade.Domain.csproj", "{00D6740E-9098-4A03-850E-AF61587110C8}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinutoSeguradoraOportunidade.Interface.Console", "src\MinutoSeguradoraOportunidade.Interface.Console\MinutoSeguradoraOportunidade.Interface.Console.csproj", "{C474D624-DDDE-4523-A899-B33235D4C694}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinutoSeguradoraOportunidade.Service", "src\MinutoSeguradoraOportunidade.Service\MinutoSeguradoraOportunidade.Service.csproj", "{2C09EF2C-B3B7-4130-B624-AE6D3B51C7D3}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinutoSeguradoraOportunidade.Tests.MSTest", "tests\MinutoSeguradoraOportunidade.Tests.MSTest\MinutoSeguradoraOportunidade.Tests.MSTest.csproj", "{257BEA40-6938-4DA3-A083-A6132FE3625D}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "IoC", "IoC", "{7C680F62-0CAF-4EBE-ADFB-FDAE21656375}"
EndProject
Project("{2150E333-8FDC-42A3-9474-1A3956D46DE8}") = "RSS", "RSS", "{C7D55725-F10D-4417-9BEB-51962595D09E}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinutoSeguradoraOportunidade.Infrastructure.IoC", "src\MinutoSeguradoraOportunidade.Infrastructure.IoC\MinutoSeguradoraOportunidade.Infrastructure.IoC.csproj", "{BEF37E90-55B2-4996-8A2C-6CBC604C4705}"
EndProject
Project("{9A19103F-16F7-4668-BE54-9A1E7A4F7556}") = "MinutoSeguradoraOportunidade.Infrastructure.RSS", "src\MinutoSeguradoraOportunidade.Infrastructure.RSS\MinutoSeguradoraOportunidade.Infrastructure.RSS.csproj", "{82C8B334-E036-4C61-9C6A-EBE37DB457C7}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{00D6740E-9098-4A03-850E-AF61587110C8}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{00D6740E-9098-4A03-850E-AF61587110C8}.Debug|Any CPU.Build.0 = Debug|Any CPU
{00D6740E-9098-4A03-850E-AF61587110C8}.Release|Any CPU.ActiveCfg = Release|Any CPU
{00D6740E-9098-4A03-850E-AF61587110C8}.Release|Any CPU.Build.0 = Release|Any CPU
{C474D624-DDDE-4523-A899-B33235D4C694}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{C474D624-DDDE-4523-A899-B33235D4C694}.Debug|Any CPU.Build.0 = Debug|Any CPU
{C474D624-DDDE-4523-A899-B33235D4C694}.Release|Any CPU.ActiveCfg = Release|Any CPU
{C474D624-DDDE-4523-A899-B33235D4C694}.Release|Any CPU.Build.0 = Release|Any CPU
{2C09EF2C-B3B7-4130-B624-AE6D3B51C7D3}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{2C09EF2C-B3B7-4130-B624-AE6D3B51C7D3}.Debug|Any CPU.Build.0 = Debug|Any CPU
{2C09EF2C-B3B7-4130-B624-AE6D3B51C7D3}.Release|Any CPU.ActiveCfg = Release|Any CPU
{2C09EF2C-B3B7-4130-B624-AE6D3B51C7D3}.Release|Any CPU.Build.0 = Release|Any CPU
{257BEA40-6938-4DA3-A083-A6132FE3625D}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{257BEA40-6938-4DA3-A083-A6132FE3625D}.Debug|Any CPU.Build.0 = Debug|Any CPU
{257BEA40-6938-4DA3-A083-A6132FE3625D}.Release|Any CPU.ActiveCfg = Release|Any CPU
{257BEA40-6938-4DA3-A083-A6132FE3625D}.Release|Any CPU.Build.0 = Release|Any CPU
{BEF37E90-55B2-4996-8A2C-6CBC604C4705}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{BEF37E90-55B2-4996-8A2C-6CBC604C4705}.Debug|Any CPU.Build.0 = Debug|Any CPU
{BEF37E90-55B2-4996-8A2C-6CBC604C4705}.Release|Any CPU.ActiveCfg = Release|Any CPU
{BEF37E90-55B2-4996-8A2C-6CBC604C4705}.Release|Any CPU.Build.0 = Release|Any CPU
{82C8B334-E036-4C61-9C6A-EBE37DB457C7}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{82C8B334-E036-4C61-9C6A-EBE37DB457C7}.Debug|Any CPU.Build.0 = Debug|Any CPU
{82C8B334-E036-4C61-9C6A-EBE37DB457C7}.Release|Any CPU.ActiveCfg = Release|Any CPU
{82C8B334-E036-4C61-9C6A-EBE37DB457C7}.Release|Any CPU.Build.0 = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(NestedProjects) = preSolution
{00D6740E-9098-4A03-850E-AF61587110C8} = {EFC553B6-8BB9-45C2-B158-09123F98B3F6}
{C474D624-DDDE-4523-A899-B33235D4C694} = {7165634D-F412-49EF-A8B8-DC568A7F8533}
{2C09EF2C-B3B7-4130-B624-AE6D3B51C7D3} = {80F9A540-B8B7-4248-AAFB-B6CC9C1EDDED}
{257BEA40-6938-4DA3-A083-A6132FE3625D} = {DAEA2212-C779-4BA9-9A32-FC8C85DA0097}
{7C680F62-0CAF-4EBE-ADFB-FDAE21656375} = {C5DCB809-380B-48D9-8206-BDBB55CFA0DB}
{C7D55725-F10D-4417-9BEB-51962595D09E} = {C5DCB809-380B-48D9-8206-BDBB55CFA0DB}
{BEF37E90-55B2-4996-8A2C-6CBC604C4705} = {7C680F62-0CAF-4EBE-ADFB-FDAE21656375}
{82C8B334-E036-4C61-9C6A-EBE37DB457C7} = {C7D55725-F10D-4417-9BEB-51962595D09E}
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {26958C50-7034-4229-8CC8-4F01F802ED0D}
EndGlobalSection
EndGlobal
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace MinutoSeguradoraOportunidade.Domain.Entities
{
public class Channel
{
public string Title { get; private set; }
public Link Links { get; private set; }
public string Link { get; private set; }
public string Description { get; private set; }
public string LastBuildDate { get; private set; }
public string Language { get; private set; }
public string UpdatePeriod { get; private set; }
public string UpdateFrequency { get; private set; }
public string Generator { get; private set; }
public List<Item> Itens { get; private set; }

public Channel(string title, Link links, string link, string description,
string lastBuildDate, string language, string updatedPeriod,
string generator, List<Item> itens)
{
this.Title = title;
this.Links = links;
this.Link = link;
this.Description = description;
this.LastBuildDate = lastBuildDate;
this.Language = language;
this.UpdatePeriod = updatedPeriod;
this.Generator = generator;
this.Itens = itens;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,18 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace MinutoSeguradoraOportunidade.Domain.Entities
{
public class Guid
{
public string IsPermaLink { get; private set; }
public string Text { get; private set; }

public Guid(string isPermaLink, string text)
{
this.IsPermaLink = isPermaLink;
this.Text = text;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,35 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace MinutoSeguradoraOportunidade.Domain.Entities
{
public class Item
{
public string Title { get; private set; }
public string Link { get; private set; }
public List<string> Comments { get; private set; }
public string PubDate { get; private set; }
public string Creator { get; private set; }
public List<string> Category { get; private set; }
public Guid Guid { get; private set; }
public string Description { get; private set; }
public string Encoded { get; private set; }
public string CommentRss { get; private set; }

public Item(string title, string link, List<string> comments, string pubDate, string creator,
List<string> category, Guid guid, string description, string encoded, string commentRss)
{
this.Title = title;
this.Link = link;
this.Comments = comments;
this.PubDate = pubDate;
this.Creator = creator;
this.Category = category;
this.Guid = guid;
this.Description = description;
this.Encoded = encoded;
this.CommentRss = commentRss;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace MinutoSeguradoraOportunidade.Domain.Entities
{
public class Link
{
public string Href { get; private set; }
public string Rel { get; private set; }
public string Type { get; private set; }

public Link(string href, string rel, string type)
{
this.Href = href;
this.Rel = rel;
this.Type = type;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,42 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace MinutoSeguradoraOportunidade.Domain.Entities.Palavras
{
public class Artigos
{
private static string[] _artigos =
{
"a", "as", "o", "os", "uma", "umas", "um", "uns"
};

public string Artigo { get; private set; }

public Artigos(string artigo)
{
this.Artigo = artigo;
}

public static bool EhArtigo(string palavra)
{
if (_artigos.Contains(palavra.ToLower()))
{
return true;
}

return false;
}

public static bool EhArtigo(Artigos palavra)
{
if (_artigos.Contains(palavra.Artigo.ToLower()))
{
return true;
}

return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,72 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Text.RegularExpressions;
using System.Linq;

namespace MinutoSeguradoraOportunidade.Domain.Entities.Palavras
{
public class Palavras
{
private string _conteudo;
private List<Palavras> _palavras = new List<Palavras>();
private List<string> _palavrasJaListadas = new List<string>();

public string Palavra { get; private set; }
public int Quantidade { get; private set; }
public List<Palavras> OcorrenciaPalavras => this._palavras.OrderByDescending(p => p.Quantidade).ToList();

public Palavras(string conteudo)
{
this._conteudo = conteudo;

this.ListarPalavras();
}

private Palavras(string palavra, int quantidade)
{
this.Palavra = palavra;
this.Quantidade = quantidade;
}

private void ListarPalavras()
{
this.LimparTags();
this.LimparPontuacao();

var palavras = this._conteudo.Split(" ");

foreach (var palavra in palavras)
{
if (!Artigos.EhArtigo(palavra) && !Preposicoes.EhPreposicao(palavra))
{
if (this._palavrasJaListadas.Contains(palavra.ToLower()))
{
var ocorrencia = this._palavras.Where(p => p.Palavra == palavra.ToLower()).FirstOrDefault();
var nOcorrencia = new Palavras(ocorrencia.Palavra.ToLower(), ocorrencia.Quantidade + 1);

this._palavras.Remove(ocorrencia);
this._palavras.Add(nOcorrencia);
}
else
{
var nOcorrencia = new Palavras(palavra.ToLower(), 1);

this._palavras.Add(nOcorrencia);
this._palavrasJaListadas.Add(palavra.ToLower());
}
}
}
}

private void LimparTags()
{
this._conteudo = Regex.Replace(this._conteudo, "<.*?>", string.Empty);
}

private void LimparPontuacao()
{
this._conteudo = this._conteudo.Replace(",", "").Replace(".", "").Replace(";", "").Replace("!", "!").Replace("?", "").Replace(":", "").Replace(@"/", "").Replace(@"\", "").Replace("(", "").Replace(")", "");
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
using System;
using System.Collections.Generic;
using System.Text;
using System.Linq;

namespace MinutoSeguradoraOportunidade.Domain.Entities.Palavras
{
public class Preposicoes
{
private static string[] _preoposicoes =
{
"a", "ante", "após", "até", "com", "contra", "de", "desde", "em", "entre", "para", "por", "perante",
"sem", "sob", "sobre", "trás", "afora", "como", "conforme", "consoante", "durante", "exceto",
"feito", "fora", "mediante", "menos", "salvo", "segundo", "senão", "tirante", "visto", "do",
"duma", "à", "àquele", "aquele", "duma", "disto", "nas", "num", "nessa", "pelo", "pelas",
"ao", "aos", "aonde"
};

public string Prepocisao { get; private set; }

public Preposicoes(string preposicao)
{
this.Prepocisao = preposicao;
}

public static bool EhPreposicao(string palavra)
{
if (_preoposicoes.Contains(palavra.ToLower()))
{
return true;
}

return false;
}

public static bool EhPreposicao(Preposicoes palavra)
{
if (_preoposicoes.Contains(palavra.Prepocisao.ToLower()))
{
return true;
}

return false;
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,31 @@
using System;
using System.Collections.Generic;
using System.Text;

namespace MinutoSeguradoraOportunidade.Domain.Entities
{
public class RSS
{
public Channel Channel { get; private set; }
public string Version { get; private set; }
public string Content { get; private set; }
public string Wfw { get; private set; }
public string Dc { get; private set; }
public string Atom { get; private set; }
public string Sy { get; private set; }
public string Slash { get; private set; }

public RSS(Channel channel, string version, string content, string wfw,
string dc, string atom, string sy, string slash)
{
this.Channel = channel;
this.Version = version;
this.Content = content;
this.Wfw = wfw;
this.Dc = dc;
this.Atom = atom;
this.Sy = sy;
this.Slash = slash;
}
}
}
Loading