9.25.2019

Online syntax highlighting for the code

9.21.2019

最近看的影集及電影(雷)

這幾天,因為網友推薦,看了關於我轉生變成史萊姆這檔事
看完第一季,覺得還不錯,只是推薦我看的網友,知道史萊姆是什麼,
但是居然沒有聽過勇者鬥惡龍這個遊戲。
我和網友都懷疑,主角會不會變成最後大魔王,要跟勇者對決?

今天,為了消秏MOD的看片金,看了 詐騙女神 這部片,
覺得還OK, 好在最後的走向我有喜歡,如果變成純愛劇,
我會覺得很爛…

7.05.2019

0/0未定義的原因 (小學數學)

0/0是未定義,那為何0/0不是1呢?是否有反例?
我想到的反例如下:(這是我自己想的,如有錯誤,還請指正)
Assume 0/0 = 1,
if 2x = 3x
=> x = 1.5x, so x = 0
=> 0 = 1.5 * 0
兩邊同除0
=> 0/0 =1.5 * 0/0
=> (0/0) = 1.5 * (0/0)
We assume 0/0 = 1
=> 1 = 1.5 * 1
=> 1 = 1.5, 所以這是0/0 = 1的反例

那麼0/0是否等於0呢?
這個我不知道真正的反例,
但是這樣0/0就不能上下消去得到1了。
至於0/0等於其它數值,可以簡單得到反例,
這就不提了。



6.13.2019

Differential and Partial differential


Differential of a function

dy=f'(x)\,dx,
where  is the derivative of f with respect to x, and dx is an additional real variable (so that dy is a function of x and dx). The notation is such that the equation
holds, where the derivative is represented in the Leibniz notation dy/dx, and this is consistent with regarding the derivative as the quotient of the differentials. One also writes


satisfies
where the error ε in the approximation satisfies ε/Δx → 0 as Δx → 0. In other words, one has the approximate identity
in which the error can be made as small as desired relative to Δx by constraining Δx to be sufficiently small; that is to say,
as Δx → 0. For this reason, the differential of a function is known as the principal (linear) part in the increment of a function: the differential is a linear function of the increment Δx, and although the error ε may be nonlinear, it tends to zero rapidly as Δx tends to zero.

the partial differential of y with respect to any one of the variables x1 is the principal part of the change in y resulting from a change dx1 in that one variable. The partial differential is therefore

參:
https://en.wikipedia.org/wiki/Differential_of_a_function


全微分和偏微分有什麼不同
假設 z = x^7 + y^3 + 3(x^2)*(y^4) + 4xy + 98 
z為應變數 , x y為自變數 

全微分 : 
就是所有變數通通都要微分 
dz = 7x^6dx + 3y^2dy + 6x(y^4)dx + 12(x^2)*(y^3)dy + 4ydx + 4xdy + 0 
ps. 兩變數相乘的 , 如同一般乘法的微分 , 前微後不微+前不微後微 

偏微分 : 
只對要微的自變數微分 , 其他的都當作常數 
1.對 x 偏微 
∂z/∂x = 7x^6 + 0 + 6x(y^4) + 4y + 0 

2. 對 y 偏微 
∂z/∂y = 0 + 3y^2 + 12(x^2)*(y^3) + 4x + 0

參:
https://tw.answers.yahoo.com/question/index?qid=20050930000013KK04937


5.22.2019

pdf2txt

pdf2txt.py

pdf2txt.pyPDF文件中提取文本内容。它提取所有要以编程方式呈现的文本,即以ASCIIUnicode字符串表示的文本。它无法识别绘制为需要光学字符识别的图像的文本。它还为每个文本部分提取相应的位置,字体名称,字体大小,书写方向(水平或垂直)。访问受到限制时,您需要为受保护的PDF文档提供密码。您无法从没有提取权限的PD文档中提取任何文本。
$ pdf2txt.py -o output.html samples/naacl06-shinyama.pdf
(extract text as an HTML file whose filename is output.html)

$ pdf2txt.py -V -c euc-jp -o output.html samples/jo.pdf
(extract a Japanese HTML file in vertical writing, CMap is required)

$ pdf2txt.py -P mypassword -o output.txt secret.pdf
(extract a text from an encrypted PDF file)
有关详细信息,请参阅/docs/index.html

PDFMiner.six

PDFMiner.six is a fork of PDFMiner using six for Python 2+3 compatibility
Build Status PyPI version
PDFMiner is a tool for extracting information from PDF documents. Unlike other PDF-related tools, it focuses entirely on getting and analyzing text data. PDFMiner allows one to obtain the exact location of text in a page, as well as other information such as fonts or lines. It includes a PDF converter that can transform PDF files into other text formats (such as HTML). It has an extensible PDF parser that can be used for other purposes than text analysis.


from pdfminer.layout import LAParams
from pdfminer.converter import PDFPageAggregator
from pdfminer.pdfinterp import PDFResourceManager, PDFPageInterpreter
from pdfminer.pdfpage import PDFPage
from pdfminer.layout import LTTextBoxHorizontal
import sys, os

os.environ["PYTHONIOENCODING"] = 'utf-8'
sys.stdout.reconfigure(encoding='utf-8')
#print(sys.stdout.encoding)
#print(os.environ["PYTHONIOENCODING"])
            
document = open('Pfizer1.pdf', 'rb')
rsrcmgr = PDFResourceManager()
laparams = LAParams()
device = PDFPageAggregator(rsrcmgr, laparams=laparams)
interpreter = PDFPageInterpreter(rsrcmgr, device)
for page in PDFPage.get_pages(document):
    interpreter.process_page(page)
    layout = device.get_result()
    for element in layout:
        if isinstance(element, LTTextBoxHorizontal):
            obj = element._objs[0]
            print("x_cor: %.2f " % obj.bbox[0])
            print("y_cor: %.2f" % obj.bbox[1])
            print("length: %.2f" % obj.bbox[2])
            print("height: %.2f" % obj.bbox[3])
            text = obj.get_text().replace('\n','')
            #btext = text.encode(encoding='utf-8')
            print("text: ", text)
            print("--------------------")