met behulp van System; met behulp van System.Collections.Generic; met behulp van System.Linq; gebruik van System.Text; gebruik van System.Threading.Tasks; met behulp van PanGu.Dict; met behulp van PanGu.Framework; met behulp van PanGu.Match; met behulp van PanGu.Setting; met behulp van PanGu.HighLight; met behulp van Lucene.Net.Analysis; met System.IO; met behulp van PanGu; gebruikmakend van System.Configuration;
naamruimte Pangu.Helper
{ openbare klasse PanguHelper {
privé vluchtige statische PanguHelper _instance = nul; privé statisch alleen-lezen object lockHelper = nieuw object(); private PanguHelper() { }
/// <summary> [Standaard gebruikt pangu.xml profiel onder hetzelfde pad] /// </summary> /// <returns></returns> publieke statische PanguHelper DeelHelper { Toevoegen { als (_instance == nul) { slot (lockHelper) { als (_instance == nul) { _instance = nieuwe PanguHelper(); string configFile = ConfigurationManager.AppSettings["PANGU_CONFIG"] + ""; if (configFile != "") { _instance. Use(configFile); } } } }
Geef _instance terug; } }
/// <summary> Initialiseer het opgegeven configuratiebestand /// </summary> <param name="configFile"> pangu configuratiebestand</param> public void Use(string configFile) { PanGu.Segment.Init(configFile); }
/// <summary> Vraag een woordsoort beschrijving op /// </summary> <param naam="pos"> woordsoortopsomming</param> /// <returns></returns> publieke string GetPosDescrip{filter}t(POS pos) { Schakelaar (POS) { zaak POS. POS_UNK: retourneer "onbekende woordsoort;" zaak POS. POS_D_K: retourneren "trailing component"; zaak POS. POS_D_H: retourneren "voorgaande component"; zaak POS. POS_A_NZ: retourneren "andere eigennaam"; zaak POS. POS_A_NX: retourneren "buitenlands personage"; zaak POS. POS_A_NR: geef "naam van de persoon" terug; zaak POS. POS_D_Z: retourneer "statuswoord"; zaak POS. POS_A_NT: teruggeven "lichaam van instellingen"; zaak POS. POS_A_NS: geef "plaatsnaam" terug; zaak POS. POS_D_Y: retourneren "stemmingswoord stemmingsmorfeem"; zaak POS. POS_D_X: retourneren "niet-morfemisch woord"; zaak POS. POS_D_W: retourneren "interpunctie"; zaak POS. POS_D_T: retourneren "woord van tijd"; zaak POS. POS_D_S: retourneren "plaatswoord"; zaak POS. POS_D_V: retourneren "werkwoordmorfeem"; zaak POS. POS_D_U: retourneren "deeltjedeeltjesmorfeem"; zaak POS. POS_D_R: retour "voornaamwoordvoornaamwoordmorfeem"; zaak POS. POS_A_Q: retourneren "quantifier quantifier morpheem"; zaak POS. POS_D_P: retour "voorzetsel"; zaak POS. POS_D_MQ: retour "quantifier"; zaak POS. POS_A_M: retourneren "cijfer, cijfer, cijfer"; zaak POS. POS_D_O: retour "onomatopee"; zaak POS. POS_D_N: terugbrengen "zelfstandig naamwoordmorfeem"; zaak POS. POS_D_F: retourneren "azimutwoord azimut morfeem"; zaak POS. POS_D_E: retourneren "interjectiemorfeem"; zaak POS. POS_D_L: geef "idioom" terug; zaak POS. POS_D_I: retour "idioom"; zaak POS. POS_D_D: retourneren "bijwoord, bijwoord, bijwoord, morfeem"; zaak POS. POS_D_C: retourneren "conjunctieve conjunctiemorfeem"; zaak POS. POS_D_B: return "om woorden te onderscheiden om morfemen te onderscheiden"; zaak POS. POS_D_A: retourneren "bijvoeglijk naamwoord morfeem"; } retour "onbekend woordsoort"; }
/// <summary> Krijg het deelwoord [Originele Wordinfo] /// </summary> <param naam="inhoud"> de inhoud van het te scheiden woord</param> <param name="matchOptions"> gebruik de matchopties</param> <param name="matchParameter"> gebruik de match-parameter</param> /// <returns></returns> publieke ICollection<WordInfo> GetSegmentWords(string-inhoud, MatchOptions matchOptions = null, MatchParameter matchParameter = null) { Segmentsegment = nieuw segment(); ICollectionwoorden<WordInfo> = segment. DoSegment (content, matchOptions, matchParameter); Beantwoord woorden; }
/// <summary> Leer deelwoorden /// </summary> <param naam="inhoud"> de inhoud van het te scheiden woord</param> <param name="matchOptions"> Matchopties worden niet standaard gebruikt</param> <param name="matchParameter" > gebruik de bijbehorende parameter, niet standaard</param> publieke lijst<string> GetSplitWords (stringinhoud, MatchOptions matchOptions = null, MatchParameter matchParameter = null) { Segmentsegment = nieuw segment(); ICollectionwoorden<WordInfo> = segment. DoSegment(content,matchOptions,matchparameter); Lijstlijst<string> = nieuwe Lijst<string>(); foreach (WordInfo woord in woorden) { lijst. Add(word. Word); } retourlijst; }
/// <summary> Verkrijg het deelwoord van de opgegeven woordfrequentie /// </summary> <param naam="inhoud"> de inhoud van het te scheiden woord</param> <param naam="frequentie"> woordfrequentie</param> <param name="matchOptions"> Matchopties worden niet standaard gebruikt</param> <param name="matchParameter" > gebruik de bijbehorende parameter, niet standaard</param> /// <returns></returns> publieke lijst<string> GetSplitWordsByFrequency(stringinhoud, dubbele frequentie, MatchOptions matchOptions = null, MatchParameter matchParameter = null) { Segmentsegment = nieuw segment(); ICollectionwoorden<WordInfo> = segment. DoSegment (content, matchOptions, matchParameter);
Lijstlijst<string> = nieuwe Lijst<string>(); foreach (WordInfo woord in woorden) { als (frequentie == woord. Frequentie) { lijst. Add(word. Word); } } retourlijst; }
/// <summary> Krijg een deelwoord met een bepaald gewicht /// </summary> <param naam="inhoud"> de inhoud van het te scheiden woord</param> <param naam="rang"> gewicht</param> <param name="matchOptions"> Matchopties worden niet standaard gebruikt</param> <param name="matchParameter" > gebruik de bijbehorende parameter, niet standaard</param> /// <returns></returns> publieke lijst<string> GetSplitWordsByRank(stringinhoud, int rank, MatchOptions matchOptions = null, MatchParameter matchParameter = null) { Segmentsegment = nieuw segment(); ICollectionwoorden<WordInfo> = segment. DoSegment (content, matchOptions, matchParameter);
Lijstlijst<string> = nieuwe Lijst<string>(); foreach (WordInfo woord in woorden) { als (rang == woord. Rang) { lijst. Add(word. Word); } } retourlijst; }
/// <summary> Hoogtepunt /// </summary> <param name="keyword"> de string om te markeren</param> <param name="content">content</param> <param name="fragmentSize"> het aantal tekens voor elk samenvattingsveld</param> <returns>Gemarkeerde inhoud</returns> publieke statische string HighLight (string keyword, string content, int fragmentSize) { Maak een HTML-code aan met de parameter die de zoekterm markeert SimpleHTMLFormatter simpleHTMLFormatter = nieuwe SimpleHTMLFormatter("<font color='red'>", "</font>"); Maak markeringen, voer HTML-code in en Pangu-object Semgent Highlighter hoger = nieuwe highlighter(simpleHTMLFormatter, nieuwe Segment()); Stel het aantal tekens in voor elk samenvattingsveld hoger. FragmentSize = FragmentSize; string highlightStr = hoger. GetBestFragment (trefwoord, inhoud);
als (string. IsNullOrEmpty(highlightStr)) { return content; } terugkeer hoogtepuntStr; }
}
}
|