Skip to content

Commit

Permalink
Remove syntax errors
Browse files Browse the repository at this point in the history
Signed-off-by: Jeff Hodges <jeff@somethingsimilar.com>
  • Loading branch information
manveru authored and jmhodges committed Sep 10, 2009
1 parent 945438b commit f54c49e
Show file tree
Hide file tree
Showing 8 changed files with 19 additions and 19 deletions.
12 changes: 6 additions & 6 deletions lib/rchardet/chardistribution.rb
Expand Up @@ -57,8 +57,8 @@ def feed(aStr, aCharLen)
if order >= 0 if order >= 0
@_mTotalChars += 1 @_mTotalChars += 1
# order is valid # order is valid
if order < @_mTableSize: if order < @_mTableSize
if 512 > @_mCharToFreqOrder[order]: if 512 > @_mCharToFreqOrder[order]
@_mFreqChars += 1 @_mFreqChars += 1
end end
end end
Expand All @@ -72,7 +72,7 @@ def get_confidence
return SURE_NO return SURE_NO
end end


if @_mTotalChars != @_mFreqChars: if @_mTotalChars != @_mFreqChars
r = @_mFreqChars / ((@_mTotalChars - @_mFreqChars) * @_mTypicalDistributionRatio) r = @_mFreqChars / ((@_mTotalChars - @_mFreqChars) * @_mTypicalDistributionRatio)
if r < SURE_YES if r < SURE_YES
return r return r
Expand Down Expand Up @@ -227,10 +227,10 @@ def get_order(aStr)
# first byte range: 0xa0 -- 0xfe # first byte range: 0xa0 -- 0xfe
# second byte range: 0xa1 -- 0xfe # second byte range: 0xa1 -- 0xfe
# no validation needed here. State machine has done that # no validation needed here. State machine has done that
if aStr[0..0] >= "\xA0": if aStr[0..0] >= "\xA0"
return 94 * (aStr[0] - 0xA1) + aStr[1] - 0xa1 return 94 * (aStr[0] - 0xA1) + aStr[1] - 0xa1
else else
return -1 return -1
end end
end end
end end
Expand Down
2 changes: 1 addition & 1 deletion lib/rchardet/charsetgroupprober.rb
Expand Up @@ -40,7 +40,7 @@ def reset
super super
@_mActiveNum = 0 @_mActiveNum = 0


for prober in @_mProbers: for prober in @_mProbers
if prober if prober
prober.reset() prober.reset()
prober.active = true prober.active = true
Expand Down
2 changes: 1 addition & 1 deletion lib/rchardet/escprober.rb
Expand Up @@ -41,7 +41,7 @@ def initialize


def reset def reset
super() super()
for codingSM in @_mCodingSM: for codingSM in @_mCodingSM
next if not codingSM next if not codingSM
codingSM.active = true codingSM.active = true
codingSM.reset() codingSM.reset()
Expand Down
2 changes: 1 addition & 1 deletion lib/rchardet/eucjpprober.rb
Expand Up @@ -56,7 +56,7 @@ def feed(aBuf)
elsif codingState == EItsMe elsif codingState == EItsMe
@_mState = EFoundIt @_mState = EFoundIt
break break
elsif codingState == EStart: elsif codingState == EStart
charLen = @_mCodingSM.get_current_charlen() charLen = @_mCodingSM.get_current_charlen()
if i == 0 if i == 0
@_mLastChar[1] = aBuf[0..0] @_mLastChar[1] = aBuf[0..0]
Expand Down
8 changes: 4 additions & 4 deletions lib/rchardet/jpcntx.rb
Expand Up @@ -150,9 +150,9 @@ def feed(aBuf, aLen)
@_mNeedToSkipCharNum = i - aLen @_mNeedToSkipCharNum = i - aLen
@_mLastCharOrder = -1 @_mLastCharOrder = -1
else else
if (order != -1) and (@_mLastCharOrder != -1): if (order != -1) and (@_mLastCharOrder != -1)
@_mTotalRel += 1 @_mTotalRel += 1
if @_mTotalRel > MAX_REL_THRESHOLD: if @_mTotalRel > MAX_REL_THRESHOLD
@_mDone = true @_mDone = true
break break
end end
Expand All @@ -169,7 +169,7 @@ def got_enough_data


def get_confidence def get_confidence
# This is just one way to calculate confidence. It works well for me. # This is just one way to calculate confidence. It works well for me.
if @_mTotalRel > MINIMUM_DATA_THRESHOLD: if @_mTotalRel > MINIMUM_DATA_THRESHOLD
return (@_mTotalRel - @_mRelSample[0]) / @_mTotalRel return (@_mTotalRel - @_mRelSample[0]) / @_mTotalRel
else else
return DONT_KNOW return DONT_KNOW
Expand Down Expand Up @@ -208,7 +208,7 @@ def get_order(aStr)
return -1, 1 unless aStr return -1, 1 unless aStr
# find out current char's byte length # find out current char's byte length
aStr = aStr[0..1].join if aStr.class == Array aStr = aStr[0..1].join if aStr.class == Array
if (aStr[0..0] == "\x8E") or ((aStr[0..0] >= "\xA1") and (aStr[0..0] <= "\xFE")): if (aStr[0..0] == "\x8E") or ((aStr[0..0] >= "\xA1") and (aStr[0..0] <= "\xFE"))
charLen = 2 charLen = 2
elsif aStr[0..0] == "\x8F" elsif aStr[0..0] == "\x8F"
charLen = 3 charLen = 3
Expand Down
2 changes: 1 addition & 1 deletion lib/rchardet/sjisprober.rb
Expand Up @@ -71,7 +71,7 @@ def feed(aBuf)


@_mLastChar[0] = aBuf[aLen - 1.. aLen-1] @_mLastChar[0] = aBuf[aLen - 1.. aLen-1]


if get_state() == EDetecting: if get_state() == EDetecting
if @_mContextAnalyzer.got_enough_data() and (get_confidence() > SHORTCUT_THRESHOLD) if @_mContextAnalyzer.got_enough_data() and (get_confidence() > SHORTCUT_THRESHOLD)
@_mState = EFoundIt @_mState = EFoundIt
end end
Expand Down
8 changes: 4 additions & 4 deletions lib/rchardet/universaldetector.rb
Expand Up @@ -91,11 +91,11 @@ def feed(aBuf)
end end


@_mGotData = true @_mGotData = true
if @result['encoding'] and (@result['confidence'] > 0.0): if @result['encoding'] and (@result['confidence'] > 0.0)
@done = true @done = true
return return
end end
if @_mInputState == EPureAscii: if @_mInputState == EPureAscii
if @_highBitDetector =~ (aBuf) if @_highBitDetector =~ (aBuf)
@_mInputState = EHighbyte @_mInputState = EHighbyte
elsif (@_mInputState == EPureAscii) and @_escDetector =~ (@_mLastChar + aBuf) elsif (@_mInputState == EPureAscii) and @_escDetector =~ (@_mLastChar + aBuf)
Expand Down Expand Up @@ -138,12 +138,12 @@ def close
end end
@done = true @done = true


if @_mInputState == EPureAscii: if @_mInputState == EPureAscii
@result = {'encoding' => 'ascii', 'confidence' => 1.0} @result = {'encoding' => 'ascii', 'confidence' => 1.0}
return @result return @result
end end


if @_mInputState == EHighbyte: if @_mInputState == EHighbyte
confidences = {} confidences = {}
@_mCharSetProbers.each{ |prober| confidences[prober] = prober.get_confidence } @_mCharSetProbers.each{ |prober| confidences[prober] = prober.get_confidence }
maxProber = @_mCharSetProbers.max{ |a,b| confidences[a] <=> confidences[b] } maxProber = @_mCharSetProbers.max{ |a,b| confidences[a] <=> confidences[b] }
Expand Down
2 changes: 1 addition & 1 deletion lib/rchardet/utf8prober.rb
Expand Up @@ -63,7 +63,7 @@ def feed(aBuf)
end end
end end


if get_state() == EDetecting: if get_state() == EDetecting
if get_confidence() > SHORTCUT_THRESHOLD if get_confidence() > SHORTCUT_THRESHOLD
@_mState = EFoundIt @_mState = EFoundIt
end end
Expand Down

0 comments on commit f54c49e

Please sign in to comment.