主頁 > 前端設計 > 如何找到給定單詞串列的唯一詞綴串列?

如何找到給定單詞串列的唯一詞綴串列?

2021-12-25 04:00:09 前端設計

賞金過期5天此問題的答案有資格獲得 500聲望獎勵。 Lance Pollard正在尋找規范的答案
在 JavaScript 中尋找可以處理單詞中間的前綴、后綴和單詞部分的實作。

詞綴可以是前綴(詞前)、中綴(詞中間)或后綴(詞后)。我有一份生物分類學中使用的 20 萬多個拉丁/希臘名稱串列不幸的是,除了這個非常基本的串列之外,并沒有集中列出分類法中使用的所有詞綴

問題是,我怎樣才能把那 20 萬多個拉丁/希臘名字的串列分成一個詞綴串列(最好只使用純 JavaScript)?

我真的不知道從哪里開始這個。如果我構建一個 trie,我需要以某種方式測驗特定的單詞塊。或者如果塊可以擴展,在我們達到某種最終擴展之前不要包含塊......

const fs = require('fs')
const words = fs.readFileSync(`/Users/lancepollard/Downloads/all.csv`, 'utf-8').trim().split(/\n /)
const trie = { children: {} }

words.forEach(word => addToTrie(trie, word))

function addToTrie(trie, word) {
  let letters = word.trim().split('')
  let node = trie
  let i = 0
  while (i < letters.length) {
    let letter = letters[i  ]
    node = node.children[letter] = node.children[letter] || { children: {} }
  }
  node.isWord = true
}

它不需要很精確,就像每個詞綴實際上都意味著什么,它可以是骯臟的(也就是說,有些詞意味著什么,有些詞沒有)。但它不應該只是列出單詞字母的每個排列之類的東西。它應該包括“潛在詞綴候選”的東西,它們是在串列中出現不止一次的塊這至少會讓我走到一半,然后我可以手動查看并查找每個“塊”的定義。理想情況下,它還應該說明它是否是前綴/中綴/后綴。也許輸出是 CSV 格式affix,position

您可以創造性地解決這個問題,因為如果事先不知道可能的詞綴串列,我們不知道確切的輸出應該是什么。這基本上是為了盡可能地找到詞綴。aa-例如,如果它包含前綴之類的東西,這可能是一個常見的字母序列,但我認為這不是詞綴,這對我來說很好,可以手動過濾掉。但是,如果有兩個詞(我在做這件事),說abrogatiabrowendi,那么abro將是一個“共同的前綴”,以及應包含在最終的名單,不abraba,即使這些是常見的了。基本上,最長的公共前綴。但是,如果我們有單詞apistalariavi,我們可以說這a是一個常見的前綴,所以我們的最終串列將包括aabro

更詳細一點,假設我們有這兩個詞aprineyanilantliand aboneyanomantli,它們有共同的前綴a-、共同的后綴-antli以及中綴-neyan-,所以它們應該在最終串列中。

它不一定需要高效,因為理論上這只會在 200k 串列上運行一次。但如果它也有效率,那將是獎勵。理想情況下,雖然它不應該需要幾個小時才能運行,但我不確定有什么可能:)

另一個例子是這樣的:

brevidentata
brevidentatum
brevidentatus
crassidentata
crassidentatum
crassidentatus

在這里,前 3 個有一個公共前綴, brevidentat,然后 2-3 個有公共前綴brevidentatu但后來(與人類的知識),我們發現identat可能是我們的愿望,和a/ um/us是word格式的后綴。此外,我們看到這identat是兩個詞crass...和中的中綴brev...所以最終的結果應該是:

brav-
crass-
-identat-
-a
-us
-um

從理論上講,這將是理想的結果。但你也可以有這個:

brav-
crass-
-identat-
-identata
-identatus
-identatum

這也可以,我們可以做一些簡單的過濾,以便稍后將它們過濾掉。

Note, I don't care about infixes in the sense of word parts that surround something else, like stufffoo...barstuff, where foo...bar wraps something. I just care about the word parts which are repeated, such as prefixes, suffixes, and stuff in the middle of words.

uj5u.com熱心網友回復:

這是一個簡單的方法,但可能是在幾個小時內。此外,您可以使用 JavaScript 來實作,但我將采用通用的 Unixy 方法,您可以使用任何語言撰寫它,因為這很容易考慮。

首先,讓我們獲取您的檔案,并在每個單詞的開頭/結尾添加標記,并在字母之間添加空格。所以你的例子會變成:

^ b r e v i d e n t a t a $
^ b r e v i d e n t a t u m $
^ b r e v i d e n t a t u s $
^ c r a s s i d e n t a t a $
^ c r a s s i d e n t a t u m $
^ c r a s s i d e n t a t u s $

這是我們的一般表示,空格分隔可能的詞綴。基本詞綴是字母、開始和結束。當然,我們在這里沒有發現詞綴。


這是單個詞綴搜索通道的樣子。

拿我們的檔案,創建tempfile不同的可能詞綴部分,然后是單詞的行號。(我說不同,這樣如果行666包含a b a b你就不會得到a b: 666兩次。)所以我們的檔案開始:

 ^ b: 1
 ^ b r: 1
 .
 .
 .
 ^ c r a s s i d e n t a t u s $: 6

接下來sort是檔案(只需使用 UnixLC_ALL=C sort tempfile > sortedtempfile命令,LC_ALL強制 asciibetical 排序)。您現在生成sortedtempfile開始:

 ^ b: 1
 ^ b: 2
 .
 .
 .
 ^ c r a s s i d e n t a t u s $: 6

接下來運行一個自定義命令,為每個至少出現 2 次的前綴提供,使用它作為詞綴保存多少符號,然后是詞綴,然后是出現它的行串列。這會生成一個tempsaved開始的檔案

 3: ^ b: 1 2 3
 6: ^ b r e: 1 2 3
 .
 .
 .
 16: v i d e n t a t u: 2 3

現在sorted -rn tempsaved > sortedtempsaved先從最大節省量排序,然后找到最大的節省量。這個檔案現在開始

 36: ^ c r a s s i d e n t a t: 4 5 6
 33: ^ b r e v i d e n t a t: 1 2 3
 36: ^ c r a s s i d e n t a: 4 5 6

在下一個函式中,我們識別詞綴,直到在同一行號上遇到 2。然后回傳到我們的原始檔案并應用它們。所以在這個程序中,我們將識別^crassidentat^brevidentat然后生成一個新檔案,其中包含:

^brevidentat a $
^brevidentat u m $
^brevidentat u s $
^crassidentat a $
^crassidentat u m $
^crassidentat u s $

現在重復。


在您的示例中,您將得到以下一組詞綴:

^crassidentat
^brevidentat
um$
us$
a$

如果將 words identata, identatumand添加identatus到原始串列中,則相同的演算法將生成以下詞綴串列

identat
^crass
^brev
um$
us$
a$

這是你所說的理想結果。


我的信封背面說你應該期望每次通過需要幾分鐘。但是我們試圖在每次通過時找到很多詞綴。所以我不希望這需要超過幾十遍。此外,該串列之后還需要人工審核。我認為沒有什么可以避免的。

uj5u.com熱心網友回復:

這是一個有趣的問題,我有一個解決方案的草圖,其中包含可運行的代碼和有點合理——但遠非完美——的輸出。玩變體很容易,如果不是很快的話。

這個想法是首先遍歷所有單詞,以各種可能的方式拆分它們,然后計算所有單詞中每個前綴、中綴和后綴的出現次數,最后使用該資訊以及評分函式,選擇每個單詞的最佳表示。

我測驗過的評分函式涉及前綴長度、所有單詞中該前綴的計數以及后綴和詞綴的相同因素的組合。一般來說,我對長度的權重比計數高得多,我現在關注前綴,只對后綴稍加權重。

運行這需要幾分鐘,但默認情況下比 Node 獲得的記憶體多。我運行它

node --max-old-space-size=8192 index

這似乎就足夠了。4GB的我沒試過。

我的代碼看起來像這樣,使用最新的(也是我最喜歡的)評分函式:

const {readFile, writeFile} = require ('fs') .promises
 
const range = (lo, hi) =>
  Array .from ({length: hi - lo}, (_, i) => i   lo)
 
const chooseTwo = (n) =>
  range (0, n) .flatMap (i => range (i   1, n   1) .map (j => [i, j]))
 
const maximumBy = (fn) => (xs) =>
  xs .reduce (({max, val}, x, _, __, v = fn(x)) => v > max ? {max: v, val: x} : {max, val}, {max:-Infinity}) .val
 
 
const breakdown = (word, len = word.length, ranges = chooseTwo (len)) => [
  ... ranges .map (([i, j]) => ({p: word .slice (0, i), i: word .slice (i, j), s: word .slice (j)})),
  ... range (0, len - 1) .map (i => ({p: '', i: word .slice (0, i), s: word .slice (i)})),
]
 
const score = (counts) => ({p, i, s}) =>
  Math .max (1, Math .sqrt (1   counts .prefixes [p]) * p .length ** 2) *
  // Math .max (1, counts .infixes [i] * i .length ) *
  Math .max (1, counts .suffixes [s] * s .length)
 
const process = (words) => {
  const breakdowns = words .map (w => breakdown(w))
  const counts = breakdowns .reduce (
    (all, breakdown) => breakdown .reduce (
      (all, {p, i, s}) => {
        all .prefixes [p] = (all .prefixes [p] || 0)   1
        all .infixes [i] = (all .infixes [i] || 0)   1
        all .suffixes [s] = (all .suffixes [s] || 0)   1
        return all;
      },
      all
    ),
    {prefixes: {}, infixes: {}, suffixes: {}}
  )
 
  return breakdowns .map (maximumBy (score (counts)))
}
  
readFile ('./all.csv', 'utf8')
  .then (s => s.split ('\n'))
  .then (process)
  .then (breakdowns => breakdowns .map (({p, i, s}) => `${p ? `(${p}-)` : ''}(${i})${s ? `(-${s})` : ''}`))
  .then (words => writeFile ('./res.csv', words .join ('\n')), 'utf8')
  .then (() => console .log ('Result written'))

第一個重要的函式是breakdown,例如,它變成'horse'

(h)(-orse)
(ho)(-rse)
(hor)(-se)
(hors)(-e)
(horse)
(h-)(o)(-rse)
(h-)(or)(-se)
(h-)(ors)(-e)
(h-)(orse)
(ho-)(r)(-se)
(ho-)(rs)(-e)
(ho-)(rse)
(hor-)(s)(-e)
(hor-)(se)
(hors-)(e)
()(-horse)
(h)(-orse)
(ho)(-rse)
(hor)(-se)
(h-)(orse)
(ho-)(rse)
(hor-)(se)
(hors-)(e)

它與p,is屬性一起存盤在內部, for prefix, infix, and suffix,所以它實際上是這樣的:

[
  {p: '', i: 'h', s: 'orse'},
  {p: '', i: 'ho', s: 'rse'},
  {p: '', i: 'hor', s: 'se'},
  {p: '', i: 'hors', s: 'e'},
  {p: '', i: 'horse', s: ''},
  {p: 'h', i: 'o', s: 'rse'},
  {p: 'h', i: 'or', s: 'se'},
  {p: 'h', i: 'ors', s: 'e'},
  {p: 'h', i: 'orse', s: ''},
  {p: 'ho', i: 'r', s: 'se'},
  {p: 'ho', i: 'rs', s: 'e'},
  {p: 'ho', i: 'rse', s: ''},
  {p: 'hor', i: 's', s: 'e'},
  {p: 'hor', i: 'se', s: ''},
  {p: 'hors', i: 'e', s: ''},
  {p: '', i: '', s: 'horse'},
  {p: '', i: 'h', s: 'orse'},
  {p: '', i: 'ho', s: 'rse'},
  {p: '', i: 'hor', s: 'se'},
  {p: 'h', i: 'orse', s: ''},
  {p: 'ho', i: 'rse', s: ''},
  {p: 'hor', i: 'se', s: ''},
  {p: 'hors', i: 'e', s: ''},
]

breakdown is built on two trivial functions: range creates an integer range, inclusive on the start, exclusive on the end, so that range (3, 12) yields [3, 4, 5, 6, 7, 8, 9, 10, 11]. And chooseTwo finds all pairs of distinct integers between 0 and n.

Our second main function is process, which does the algorithm described above using breakdown and maximumBy, which we use to choose the maximum valued breakdown using the score function. In between, we simply count the parts used.

This is all infrastructure. The important work is in score. You can alter this in so many ways. If it wasn't holiday time, I would love to play around with variants of this. But when you do, you should note that although it's easy to play with a small subset of the data and get reasonable-looking results, that doesn't always scale so reasonable to the complete data. So you will need to run the full code with various functions.

One thing I would suggest investigating is whether there is a reasonably accurate predictive hyphenating tool for English -- not dictionary-based, but either the result of reasonable first principles or of some machine learning runs. A good hyphenation decision might help you write a better score function.

如果您想在一小部分資料中看到這一點,您可以展開以下代碼段:

顯示代碼片段

const range = (lo, hi) =>
  Array .from ({length: hi - lo}, (_, i) => i   lo)
 
const chooseTwo = (n) =>
  range (0, n) .flatMap (i => range (i   1, n   1) .map (j => [i, j]))
 
const maximumBy = (fn) => (xs) =>
  xs .reduce (({max, val}, x, _, __, v = fn(x)) => v > max ? {max: v, val: x} : {max, val}, {max:-Infinity}) .val
 
 
const breakdown = (word, len = word.length, ranges = chooseTwo (len)) => [
  ... ranges .map (([i, j]) => ({p: word .slice (0, i), i: word .slice (i, j), s: word .slice (j)})),
  ... range (0, len - 1) .map (i => ({p: '', i: word .slice (0, i), s: word .slice (i)})),
]
 
const score = (counts) => ({p, i, s}) =>
  Math .max (1, Math .sqrt (1   counts .prefixes [p]) * p .length ** 2) *
  // Math .max (1, counts .infixes [i] * i .length ) *
  Math .max (1, counts .suffixes [s] * s .length)
 
const process = (words) => {
  const breakdowns = words .map (w => breakdown(w))
  const counts = breakdowns .reduce (
    (all, breakdown) => breakdown .reduce (
      (all, {p, i, s}) => {
        all .prefixes [p] = (all .prefixes [p] || 0)   1
        all .infixes [i] = (all .infixes [i] || 0)   1
        all .suffixes [s] = (all .suffixes [s] || 0)   1
        return all;
      },
      all
    ),
    {prefixes: {}, infixes: {}, suffixes: {}}
  )
 
  return breakdowns .map (maximumBy (score (counts)))
}

const words = ["cristata", "cristatella", "cristatellidae", "cristatellus", "cristaticeps", "cristaticollis", "cristatiforme", "cristatifrons", "cristatigena", "cristatipes", "cristatispinosa", "cristatissimus", "cristatogobius", "cristatoides", "cristatolabra", "cristatopalpus", "cristatula", "cristatum", "cristatus", "cristavarius", "cristellaria", "cristeremaeus", "cristi", "cristianalemani", "cristiani", "cristibrachium", "cristicauda", "cristiceps", "cristicola", "cristicollis", "cristidigitus", "cristifer", "cristifera", "cristiferus", "cristiformis", "cristifrons", "cristigera", "cristiglans", "cristiloba", "cristimanus", "cristina", "cristinae", "cristipalpis", "cristipes", "cristirhizophorum", "cristis", "cristispira", "cristiverpa", "cristobal", "cristobala", "cristobalensis", "cristobalia", "cristoides", "cristonothrus", "cristophylla", "cristovalensis", "cristovaoi", "cristula", "cristulata", "cristulatum", "cristulatus", "cristuliflora", "cristulifrons", "cristulipes", "cristulum", "cristus", "crisulipora", "critchleyi", "critesion", "crithagra", "crithionina", "crithmifolia", "crithmoides", "critho", "crithodium", "crithopyrum", "critica", "criticum", "criticus", "critola", "critolaus", "critomolgus", "criton", "critonia", "crittersius", "crius", "crivellarii", "crnobog", "crnri", "croasdaleae", "croatanensis", "croatania", "croatanica", "croatica", "croaticum", "croaticus", "croatii", "crobylophorus", "crobylura", "crocaceae", "crocale", "crocallata", "crocallis", "crocana", "crocanthemum", "crocata", "crocatum", "crocatus", "crocea", "croceareolata", "crocearia", "croceata", "croceater", "croceator", "croceatus", "croceguttatus", "croceibacter", "croceicauda", "croceicincta", "croceicoccus", "croceicollis", "croceicornis", "croceiflorus", "croceipennis", "croceipes", "croceitalea", "croceitarsis", "croceithorax", "croceiventre", "croceiventris", "croceoida", "croceoides", "croceoinguinis", "croceola", "croceolanata", "croceomaculatus", "croceopodes", "croceosignatus", "croceovittata", "croceovittatus", "croces", "croceum", "croceus", "croci", "crociaeus", "crocias", "crocidema", "crocidium", "crocidolomiae", "crocidopoma", "crocidura", "crocidurae", "crocidurai", "crocidurinae", "crociduroides", "crocidurus", "crocifera", "crocigrapha", "crocina", "crocinae", "crocineus", "crocinitomix", "crocinopterus", "crocinosoma", "crocinubia", "crocinum", "crocinus", "crocisa", "crocisaeformis", "crockerella", "crockeri", "crockeria", "crockeriana", "crockerinus", "crockettorum", "crococephala", "crocodila", "crocodilensis", "crocodili", "crocodilia", "crocodilichthys", "crocodilinus", "crocodill", "crocodillicola", "crocodilorum", "crocodilosa", "crocodilurus", "crocodilus", "crocodyli", "crocodylia", "crocodylidae", "crocodylus", "crocogaster", "crocolita", "croconota", "croconotus", "crocopeplus", "crocopygia", "crocopygius", "crocorrhoa", "crocosema", "crocosmia", "crocosmiiflora", "crocostethus", "crocota", "crocothemis", "crocotia", "crocotila", "crocoturum", "crocotus", "crocro", "crocus", "crocusella", "crocuta", "crocutasis", "crocutella", "crocynia", "crocyniaceae", "croeciclava", "croeseri", "croesia", "croesioides", "croesus", "croftia", "croftiae", "croftii", "croftoni", "croftus", "crogmaniana", "croicensis", "croilia", "croisseti", "croix", "croizati", "croizatii", "crokeri", "cromagnonensis", "crombiei", "crombota", "cromeria", "cromerus", "cromileptes", "cromion", "cromis", "cromwellii", "cromyorhizon", "cronadun", "cronartiaceae", "cronartium", "cronebergi", "cronebergii", "croni"]
 
Promise .resolve (words)
  .then (process)
  .then (breakdowns => breakdowns .map (({p, i, s}) => `${p ? `(${p}-)` : ''}(${i})${s ? `(-${s})` : ''}`))
  .then (words => console .log (words .join ('\n')))
.as-console-wrapper {max-height: 100% !important; top: 0}

我用來顯示這些的格式與建議的略有不同,因為我希望允許沒有前綴或后綴的版本,但仍然非常可讀和明確。這樣(crist-)(atellid)(-ae)應該就很清楚了。這三個部分中的每一個都用括號括起來。前綴以連字符結尾,后綴以 1 開頭。這是輸出檔案中的格式,但更改它是微不足道的——只需調整提供給breakdowns .map ()最后一個塊的函式即可


一個引人入勝的問題,我希望下周有時間更仔細地研究它。

uj5u.com熱心網友回復:

前綴和后綴使用 Trie 很容易。但是,Trie 不會幫助您處理中綴。

Trie 的示例代碼(在 Java 中,未經測驗,不完整)

class Node {
    private int cnt;
    private Map<Character, Node> children;

    Node() {
        cnt = 0;
        this.children = new HashMap<>();
    }

    Node(String s, int pos) {
        this();
        addChild(s, pos);
    }

    bool isLeaf() {
        return this.children.size() == 0
    }

    void addChild(String s, int pos) {
        if (pos == s.length()) {
            return;
        }

        char c = s.charAt(pos);
        if (children.containsKey(c)) {
            children.get(c).addChild(s, pos   1);
        } else {
            children.put(c, new Node(s, pos   1));
        }
        cnt  ;
    }

    void removeChild(char c) {
        int ccnt = 0;
        Node child = children.remove(c);
        if (child != null) {
            ccnt = child.cnt;
        }
        cnt -= ccnt;
    }

    // other methods as necessary for traversal/value lookup...
}

class Solution {
    private Node preroot = new Node();
    private Node sufroot = new Node();

    void addWord(String s) {
        preroot.addChild(s, 0);
        sufroot.addChild(new StringBuilder(s).reverse().toString(), 0);
    }

    void findPrefixes(int minOccur) {
        // standard tree traversal on preroot,
        // starting at the left-most leaf.
        // when it finds a non-leaf with cnt >= minOccur
        // output all permutations and remove the child.
    }
}

中綴

中綴的問題是你不知道從哪里開始。即取字串 abcdefgh 和 pppbcdefgzzzz,它們具有共同的中綴 bcdefg。此外,abcdefgh 和 pppabcdefgzzz 怎么樣?

要解決這個問題,您基本上需要將單詞切成所有可能的成分,然后指向該單詞。然后遍歷排骨串列,按長度降序排序,并洗掉所有與“已用”詞相關的條目。

即 abc 將成為查找條目:abc、ab、bc、a、b、c。然后查找表將如下所示:

單詞與符號的關聯:

{abc -> {abc, ab, bc, a, b, c}}

地圖:

{abc -> { abc }}
{ab -> { abc }}
{bc -> { abc }}
{a -> { abc }}
{b -> { abc }}
{c -> { abc }}

當我們添加 bcd 時,它添加了符號:bcd、bc、cd、b、c、d,添加了單詞關聯并更新了查找表:

{abc -> { abc }}
{bcd -> { bcd }}
{ab -> { abc }}
{bc -> { abc, bcd }}
{cd -> { bcd }}
{a -> { abc }}
{b -> { abc, bcd }}
{c -> { abc, bcd }}
{d -> { bcd }

然后使用映射鍵的長度來指示排序順序。從頂部開始,導航直到達到最少出現次數,然后使用該串列中的單詞并從結構中洗掉這些單詞。從映射中洗掉單詞使用之前保存的單詞關聯來查找符號映射中的鍵。

轉載請註明出處,本文鏈接:https://www.uj5u.com/qianduan/391948.html

標籤:javascript algorithm trie

上一篇:將vector<vector<string>>轉換為vector<vector<double>>的最佳方法是什么?

下一篇:Z80除法演算法運行不正常

標籤雲
其他(157675) Python(38076) JavaScript(25376) Java(17977) C(15215) 區塊鏈(8255) C#(7972) AI(7469) 爪哇(7425) MySQL(7132) html(6777) 基礎類(6313) sql(6102) 熊猫(6058) PHP(5869) 数组(5741) R(5409) Linux(5327) 反应(5209) 腳本語言(PerlPython)(5129) 非技術區(4971) Android(4554) 数据框(4311) css(4259) 节点.js(4032) C語言(3288) json(3245) 列表(3129) 扑(3119) C++語言(3117) 安卓(2998) 打字稿(2995) VBA(2789) Java相關(2746) 疑難問題(2699) 细绳(2522) 單片機工控(2479) iOS(2429) ASP.NET(2402) MongoDB(2323) 麻木的(2285) 正则表达式(2254) 字典(2211) 循环(2198) 迅速(2185) 擅长(2169) 镖(2155) 功能(1967) .NET技术(1958) Web開發(1951) python-3.x(1918) HtmlCss(1915) 弹簧靴(1913) C++(1909) xml(1889) PostgreSQL(1872) .NETCore(1853) 谷歌表格(1846) Unity3D(1843) for循环(1842)

熱門瀏覽
  • vue移動端上拉加載

    可能做得過于簡單或者比較low,請各位大佬留情,一起探討技術 ......

    uj5u.com 2020-09-10 04:38:07 more
  • 優美網站首頁,頂部多層導航

    一個個人用的瀏覽器首頁,可以把一下常用的網站放在這里,平常打開會比較方便。 第一步,HTML代碼 <script src=https://www.cnblogs.com/szharf/p/"js/jquery-3.4.1.min.js"></script> <div id="navigate"> <ul> <li class="labels labels_1"> ......

    uj5u.com 2020-09-10 04:38:47 more
  • 頁面為要加<!DOCTYPE html>

    最近因為寫一個js函式,需要用到$(window).height(); 由于手寫demo的時候,過于自信,其實對前端方面的認識也不夠體系,用文本檔案直接敲出來的html代碼,第一行沒有加上<!DOCTYPE html> 導致了$(window).height();的結果直接是整個document的高 ......

    uj5u.com 2020-09-10 04:38:52 more
  • WordPress網站程式手動升級要做好資料備份

    WordPress博客網站程式在進行升級前,必須要做好網站資料的備份,這個問題良家佐言是遇見過的;在剛開始接觸WordPress博客程式的時候,因為升級問題和博客網站的修改的一些嘗試,良家佐言是吃盡了苦頭。因為購買的是西部數碼的空間和域名,每當佐言把自己的WordPress博客網站搞到一塌糊涂的時候 ......

    uj5u.com 2020-09-10 04:39:30 more
  • WordPress程式不能升級為5.4.2版本的原因

    WordPress是一款個人博客系統,受到英文博客愛好者和中文博客愛好者的追捧,并逐步演化成一款內容管理系統軟體;它是使用PHP語言和MySQL資料庫開發的,用戶可以在支持PHP和MySQL資料庫的服務器上使用自己的博客。每一次WordPress程式的更新,就會牽動無數WordPress愛好者的心, ......

    uj5u.com 2020-09-10 04:39:49 more
  • 使用CSS3的偽元素進行首字母下沉和首行改變樣式

    網頁中常見的一種效果,首字改變樣式或者首行改變樣式,效果如下圖。 代碼: <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, ......

    uj5u.com 2020-09-10 04:40:09 more
  • 關于a標簽的講解

    什么是a標簽? <a> 標簽定義超鏈接,用于從一個頁面鏈接到另一個頁面。 <a> 元素最重要的屬性是 href 屬性,它指定鏈接的目標。 a標簽的語法格式:<a href=https://www.cnblogs.com/summerxbc/p/"指定要跳轉的目標界面的鏈接">需要展示給用戶看見的內容</a> a標簽 在所有瀏覽器中,鏈接的默認外觀如下: 未被訪問的鏈接帶 ......

    uj5u.com 2020-09-10 04:40:11 more
  • 前端輪播圖

    在需要輪播的頁面是引入swiper.min.js和swiper.min.css swiper.min.js地址: 鏈接:https://pan.baidu.com/s/15Uh516YHa4CV3X-RyjEIWw 提取碼:4aks swiper.min.css地址 鏈接:https://pan.b ......

    uj5u.com 2020-09-10 04:40:13 more
  • 如何設定html中的背景圖片(全屏顯示,且不拉伸)

    1 <style>2 body{background-image:url(https://uploadbeta.com/api/pictures/random/?key=BingEverydayWallpaperPicture); 3 background-size:cover;background ......

    uj5u.com 2020-09-10 04:40:16 more
  • Java學習——HTML詳解(上)

    HTML詳解 初識HTML Hyper Text Markup Language(超文本標記語言) 1 <!--DOCTYPE:告訴瀏覽器我們要使用什么規范--> 2 <!DOCTYPE html> 3 <html lang="en"> 4 <head> 5 <!--meta 描述性的標簽,描述一些 ......

    uj5u.com 2020-09-10 04:40:33 more
最新发布
  • 我的第一個NPM包:panghu-planebattle-esm(胖虎飛機大戰)使用說明

    好家伙,我的包終于開發完啦 歡迎使用胖虎的飛機大戰包!! 為你的主頁添加色彩 這是一個有趣的網頁小游戲包,使用canvas和js開發 使用ES6模塊化開發 效果圖如下: (覺得圖片太sb的可以自己改) 代碼已開源!! Git: https://gitee.com/tang-and-han-dynas ......

    uj5u.com 2023-04-20 07:59:23 more
  • 生產事故-走近科學之消失的JWT

    入職多年,面對生產環境,盡管都是小心翼翼,慎之又慎,還是難免捅出簍子。輕則滿頭大汗,面紅耳赤。重則系統停擺,損失資金。每一個生產事故的背后,都是寶貴的經驗和教訓,都是專案成員的血淚史。為了更好地防范和遏制今后的各類事故,特開此專題,長期更新和記錄大大小小的各類事故。有些是親身經歷,有些是經人耳傳口授 ......

    uj5u.com 2023-04-18 07:55:04 more
  • 記錄--Canvas實作打飛字游戲

    這里給大家分享我在網上總結出來的一些知識,希望對大家有所幫助 打開游戲界面,看到一個畫面簡潔、卻又富有挑戰性的游戲。螢屏上,有一個白色的矩形框,里面不斷下落著各種單詞,而我需要迅速地輸入這些單詞。如果我輸入的單詞與螢屏上的單詞匹配,那么我就可以獲得得分;如果我輸入的單詞錯誤或者時間過長,那么我就會輸 ......

    uj5u.com 2023-04-04 08:35:30 more
  • 了解 HTTP 看這一篇就夠

    在學習網路之前,了解它的歷史能夠幫助我們明白為何它會發展為如今這個樣子,引發探究網路的興趣。下面的這張圖片就展示了“互聯網”誕生至今的發展歷程。 ......

    uj5u.com 2023-03-16 11:00:15 more
  • 藍牙-低功耗中心設備

    //11.開啟藍牙配接器 openBluetoothAdapter //21.開始搜索藍牙設備 startBluetoothDevicesDiscovery //31.開啟監聽搜索藍牙設備 onBluetoothDeviceFound //30.停止監聽搜索藍牙設備 offBluetoothDevi ......

    uj5u.com 2023-03-15 09:06:45 more
  • canvas畫板(滑鼠和觸摸)

    <!DOCTYPE html> <html> <head> <meta charset="utf-8"> <title>canves</title> <style> #canvas { cursor:url(../images/pen.png),crosshair; } #canvasdiv{ bo ......

    uj5u.com 2023-02-15 08:56:31 more
  • 手機端H5 實作自定義拍照界面

    手機端 H5 實作自定義拍照界面也可以使用 MediaDevices API 和 <video> 標簽來實作,和在桌面端做法基本一致。 首先,使用 MediaDevices.getUserMedia() 方法獲取攝像頭媒體流,并將其傳遞給 <video> 標簽進行渲染。 接著,使用 HTML 的 < ......

    uj5u.com 2023-01-12 07:58:22 more
  • 記錄--短視頻滑動播放在 H5 下的實作

    這里給大家分享我在網上總結出來的一些知識,希望對大家有所幫助 短視頻已經無數不在了,但是主體還是使用 app 來承載的。本文講述 H5 如何實作 app 的視頻滑動體驗。 無聲勝有聲,一圖頂百辯,且看下圖: 網址鏈接(需在微信或者手Q中瀏覽) 從上圖可以看到,我們主要實作的功能也是本文要講解的有: ......

    uj5u.com 2023-01-04 07:29:05 more
  • 一文讀懂 HTTP/1 HTTP/2 HTTP/3

    從 1989 年萬維網(www)誕生,HTTP(HyperText Transfer Protocol)經歷了眾多版本迭代,WebSocket 也在期間萌芽。1991 年 HTTP0.9 被發明。1996 年出現了 HTTP1.0。2015 年 HTTP2 正式發布。2020 年 HTTP3 或能正... ......

    uj5u.com 2022-12-24 06:56:02 more
  • 【HTML基礎篇002】HTML之form表單超詳解

    ??一、form表單是什么

    ??二、form表單的屬性

    ??三、input中的各種Type屬性值

    ??四、標簽 ......

    uj5u.com 2022-12-18 07:17:06 more