programing

복잡한 콘텐츠 필터를 작성하는 가장 효율적인 방법은 무엇입니까?

i4 2023. 3. 7. 21:05
반응형

복잡한 콘텐츠 필터를 작성하는 가장 효율적인 방법은 무엇입니까?

얼마 전, 저는 제 웹사이트의 콘텐츠 필터에 대해 상당히 긴 질문을 했습니다.투고는 이쪽에서 찾을 수 있으므로, 천천히 읽어 주세요.

@DampeS8N의 답변은 잘 대답하고 올바른 방향으로 보내주셔서 받아 들였습니다.

유감스럽게도 이 질문의 결과는 사용하고 있는 콘텐츠필터가 너무 비효율적이어서 어플리케이션의 컨텍스트에서 실행할 수 없다는 것입니다.

정보는 다음과 같습니다.

  • 용어집**과 1200종 이상의 프로파일을 가지고 있습니다**
  • 이러한 투고의 제목(용어 엔트리) 또는 학명(종 프로파일)이 필터의 검색어를 구성합니다.
  • 내 종 프로필의 내용을 필터링하고(가능한 한 저장 시, cron 작업을 통해 수행될 수 있음) 위의 검색어를 검색하여 관련 용어집 항목 또는 종 프로필에 대한 링크로 대체합니다.

*용어집 항목은 여기에서 찾을 수 있습니다.

용어집 엔트리의 예는 다음과 같습니다.caudal fin,dorsal,filter 등등.

**여기서 종족 프로파일을 찾을 수 있습니다.

, 종 「종이다」라고 하는 것이 있습니다.Apistogramma panduro,A. panduro,Dario dario,D. dario,Betta sp. 'Maha Chai'syslog.

문제는 다음과 같습니다.

  • CMS는 WordPress에 의해 구동됩니다.내 종족의 구조를 이해하는 것 말고는 이 포스트와 특별히 관련이 있는 건 아니야
  • 내 종족 프로파일은 몇 가지 기본적인 정보들로 이루어져 있다.wp_posts, 에 저장된 추가 정보wp_postmetatable.syslog를 클릭합니다.
  • 종의 대부분의 되어 있다.meta fields에의 엔트리입니다.wp_postmeta아래 표에 나와 있습니다.

http://www.seriouslyfish.com/species/puntius-sahyadriensis/

wp_postmeta

INSERT INTO `wp_postmeta` (`meta_id`, `post_id`, `meta_key`, `meta_value`) VALUES
(104395, 2288, 'genus', '<em>Puntius</em>'),
(104396, 2288, 'species', '<em>sahyadriensis</em>'),
(104397, 2288, 'family', 'Cyprinidae'),
(104398, 2288, 'common_names', ''),
(104399, 2288, 'distribution', '<a class="link_glossary" href="/glossary/e/endemic" rel="/glossary/e/endemic?hover=true">Endemic</a> to streams of the Yenna <a class="link_glossary" href="/glossary/r/river%20basin" rel="/glossary/r/river%20basin?hover=true">river basin</a> close to the city of Mahabaleshwar in the Western Ghats mountain range, Satara district, Maharashtra state, India.'),
(104400, 2288, 'habitat', 'The <a class="link_glossary" href="/glossary/r/river" rel="/glossary/r/river?hover=true">river</a> Yenna flows through lush evergreen forest meaning the hill streams in which the fish can be found are likely to be shaded by the forest canopy and dense <a class="link_glossary" href="/glossary/m/marginal" rel="/glossary/m/marginal?hover=true">marginal</a> vegetation. Substrates should be composed of boulders, smaller stones, <a class="link_glossary" href="/glossary/s/sand" rel="/glossary/s/sand?hover=true">sand</a> or <a class="link_glossary" href="/glossary/g/gravel" rel="/glossary/g/gravel?hover=true">gravel</a> with submerged tree roots around the margins and quieter areas in which fallen branches and leaf litter collect. As with similar members of the <a class="link_glossary" href="/glossary/g/genus" rel="/glossary/g/genus?hover=true">genus</a> it is likely to congregate in <a class="link_glossary" href="/glossary/b/backwater" rel="/glossary/b/backwater?hover=true">backwater</a> pools or deeper areas with lower flow.'),
(104402, 2288, 'max_size', 'Around 2.75"/7cm.'),
(104403, 2288, 'aquarium_size', 'It is an active <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> and a <a class="link_glossary" href="/glossary/t/tank" rel="/glossary/t/tank?hover=true">tank</a> measuring at least 36" x 12" x 12"/90cm x 30cm x 30cm/85 litres is needed to house a group.'),
(104404, 2288, 'maintenance', 'Choice of decor is not as critical as water quality and the amount of swimming-space provided. We suggest keeping it in a roomy, well-planted <a class="link_glossary" href="/glossary/a/aquarium" rel="/glossary/a/aquarium?hover=true">aquarium</a> or alternatively it would look superb in a set-up designed to resemble a flowing <a class="link_glossary" href="/glossary/r/river" rel="/glossary/r/river?hover=true">river</a> with a <a class="link_glossary" href="/glossary/s/substrate" rel="/glossary/s/substrate?hover=true">substrate</a> of variably-sized rocks and <a class="link_glossary" href="/glossary/g/gravel" rel="/glossary/g/gravel?hover=true">gravel</a> and some large water-worn boulders. A rivertank manifold could also be constructed to provide naturalistic unidirectional flow. The <a class="link_glossary" href="/glossary/t/tank" rel="/glossary/t/tank?hover=true">tank</a> can be further furnished with driftwood branches and <a class="link_glossary" href="/glossary/a/aquatic" rel="/glossary/a/aquatic?hover=true">aquatic</a> plants for aesthetic value. While the vast majority of plant <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> will fail to thrive in such conditions possibilities include hardy <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> such as Java fern, <em>Bolbitis</em> or <em>Anubias</em> <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> which can be grown attached to the decor. Like many other <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> that hail from pristine natural environments it is intolerant to the accumulation of <a class="link_glossary" href="/glossary/o/organic" rel="/glossary/o/organic?hover=true">organic</a> wastes and requires spotless water at all times in order to thrive.'),
(104405, 2288, 'water_chemistry', '<strong>Temperature</strong>: Prefers slightly cool conditions within the range 20 - 24°C/68 - 75°C. Higher temperatures are known to stimulate spawning with an associated increase of aggression in males.\r\n\r\n<strong>pH</strong>: 6.8 - 7.8\r\n\r\n<strong>Hardness</strong>: 5 - 15°H'),
(104406, 2288, 'diet', 'Likely to feed on small invertebrates, <a class="link_glossary" href="/glossary/a/algae" rel="/glossary/a/algae?hover=true">algae</a> and other <a class="link_glossary" href="/glossary/z/zooplankton" rel="/glossary/z/zooplankton?hover=true">zooplankton</a> in nature. In the <a class="link_glossary" href="/glossary/a/aquarium" rel="/glossary/a/aquarium?hover=true">aquarium</a> it will accept dried foods of a suitable size but should not be fed these exclusively. Daily meals of small live and frozen fare such as <em><a class="link_glossary" href="/glossary/D/Daphnia" rel="/glossary/D/Daphnia?hover=true">Daphnia</a></em>, <em><a class="link_glossary" href="/glossary/A/Artemia" rel="/glossary/A/Artemia?hover=true">Artemia</a></em> and suchlike will result in the best colouration and encourage the fish to come into breeding condition.'),
(104407, 2288, 'behaviour', 'Not an aggressive fish but best kept with other hillstream-dwelling <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> such as <em>Danio</em>, <em>Devario</em>, other small <em>Puntius</em>, <em>Garra</em> and balitorid loaches. That said provided its oxygen and temperature requirements can be met it can be mixed with most peaceful fish too large to be considered food. A <a class="link_glossary" href="/glossary/b/biotope" rel="/glossary/b/biotope?hover=true">biotope</a>-style <a class="link_glossary" href="/glossary/c/community" rel="/glossary/c/community?hover=true">community</a> based around <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> from hill streams of the Western Ghats would also make an interesting project with <em><a class="link_species" href="/species/puntius-filamentosus" rel="/species/puntius-filamentosus/?hover=true">Puntius filamentosus</a></em>, <em><a class="link_species" href="/species/puntius-fasciatus" rel="/species/puntius-fasciatus/?hover=true">P. fasciatus</a></em>, <em><a class="link_species" href="/species/puntius-narayani" rel="/species/puntius-narayani/?hover=true">P. narayani</a></em>, <em><a class="link_species" href="/species/puntius-ticto" rel="/species/puntius-ticto/?hover=true">P. ticto</a></em>, <em>Barilius bakeri</em>, <em>B. canarensis</em>, <em><a class="link_species" href="/speciesario-aequipinnatus" rel="/speciesario-aequipinnatus/?hover=true">Devario aequipinnatus</a></em>, <em><a class="link_species" href="/speciesario-malabaricus" rel="/speciesario-malabaricus/?hover=true">D. malabaricus</a></em>, <em>Rasbora daniconius</em>, <em>Laubuca laubuca</em>, <em>Nemacheilus rupelli</em>, <em>Mesonemacheilus triangularis</em> and <em><a class="link_species" href="/species/mesonoemacheilus-guentheri" rel="/species/mesonoemacheilus-guentheri/?hover=true">M. guentheri</a></em> among the numerous suitable <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> available in the trade at times.\r\n\r\nIt''s a shoaling <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> by nature and really should be kept in a group of at least 8-10 specimens. Maintaining it in decent numbers will not only make the fish less nervous but will result in a more effective, natural-looking display while allowing individuals some respite from the vigorous alpha male(s). Males will also display their best colours and some interesting behaviour as they compete with one other for female attention. In particular the dominant individual in a given group will develop some stunning colouration.'),
(104408, 2288, 'dimorphism', 'The male is noticeably slimmer and more brightly coloured than the female especially when the fish are in <a class="link_glossary" href="/glossary/s/spawning" rel="/glossary/s/spawning?hover=true">spawning</a> condition. Most notably the body colouration is more intense, <a class="link_glossary" href="/glossary/v/ventral" rel="/glossary/v/ventral?hover=true">ventral</a> fins tipped with white, other finnage redder and prominent tubercules develop around the <a class="link_glossary" href="/glossary/s/snout" rel="/glossary/s/snout?hover=true">snout</a> and head in sexually <a class="link_glossary" href="/glossary/m/mature" rel="/glossary/m/mature?hover=true">mature</a> specimens.'),
(104409, 2288, 'reproduction', 'We''re not sure if it has been bred in the hobby although it should certainly be possible. Like most cyprinids this <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> is an <a class="link_glossary" href="/glossary/e/egg" rel="/glossary/e/egg?hover=true">egg</a>-scattering, continuous spawner that exhibits no <a class="link_glossary" href="/glossary/p/parental%20care" rel="/glossary/p/parental%20care?hover=true">parental care</a>. That is to say when the fish are in good condition they will <a class="link_glossary" href="/glossary/s/spawn" rel="/glossary/s/spawn?hover=true">spawn</a> often and in a well-furnished, <a class="link_glossary" href="/glossary/m/mature" rel="/glossary/m/mature?hover=true">mature</a> <a class="link_glossary" href="/glossary/a/aquarium" rel="/glossary/a/aquarium?hover=true">aquarium</a> it is feasible that small numbers of <a class="link_glossary" href="/glossary/f/fry" rel="/glossary/f/fry?hover=true">fry</a> may start to appear without human intervention.\r\n\r\nHowever if you want to increase the yield of <a class="link_glossary" href="/glossary/f/fry" rel="/glossary/f/fry?hover=true">fry</a> a slightly more controlled approach is required and we suggest using an approach that has proven successful for similar members of the <a class="link_glossary" href="/glossary/g/genus" rel="/glossary/g/genus?hover=true">genus</a> as a starting point. The adult group can still be conditioned together but one or more small, say 18" x 10" x 10"/45cm x 25cm x 25cm/29.5 <a class="link_glossary" href="/glossary/l/litre" rel="/glossary/l/litre?hover=true">litre</a> containers should also be set up and half-filled with water. These should be very dimly lit with the <a class="link_glossary" href="/glossary/b/base" rel="/glossary/b/base?hover=true">base</a> either left bare or covered with some kind of mesh of a large enough grade so that any eggs that fail to adhere to the plant can pass through but small enough so that the adults cannot reach them. The widely available plastic ''grass''-<a class="link_glossary" href="/glossary/t/type" rel="/glossary/t/type?hover=true">type</a> matting can also be used and works very well. A decent-sized clump of Java moss or other fine-leaved plant should also be added filling perhaps half the available space. The water should be around <a class="link_glossary" href="/glossary/n/neutral" rel="/glossary/n/neutral?hover=true">neutral</a> <a class="link_glossary" href="/glossary/p/pH" rel="/glossary/p/pH?hover=true">pH</a>, <a class="link_glossary" href="/glossary/G/GH" rel="/glossary/G/GH?hover=true">gH</a> &lt;8, with a slightly raised temperature of 75 - 80°F. A small air-powered <a class="link_glossary" href="/glossary/s/sponge%20filter" rel="/glossary/s/sponge%20filter?hover=true">sponge filter</a> bubbling away very gently is all that is needed in terms of filtration.\r\n\r\nWhen the adult fish are well-conditioned and the females appear full of eggs a single <a class="link_glossary" href="/glossary/p/pair" rel="/glossary/p/pair?hover=true">pair</a> should then be introduced to each container. If conditions are to their liking they should <a class="link_glossary" href="/glossary/s/spawn" rel="/glossary/s/spawn?hover=true">spawn</a> the following morning. Be sure to provide plenty of cover for the female as the male may be quite aggressive in his pursuit of her. In some cases she might even require a period of post-<a class="link_glossary" href="/glossary/s/spawning" rel="/glossary/s/spawning?hover=true">spawning</a> rehabilitation in a <a class="link_glossary" href="/glossary/t/tank" rel="/glossary/t/tank?hover=true">tank</a> that does not contain any males.\r\n\r\nThe adults will eat the eggs given the chance and should be removed as soon as any are noticed. Incubation in <em>Puntius</em> eggs is temperature-dependant to an extent but usually takes between 20 and 48 hours with the young free-swimming 24 to 48 hours later. Initial food should be <em>Paramecium</em> or similar introducing <em><a class="link_glossary" href="/glossary/A/Artemia" rel="/glossary/A/Artemia?hover=true">Artemia</a></em> <a class="link_glossary" href="/glossary/n/nauplii" rel="/glossary/n/nauplii?hover=true">nauplii</a> and/or <a class="link_glossary" href="/glossary/m/microworm" rel="/glossary/m/microworm?hover=true">microworm</a> once the <a class="link_glossary" href="/glossary/f/fry" rel="/glossary/f/fry?hover=true">fry</a> are large enough to accept them.'),
(104410, 2288, 'misc_notes', 'This beautiful <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> is not often seen in the hobby, presumably as a result of its limited distribution, and tends to command a relatively high price when available. It may be seen on sale under the trade names ''Maharaja'' or ''Khavli'' <a class="link_glossary" href="/glossary/b/barb" rel="/glossary/b/barb?hover=true">barb</a>.\r\n\r\nThe <a class="link_glossary" href="/glossary/g/genus" rel="/glossary/g/genus?hover=true">genus</a> <em>Puntius</em> is currently viewed as something of a catch-all for well over 100 <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> of small cyprinid. Most experts agree that a full <a class="link_glossary" href="/glossary/r/revision" rel="/glossary/r/revision?hover=true">revision</a> is required, with the likely outcome that many <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> will be placed into new or different <a class="link_glossary" href="/glossary/g/genera" rel="/glossary/g/genera?hover=true">genera</a>. When describing the <a class="link_glossary" href="/glossary/g/genus" rel="/glossary/g/genus?hover=true">genus</a> in 1822, Hamilton identified the defining characteristics as: "absence or presence of <a class="link_glossary" href="/glossary/m/maxillary" rel="/glossary/m/maxillary?hover=true">maxillary</a> only or <a class="link_glossary" href="/glossary/r/rostral" rel="/glossary/r/rostral?hover=true">rostral</a> and <a class="link_glossary" href="/glossary/m/maxillary" rel="/glossary/m/maxillary?hover=true">maxillary</a> barbels; <a class="link_glossary" href="/glossary/d/dorsal" rel="/glossary/d/dorsal?hover=true">dorsal</a> <a class="link_glossary" href="/glossary/f/fin" rel="/glossary/f/fin?hover=true">fin</a> with last <a class="link_glossary" href="/glossary/s/simple%20ray" rel="/glossary/s/simple%20ray?hover=true">simple ray</a> <a class="link_glossary" href="/glossary/s/serrate" rel="/glossary/s/serrate?hover=true">serrate</a> or entire, <a class="link_glossary" href="/glossary/b/branched%20rays" rel="/glossary/b/branched%20rays?hover=true">branched rays</a> usually 8; anal <a class="link_glossary" href="/glossary/f/fin" rel="/glossary/f/fin?hover=true">fin</a> with last <a class="link_glossary" href="/glossary/s/simple%20ray" rel="/glossary/s/simple%20ray?hover=true">simple ray</a> entire, <a class="link_glossary" href="/glossary/b/branched%20rays" rel="/glossary/b/branched%20rays?hover=true">branched rays</a> usually 5; <a class="link_glossary" href="/glossary/l/lateral%20line" rel="/glossary/l/lateral%20line?hover=true">lateral line</a> complete or incomplete, <a class="link_glossary" href="/glossary/l/lateral" rel="/glossary/l/lateral?hover=true">lateral</a>-line scales 17-36 in row; <a class="link_glossary" href="/glossary/c/cephalic" rel="/glossary/c/cephalic?hover=true">cephalic</a> <a class="link_glossary" href="/glossary/c/cutaneous" rel="/glossary/c/cutaneous?hover=true">cutaneous</a> <a class="link_glossary" href="/glossary/p/papillae" rel="/glossary/p/papillae?hover=true">papillae</a> minute or absent; <a class="link_glossary" href="/glossary/p/pharyngeal%20teeth" rel="/glossary/p/pharyngeal%20teeth?hover=true">pharyngeal teeth</a> in 3 rows, usually 2,3,5/5,3,2; colour pattern extremely variable." All the <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> currently in the <a class="link_glossary" href="/glossary/g/genus" rel="/glossary/g/genus?hover=true">genus</a> are <a class="link_glossary" href="/glossary/n/native" rel="/glossary/n/native?hover=true">native</a> to Southeast Asia, India and Sri Lanka.\r\n\r\nThe other main source of confusion with <em>Puntius</em> is that some authors do not recognise all the member <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> as such, rather following Walter Rainboth (1996) and preferring to place some into the alternative <a class="link_glossary" href="/glossary/g/genus" rel="/glossary/g/genus?hover=true">genus</a> <em>Systomus</em>. Rainboth proposed that <em>Systomus</em> should be reinstated (it was first erected in the 19th century) as a valid <a class="link_glossary" href="/glossary/g/genus" rel="/glossary/g/genus?hover=true">genus</a> on account of the fact that in its current state <em>Puntius</em> would seem to constitute a <a class="link_glossary" href="/glossary/p/polyphyletic" rel="/glossary/p/polyphyletic?hover=true">polyphyletic</a> grouping i.e. not all of its members appear to have descended from the same common ancestor. The defining characteristics of a <em>Systomus</em> <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> are (according to Rainboth) a <a class="link_glossary" href="/glossary/s/serrated" rel="/glossary/s/serrated?hover=true">serrated</a> (vs. smooth in <em>Puntius</em>) <a class="link_glossary" href="/glossary/d/dorsal" rel="/glossary/d/dorsal?hover=true">dorsal</a> <a class="link_glossary" href="/glossary/s/spine" rel="/glossary/s/spine?hover=true">spine</a>, the presence of 2 or 4 barbels (vs. always 2) and less than 12 <a class="link_glossary" href="/glossary/g/gill" rel="/glossary/g/gill?hover=true">gill</a> rakers (vs. 12-20). SF tentatively lists all <a class="link_glossary" href="/glossary/s/species" rel="/glossary/s/species?hover=true">species</a> as <em>Puntius</em> at present.'),
(167927, 2288, 'etymology', ''),
(104421, 2288, 'attached_media', 'a:4:{i:0;s:5:"22881";i:1;s:5:"22882";i:2;s:5:"22883";i:3;s:5:"22884";}'),
(150578, 2288, 'references', 'a:2:{i:0;a:5:{s:13:"ref_doc_title";s:67:"Assemblage structure of stream fishes in the Western Ghats (India).";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:5:"1-31.";s:14:"ref_publishers";s:17:"Hydrobiologia 430";s:11:"ref_authors";s:19:"Arunachalam M. 2000";}i:1;a:5:{s:13:"ref_doc_title";s:0:"";s:12:"ref_pub_year";s:0:"";s:13:"ref_page_nums";s:0:"";s:14:"ref_publishers";s:16:"www.fishbase.org";s:11:"ref_authors";s:0:"";}}'),
(167925, 2288, '_edit_lock', '1341244017:4'),
(167928, 2288, 'species_author', 'Silas'),
(167929, 2288, 'year_described', '1953'),
(167930, 2288, 'beginner_suitability', '3'),
(167931, 2288, 'type_of_fish', '2')

wp_module

INSERT INTO `wp_posts` (`ID`, `post_author`, `post_date`, `post_date_gmt`, `post_content`, `post_title`, `post_excerpt`, `post_status`, `comment_status`, `ping_status`, `post_password`, `post_name`, `to_ping`, `pinged`, `post_modified`, `post_modified_gmt`, `post_content_filtered`, `post_parent`, `guid`, `menu_order`, `post_type`, `post_mime_type`, `comment_count`) VALUES
(2288, 4, '2012-03-13 13:24:32', '2012-03-13 13:24:32', '', 'Puntius sahyadriensis', 'This beautiful species is not often seen in the hobby, presumably as a result of its limited distribution, and tends to command a relatively high price when available. It may be seen on sale under the trade names &#039;Maharaja&#039; or &#039;Khavli&#039; barb.\r\n\r\nThe genus Puntius is currently viewed as something of a catch-all for well over 100 species of small cyprinid. Most experts agree that a full revision is required, with the likely outcome that many species will be placed into new or di...', 'publish', 'open', 'open', '', 'puntius-sahyadriensis', '', '', '2012-07-02 16:48:43', '2012-07-02 15:48:43', '', 0, 'http://www.seriouslyfish.com/?post_type=species&#038;p=2288', 0, 'species', '', 0);

보시다시피, 종 프로파일의 내용은 믿을 수 없을 정도로 길어요.이 링크를 통해 팝업을 표시할 수 있기를 바랍니다.

<a class="link_glossary" href="/glossary/n/native" rel="/glossary/n/native?hover=true">native</a>

문제는 다음과 같습니다. 현재 실행 중인 필터의 세부 정보는 첫 번째 링크 게시물에서 확인할 수 있습니다. 또는 여기서 직접 확인할 수 있습니다.filter.php이렇게 많은 데이터베이스 필드와 정보를 처리하는 것은 효율적이지 않습니다.

데이터를 Import할 때 로컬 호스트 WAMP 설치에서 WordPress 기반 CMS를 실행했기 때문에 처음 WordPress 기반 CMS를 사용하기 시작했을 때 필터가 작동했습니다.모든 데이터를 검토하는 데 거의 40분이 걸렸습니다.


질문입니다. 데이터 양과 데이터베이스 필드 수를 고려하여 효율적인 콘텐츠 필터를 만들려면 어떻게 해야 합니까?

데이터베이스 구조

wp_postmeta (meta_id, post_id, meta_key, meta_value)
wp_glossary (glossary_id, glossary_key, glossary_value)
wp_relation (meta_id, glossary_id)

wp_postmeta는 wp_prequarary와 wp_postmeta의 관계를 저장합니다.다음은 wp_postmeta 엔트리의 예입니다.

★★
탱크에는 부유식물이 잘 심어져 있어야 한다.종은 낮에는 숨는 것을 좋아하기 때문에 많은 은신처를 제공해야 한다.보그우드, 바위 동굴 및 PVC 배관은 모두 이 목적에 적합합니다.가시장어는 종종 자신을 묻기 좋아하기 때문에 모래를 기질로 사용해야 한다.조명이 밝아지면 물고기들이 더 자주 은신처에서 모험을 하도록 격려할 것이다.뱀장어는 아주 작은 틈새에서도 길을 찾을 수 있기 때문에 꼭 맞는 후드가 필요합니다.이 물고기는 주로 야생의 고요한 수역에 서식하기 때문에 물의 흐름이 상당히 부드러워야 한다.

다음은 wp_glossary의 엔트리의 예입니다.

glossary_id | glossary_key | glossary_value
         101   tank           ......
         102   species        ......
         103   bogwood        ......
         104   sand           ......
         105   substrate      ......

다음은 wp_relation이 용어집과 포스트메타의 관계를 유지하는 방법의 예이다.위의 포스트메타의 ID가 405라고 가정합니다.

glossary_id | meta_id 
         101   405       
         102   405  
         103   405    
         104   405       
         105   405  

출력 프로파일

위 데이터베이스 구조를 유지할 수 있게 되면 wp_relation에서 wp_postmeta 엔트리의 id를 검색하여 각 wp_postmeta에 대한 용어 링크를 쉽게 구축할 수 있습니다.그다음에 '어느 정도'를 str_replace콘텐츠에 대한 링크를 채웁니다.

성능을 향상시키려면 결과 내용을 HTML로 캐시할 수 있습니다. 캐시 만료 기간을 1일 또는 2일로 설정하십시오(용어집 및 사이트 트래픽 업데이트 빈도에 따라 다름).하시면 됩니다.memcached,file ★★★★★★★★★★★★★★★★★」database캐시를 저장합니다.


데이터베이스 구조 유지 관리

가장 어려운 작업은 데이터베이스 관계를 유지하는 것입니다.데이터베이스 관계를 변경하는 두 가지 주요 작업이 있습니다.

용어집 변경

  • 새로운 용어집 추가 : wp_postmeta에서 검색하여 관계를 구축합니다.
  • 용어집 삭제: 이 용어집과 다른 wp_postmeta 사이의 모든 관계를 삭제합니다.
  • 용어집 편집:용어집을 삭제하고 새로운 용어집을 추가하는 조합입니다.

포스트메타 변경

  • 포스트메타 추가/편집:용어집과 내용 간의 관계를 재구성합니다.다음은 관계를 구축하는 데 사용할 수 있는 알고리즘입니다.나는 그것을 할 수 있는 다른 더 좋은 방법들이 있다고 믿는다.코드는 완전하지 않지만(아직 테스트하지 않았지만) 알고리즘을 이해하면 충분합니다.

    // Initialize text to add glossary link
    $desc = "Tank should be well planted with floating plants also used. 
            An abundance of hiding places should be provided as this species 
            likes to hide away during the day. Bogwood, rock caves and PVC 
            piping are all suitable for this purpose. Sand should be used as 
            substrate as the spiny eels often like to bury themselves. 
            Dimmer lighting will encourage the fish to venture from 
            its hiding places more often. A close-fitting hood is required 
            as the eel can find its way through the smallest of gaps. Water 
            flow should be fairly gentle as the fish mainly inhabits 
            areas of still water in the wild.";
    
    // Split text into list of words
    $split = preg_split("/[.,\s]+/", $desc);
    
    // Frequency English words
    $freq['will'] = true;
    $freq['also'] = true;
    $freq['with'] = true;
    $freq['about'] = true;
    $freq['back'] = true;
    $freq['been'] = true;
    $freq['were'] = true;
    $freq['want'] = true;
    
    // Get list of unqiue word and elimate unnessary words
    foreach($split as $value) {
        $value = strtolower($value);
    
        if (strlen($value) < 4) continue;
        if (is_numeric($value)) continue;
        if (isset($freq[$value])) continue;
    
        if (!isset($hash[$value])) $hash[$value] = true;
    }
    
    // Join the list for search
    $keys = "";
    foreach ($hash as $key => $value)
        $keys .= "^{$key}|";
    $keys = rtrim($keys, '|');
    
    // Search for list of glossary
    $glossary;
    $result = mysql_query("SELECT glossary_id,glossary_key FROM wp_glossary  WHERE gossary_key REGEXP '{$keys}'")
    if ($result) {
        while($row = mysql_fetch_row($result)) {
            if (strpos($desc, $row[1]) !== false)
                $glossary[$row[0]] = $row[1];
        }
    }
    
    // You can start to construct the relation from this $glossary
    // by loop throught it one by one and insert it into wp_relation
    print_r($glossary);
    
  • Remove Postmeta : 이 포스트메타와 용어집 사이의 관계를 제거합니다.


기타 이점

용어집 "보그우드"를 사용하는 종 프로파일을 찾아봅시다.wp_relation을 통해 쉽게 추적할 수 있습니다.


문의사항

1. 첫째, str_replace는 기존 코드(href 코드 또는 img 코드)가 있는 종 프로파일에 어떻게 영향을 미칩니까?

없는 경우 종족 프로파일에 영향을 주지 않습니다.a link용어집과 종명으로 이동합니다.

2. 두 번째로 용어집 엔트리를 언급했지만 조금 더 복잡한 종의 속명/종명은 언급하지 않았습니다.그것들을 위해 별도의 테이블을 사용할까요, 아니면 모두 하나의 테이블에 통합할까요?

종명과 포스트메타의 관계를 저장하기 위한 별도의 테이블을 가질 수도 있고, 종명을 단순히 특수 플래그를 사용하여 용어집 용어로 취급할 수도 있습니다(용어 구조 변경 필요).

3. 그러면 용어집 엔트리와 종 프로파일 간의 차이(태그 내의 다른 클래스)를 어떻게 지정할 수 있습니까?

답변은 두 번째 질문에 어떤 방법을 사용하느냐에 따라 달라집니다.

여기 또 다른 생각이 있어요, 고객에게 가격 인상을 해 주세요.

분류법을 텍스트 파일로 추출하고 "변환 용어"를 캐시합니다.

guppie
salmon

리더가 페이지를 읽고 있을 때 JS가 이러한 내용을 살펴보고 URL을 다시 쓰도록 합니다.

<a href="/section/guppie">guppie</a> and a <a href="/section/salmon">salmon</a>

내가 예전에 여기서 논의한 적이 있기 때문에 이 방법에 대한 더 많은 것이 인터넷에 있을 것이다.

WP Custom Taxipies에 관한 튜터도 우연히 발견했는데, 당신의 경우와 관련이 있을 수 있습니다.

삼진수 탐색 트리를 고려해 보셨습니까?

이것은 "텍스트 매스 y에서 단어 x개수 찾기" 문제에 직면했을 때 내가 선호하는 데이터 구조이다.

트리 구축 예(fin, filter, caudal, gal, gaudy):

        f
       /|\
caudal* i ga
        |  | 
        n* l*
       /    \
    lter*    udy*

* = end node

알고리즘은 다음과 같이 됩니다.

  • 루트 노드에서 일치시킬 단어를 시작합니다.
  • 현재 위치가 일치하면 아래로 이동합니다.
  • 현재 위치 < 노드인 경우.왼쪽으로 움직이다.
  • 현재 위치 > 노드인 경우.오른쪽으로 움직이다.
  • 워드가 종료되고 노드가 엔드 노드인 경우.단어를 찾았습니다.
  • 왼쪽/오른쪽으로 이동할 수 없거나 워드가 비엔드 노드에서 끝나는 경우.단어를 찾을 수 없습니다.

여기 좋은 예가 있습니다.

장점은 트리를 미리 계산하여 직렬화된 형식으로 저장할 수 있다는 것입니다.사전 빌드된 트리를 구축하거나 클라이언트에 전송하여 브라우저에서 매칭을 수행할 수도 있습니다.

언급URL : https://stackoverflow.com/questions/11346736/whats-the-most-efficient-way-to-go-about-writing-a-complex-content-filter

반응형