Want to show your appreciation and help with hosting costs? Support us on Patreon!
Description: 100MB to 40,572,450 bytes compressor
Submitted on January 18, 2020 at 06:57 AM

input.txt (Text)

nd]], dualism is any of a narrow variety of views about the relationship between mind and matter, which claims that mind and matter are two ontologically separate categories. In particular, mind-body dualism claims that neither the mind nor matter can be reduced to each other in any way, and thus is opposed to [[materialism]] in general, and [[reductive materialism]] in particular. Mind-body dualism can exist as [[substance dualism]] which claims that the mind and the body are composed of a distinct substance, and as [[property dualism]] which claims that there may not be a distinction in substance, but that mental and physical properties are still categorically distinct, and not reducible to each other. This type of dualism is sometimes referred to as "''mind and body''". This is in contrast to [[monism]], which views mind and matter as being ultimately the same kind of thing.  See also [[Cartesian dualism]], [[substance dualism]], [[epiphenomenalism]].

The belief in possessing both a body and a spirit as two separate entities was first documented in approximately 1000 B.C. by Zoroastrianism, and has become a very common view in the present day.

=== Mind-Matter Dualism in Eastern Philosophy ===
During the classical era of [[Buddhist philosophy in India]], philosophers such as [[Dharmakirti]] argue for a dualism between states of consciousness and [[Buddhist atoms]] (Buddhist atoms are merely the basic building blocks that make up reality), according to "the standard interpretation" of Dharmakirti's [[Buddhist metaphysics]]. (See Georges B.J. Dreyfus, ''Recognizing Reality'', [[SUNY Press]], for more information.) Typically, in [[Western philosophy]], dualism is considered to be a dualism between mind (nonphysical) and brain (physical), which ultimately involves mind interacting with pieces of tissue in the brain, and therefore, also interacting, in some sense, with the micro-particles (basic buildling blocks) that make up the brain tissue. Buddhist dualism, in Dharmakirti’s sense, is different in that it is a dualism between not the mind and brain which is made of particles, but rather, between states of consciousness (nonphysical) and basic building blocks (according to the [[Buddhist atomism]] of Dharmakirti, Buddhist atoms are also nonphysical: they are unstructured points of energy). Like so many Buddhists from 600-1000 CE, Dharmakirti’s philosophy involved [[mereological nihilism]], meaning that other than states of consciousness, the only things that exist are momentary quantum particles, much like the particles of [[quantum physics]] ([[quarks]], [[electrons]], etc.).  Dharmakirti’s dualism however has one similarity to Western accounts of mind-body dualism, Dharmakirti’s dualism may also be considered as being not well worked-out, where few philosophers would assert that clear accounts of dualism in either tradition have been given, and many philosophers will assert, following Descartes, that dualism involves serious problems that remain unsolved.

== Usage in philosophy of science ==
In [[philosophy of science]], ''dualism'' often refers to the dichotomy between the "subject" (the observer) and the "object" (the observed). Some critics of Western science see this kind of dualism as a fatal flaw in science. In part, this has something to do with potentially complicated interactions between the subject and the object, of the sort discussed in the [[social construction]] literature.

== Usage in physics ==
''Main Article: [[Wave-particle duality]]''

In [[physics]], ''dualism'' refers generally to the duality of waves and particles.

==Usage in contemporary feminist theory==

An interesting theory relating to dualism and a contemporary feminist world view is presented by [[Susan Bordo]]. Bordo contends that dualism has shaped Western culture since the time of [[Plato]], through [[Augustine of Hippo|Augustine]] and [[Descartes]], up to the present day. 

All three of these philosophers provide instructions, rules or models as to how to gain control over the body, with the ultimate aim of learning to live without it. The mind is superior to the body, and strength comes from disregarding the body's existence to reach an elevated spiritual level.

Bordo believes that the existence of [[anorexia nervosa]] is the most telling and compelling argument that dualism is still a key aspect of modern thinking. She believes it is oftentimes a dangerous way of looking at the world. Those who are [[anorexic]] seek to gain ultimate control, and depriving oneself of food makes one a master of one's own body, which creates a sense of purity and perfection. Again, Bordo contends this stems from dualism, the separation of the mind and body.

==Usage in recent religious and philosophical movements==

In recent years, with world travel and rapid communication systems, the distinction between "eastern" and "western" philosophy has been less significant than in previous times. In the wake of these changes new religious and philosophical movements have drawn freely upon all the world's philosophy to create syntheses and compendia based around [[new age]] and [[holism|holistic]] ideas. Dualism is often cited within these groups, along with ideas of [[Oneness (concept)|Oneness]], [[:Category:Holism|Wholeness]] and [[Theory of multiple intelligences|Theories of multiple intelligences]].

In the [[Emin Society]] (printed in their archives) Dualism is presented as the Law of Two, which is said to have [[Octave|seven levels]]:

* First level: Apparent Opposites
* Second level: The apparent opposites are actually two ends of the same bar (or the North-South [[vector]] is split by the East-West vector) (or the law of things adjacent)
* Third level: [[Pitching]] and [[Yaw|Yawing]], (or [[Basque]] [[bargaining]])
* Fourth level: [[Balance]] and [[Movement]]
* Fifth level: [[Solution|Solve]] and [[Coagulation|Coagulate]]
* Sixth level: Over and Under [[Compensation]]
* Seventh level: Apparent movement between two poles (or [[heat|hot and cold]])

== See also ==
* [[Dualism (philosophy of mind)]]
* [[Advaita]]
* [[Dialectic]]
* [[Monism]]
* [[Non-Dualism]]
* [[Pluralism]]
* [[Reductionism]]

== External links ==
* [http://etext.lib.virginia.edu/cgi-local/DHI/dhi.cgi?id=dv2-05 ''Dictionary of the History of ideas'':] Dualism in Philosophy and Religion
* [http://www.cogwriter.com/two.htm Binitarian View: One God, Two Beings from Before the Beginning] Discusses the biblical and historical belief of the nature of God
* [http://www.renneslechateaubooks.info/languedocdualism/index.htm Books on (Religious) Dualism] Recommendations and Reviews

[[Category:Metaphysics]]
[[Category:Dualism]]

[[ca:Dualisme]]
[[da:Dualisme]]
[[de:Dualismus]]
[[eo:Dualismo]]
[[et:Dualism (täpsustus)]]
[[es:Dualismo]]
[[fr:Dualisme]]
[[hr:Dualizam]]
[[is:Tvíhyggja]]
[[he:דואליזם]]
[[nl:Dualisme]]
[[ja:二元論]]
[[pl:Dualizm (religia)]]
[[ru:Дуализм]]
[[simple:Dualism]]
[[fi:Dualismi]]
[[sv:Dualism]]
[[tr:İkisellik]]
[[zh:二元論]]</text>
    </revision>
  </page>
  <page>
    <title>Dualistic interactionism</title>
    <id>8136</id>
    <revision>
      <id>40126675</id>
      <timestamp>2006-02-18T09:10:18Z</timestamp>
      <contributor>
        <username>Eskimbot</username>
        <id>477460</id>
      </contributor>
      <minor />
      <comment>Robot: Fixing double redirect</comment>
      <text xml:space="preserve">#REDIRECT [[Dualism (philosophy of mind)]]</text>
    </revision>
  </page>
  <page>
    <title>Disaster</title>
    <id>8137</id>
    <revision>
      <id>41768088</id>
      <timestamp>2006-03-01T16:36:14Z</timestamp>
      <contributor>
        <ip>65.249.214.173</ip>
      </contributor>
      <comment>/* External links */</comment>
      <text xml:space="preserve">A '''disaster''' (from [[Latin language|Latin]] meaning, &quot;bad star&quot;) is the impact of a [[natural disaster|natural]] or man-made event that negatively affects [[life]], [[property]], livelihood or [[industry]] often resulting in permanent changes to human [[society|societies]], [[ecosystem]]s and [[natural environment|environment]]. (Note that the event itself is not a disaster; it is the impact which is called a disaster.) Disasters manifest as [[hazard]]s exacerbating [[vulnerable]] conditions and exceeding individuals' and communities' means to survive and thrive.  Most events included herein are compiled from United States Federal Emergency Management Agency and Department of Homeland Security. [http://www.fema.gov/hazards/][http://www.dhs.gov/dhspublic/]

The word's roots imply that when the [[star]]s are in a bad position, a disaster is about to happen. The Latin pejorative ''dis'' and ''astro'', star (L. ''aster''), creating the Italian ''disastro'', which came in to the English language in the 16th century (OED 1590) through the French ''desastre''.

==Natural disasters==
A [[Natural phenomenon]] can easily cause a [[natural disaster]]. Appearing to arise without direct human involvement, natural disasters are sometimes called an [[act of God]]. A [[natural disaster]] may become more severe because of human actions prior, during or after the disaster itself.  A specific disaster may spawn different types of events and may reduce the survivability of the initial event.  A classic example, is an earthquake that collapses homes, trapping people and breaking gas mains that then ignite, and burn people alive while trapped under debris. Human activity in [[risk]] areas may cause natural disasters. Volcanos are particularly prone to causing other events like fires, lahars, mudflows, landslides, earthquakes, and tsunamis.
&lt;br style=&quot;clear:both;&quot;&gt;

===Avalanche===
{{main|Avalanche}}
An [[avalanche]] is a slippage of built-up snow down an incline, possibly mixed with ice, rock, soil or plantlife in what is called a debris avalanche.  Avalanches are categorized as either slab or powder avalanches.  Avalanches are a major danger in the mountains during the winter as a large one can run for miles, and can create massive destruction of the lower forest and anything else in its path.  For example, in [[Montroc, France]], in [[1999]] 300,000 cubic metres of snow slid on a 30 degree slope, achieving a speed of 100 km/h. It killed 12 people in their chalets under 100,000 tons of snow, 5 meters deep.  The Mayor of [[Chamonix]] was charged with manslaughter. [http://www.pistehors.com/articles/avalanche/montroc.htm]
&lt;br style=&quot;clear:both;&quot;&gt;

===Cold===
Extreme cold snaps are hazardous to humans and their livestock.  In a [[2003]] Mongolian cold snap, almost 30,000 livestock animals perished due to excessive snow and cold [http://abob.libs.uga.edu/bobk/ccc/cc012203.html].  When the temperature drops, caloric intake must increase to maintain body heat for shivering [http://www.naturalstrength.com/nutrition/detail.asp?ArticleID=1168].  
&lt;br style=&quot;clear:both;&quot;&gt;

===Disease===
{{main articles|[[Disease]], [[Epidemic]], and [[Pandemic]]}}
Disease becomes a disaster when it spreads in a pandemic or epidemic as a massive outbreak of an infectious agent.  Disease is historically the most dangerous of all natural disasters. Different epidemics are caused by different diseases, and different epidemics have included the [[Black Death]], [[smallpox]], and [[AIDS]]. The [[Spanish flu]] of 1918 was the deadliest ever epidemic, it killed 25-40 million people. The [[Black Death]], which occurred in the [[14th Century]], killed over 20 million people, one third of [[Europe]]'s population.  Plant and animal life may also be affected by disease epidemics and pandemics.
&lt;br style=&quot;clear:both;&quot;&gt;

===Drought===
{{main|Drought}}
A drought is a long-lasting [[weather]] pattern consisting of dry conditions with very little or no [[precipitation (meteorology)|precipitation]]. during this period, [[food]] and [[water]] supplies can run low, and other conditions, such as [[famine]], can result. Droughts can last for several years and are particularly damaging in areas in which the residents depend on [[agriculture]] for survival. The [[Dust Bowl]] is a famous example of a severe drought.
&lt;br style=&quot;clear:both;&quot;&gt;

===Earthquake===
[[Image:SanFranHouses06.JPG|thumb|100px|right|San Francisco]]
{{main articles|[[Earthquake]], [[Foreshock]], and [[Aftershock]]}}
An earthquake is a sudden shift or movement in the [[tectonic plates|tectonic plate]] in the [[Earth|Earth's]] crust. On the surface, this is manifested by a moving and shaking of the ground, and can be massively damaging to poorly built structures. The most powerful earthquakes can destroy even the best built of structures. In addition, they can trigger secondary disasters, such as [[tsunami]]s and volcanic eruptions. Earthquakes occur along [[geologic fault|fault lines]], and are unpredictable. They are capable of killing hundreds of thousands of people, such as in the [[Tangshan earthquake|1976 Tangshan]] and [[2004 Indian Ocean Earthquake|2004 Indian Ocean]] earthquakes.
&lt;br style=&quot;clear:both;&quot;&gt;

===Famine===
{{main|Famine}}
Famine is a natural disaster characterized by a widespread lack of [[food]] in a region, and can be characterized as a lack of [[agricultural|agriculture]] foodstuffs, a lack of [[livestock]], or a general lack of all foodstuffs required for basic [[nutrition]] and survival. Famine is almost always caused by pre-existing conditions, such as [[drought]], but its effects may be exacerbated by social factors, such as [[war]]. Particularly devastating examples include the [[Ethiopian famine]] and the [[Irish Potato Famine]].
&lt;br style=&quot;clear:both;&quot;&gt;

===Fire===
[[Image:Wildfire.jpg|thumb|100px|right|Forest fire]]
{{main articles|[[Bush fire]], [[Fire]], [[Mine fire]], and [[Wildfire]]}}
A fire is a natural disaster that may destroy ecosystems like grasslands, forests causing great loss of life, property, livestock and wildlife.  Bush fires, forest fires and mine fires are generally started by [[lightning]], but also by human negligence or [[arson]], and can burn thousands of square kilometers. An example of a severe forest fire is the [[Oakland Hills firestorm]]. A mine fire started in [[Centralia, Pennsylvania]] in 1962 decimated the town and continues to burn. Some of the biggest city fires are The [[Great Chicago Fire]], The [[Great Fire of London]], and The San Francisco Fire. [http://www.fire-extinguisher101.com/biggest-fires.html]
&lt;br style=&quot;clear:both;&quot;&gt;

===Flood===
[[Image:Flood.jpg|thumb|100px|right|North Carolina 1916]]
{{main|Flood}}
A flood is a natural disaster caused by too much [[rain]] or [[water]] in a location, and could be caused by many different sets of conditions. Floods can be caused by prolonged rainfall from a [[storm]], including [[thunderstorm]]s, rapid melting of large amounts of [[snow]], or [[river]]s which swell from excess precipitation upstream and cause widespread damage to areas downstream, or less frequently the bursting of man-made dams. A [[river]] which floods particularly often is the [[Huang He]] in [[China]], and a particularly damaging flood was the [[Great Flood of 1993]].
&lt;br style=&quot;clear:both;&quot;&gt;

===Hail===
[[image:hailstorm.jpg|thumb|100px|right|Hailstorm]]
{{main|Hailstorm}}
A hailstorm is a natural disaster where a thunderstorm produces a numerous amount of [[hailstone]]s which damage the location in which they fall. Hailstorms can be especially devastating to [[farm]] fields, ruining crops and damaging equipment. A particularly damaging hailstorm hit [[Munich]], [[Germany]] on [[August 31]], [[1986]], felling thousands of trees and causing millions of dollars in [[insurance]] claims.  [[Skeleton Lake]] was named so after 300-600 people were killed by a hailstorm.
&lt;br style=&quot;clear:both;&quot;&gt;

===Heat===
{{main|Heat wave}}
A heat wave is a disaster characterized by [[heat]] which is considered extreme and unusual in the area in which it occurs. Heat waves are rare and require specific combinations of [[weather]] events to take place, and may include [[temperature inversion]]s, [[katabatic winds]], or other phenomena. The worst heat wave in recent history was the [[European Heat Wave of 2003]].
&lt;br style=&quot;clear:both;&quot;&gt;

===Hurricane===
[[Image:Ivan iss.jpg|thumb|100px|right|Hurricane Ivan]]
{{main|Tropical cyclone}}
A hurricane is a low-pressure cyclonic [[storm]] system which forms over the oceans. It is caused by evaporated [[water]] which comes off of the [[ocean]] and becomes a [[storm]]. The [[Coriolis Effect]] causes the storms to spin, and a hurricane is declared when this spinning mass of storms attains a wind speed greater than 74mph. In different parts of the world hurricanes are known as cyclones or typhoons. The former occur in the [[Indian Ocean]], while the latter occur in the Eastern [[Pacific Ocean]]. The most damaging hurricane in the United States was [[Hurricane Katrina]], which hit the United States Gulf Coast in [[2005]].
&lt;br style=&quot;clear:both;&quot;&gt;

===Hypernova===
A [[hypernova]] is the universe's most extreme and cataclysmic force. A hypernova is when a [[hypergiant]] star (a star at least 95-210 times bigger than our own [[Sun]]) explodes suddenly. A hypernova may have been the cause of the [[Ordovician-Silurian extinction events]]. When a hypergiant exploded, it sent a  large [[gamma-ray burst]] to Earth destroying 90-95% of all living species on Earth at that time. A hypergiant star within at least 1500-2000 [[lightyears]] from Earth, when it explodes to a hypernova, is an automatic Earth extinction event. All species would be wiped out. The nearest hypergiant ,that could explode within 10000 to 2 million years from now, is [[Eta Carinae]]. 
&lt;br style=&quot;clear:both;&quot;&gt;

===Impact event===
[[Image:Impact event.jpg|thumb|100px|right|Artist's impression]]
{{main|Impact event}}
Impact events are caused by the [[collision]] of large [[meteoroid]]s, [[asteroid]]s or [[comet]]s (generically: [[bolide]]s) with [[Earth]] and may sometimes be followed by [[mass extinction]]s of life. The magnitude of the disaster is inversely proportional to its rate of occurrence, because small impactors are much more numerous than large ones.
&lt;br style=&quot;clear:both;&quot;&gt;

===Limnic eruption===
{{main|Limnic Eruption}}
[[Image:Lake_nyos.jpg|thumb|100px|right|Lake Nyos, Cameroon]]
A Limnic eruption is a sudden release of asphyxiating or inflammable gas from a lake.  Three lakes are at risk of limnic eruptions, [[Lake Nyos]], [[Lake Monoun]], and [[Lake Kivu]].  A [[1986]] limnic eruption of 1.6 million tonnes of CO&lt;sub&gt;2&lt;/sub&gt; from Lake Nyos suffocated 1,800 people in a 20 mile radius.  In [[1984]], a sudden outgassing of CO&lt;sub&gt;2&lt;/sub&gt; had occurred at Lake Monoun, killing 37 local residents.  Lake Kivu, with concentrations of methane and CO&lt;sub&gt;2&lt;/sub&gt;, has not experienced a limnic eruption during recorded history, but is suspected of having periodic eruptions every 1,000 years.  
&lt;br style=&quot;clear:both;&quot;&gt;

===Landslide===
{{main|Landslide}}
A landslide is a disaster closely related to an [[avalanche]], but instead of occurring with [[snow]], it occurs involving actual elements of the ground, including rocks, [[tree]]s, parts of houses, and anything else which may happen to be swept up. Landslides can be caused by [[earthquake]]s, [[volcanic eruption]]s, or general instability in the surrounding land. Mudslides, or mud flows, are a special case of landslides, in which heavy rainfall causes loose soil on steep terrain to collapse and slide downwards (see also [[Lahar]]); these occur with some regularity in parts of [[California]] after periods of heavy rain.
&lt;br style=&quot;clear:both;&quot;&gt;

===Mudslide===
{{main|Mudslide}}
A mudslide is a slippage of mud because of poor drainage of [[rainfall]] through soil.  An underlying cause is often deforestation or lack of vegatation.  Some mudslides are massive and can decimate large areas.  On January 10, 2005 at 1:20pm in [[La Conchita]], a massive mudslide buried four blocks of the town in over 30 feet of earth. Ten people were killed by the slide and 14 were injured. Of the 166 homes in the community, fifteen were destroyed and 16 more were tagged by the county as uninhabitable.
&lt;br style=&quot;clear:both;&quot;&gt;

===Sink hole===
{{main|Sinkhole}}
A sinkhole is  a localized depression in the surface topography, usually caused by the collapse of a subterranean structure, such as a [[cave]]. Although rare, large sinkholes that develop suddenly in populated areas can lead to the collapse of buildings and other structures.
&lt;br style=&quot;clear:both;&quot;&gt;

===Solar flare===
{{main|Solar flare}}
[[Image:Solar flare.jpg|thumb|100px|right|Solar flare]]
A solar flare is a violent explosion in the [[Sun]]'s atmosphere with an energy equivalent to tens of millions of [[hydrogen bomb]]s. Solar flares take place in the solar [[corona]] and [[chromosphere]], heating the gas to tens of millions of kelvins and accelerating electrons, protons and heavier ions to near the speed of light. They produce electromagnetic radiation across the spectrum at all wavelengths from long-wave radio signals to the shortest wavelength gamma rays.  Solar flare emmissions are a danger to orbitting satellites, manned space missions, communications systems, and power grid systems.[http://www.space.com/businesstechnology/technology/soho_impact_030623.html]
&lt;br style=&quot;clear:both;&quot;&gt;

===Storm surge===
{{main|Storm surge}}
A storm surge is an onshore rush of water associated with a low pressure weather system, typically a [[tropical cyclone]]. Storm surge is caused primarily by high winds pushing on the ocean's surface. The wind causes the water to pile up higher than the ordinary sea level.  Storm surges are particularly damaging when they occur at the time of a [[tide|high tide]], combining the effects of the surge and the tide.  The highest storm surge ever recorded was produced by the [[1899]] Bathurst Bay Hurricane, which caused a 13 m (43 feet) storm surge at [[Bathurst Bay]], [[Australia]]. In the US, the greatest recorded storm surge was generated by [[Hurricane Katrina]], which produced a storm surge of 9 m (30 feet).
&lt;br style=&quot;clear:both;&quot;&gt;

===Thunderstorm===
{{main|Thunderstorm}}
[[Image:Rolling-thunder-cloud.jpg|thumb|100px|right|A thunderstorm]]
A thunderstorm is a form of [[severe weather]] characterized by the presence of [[lightning]] and its attendant [[thunder]], often accompanied by copious [[rainfall]], [[hail]] and on occasion [[snowfall]] and [[tornado|tornadoes]].
&lt;br style=&quot;clear:both;&quot;&gt;

order2_u.py (Python)

#!/usr/bin/env python
# coding: utf-8

# In[19]:


import pickle
import os
import sys
from datetime import datetime


# In[ ]:


def update_ranges(range_low,range_high):
    digits = []
    while True:
        if int(range_low * 10) == int(range_high*10):
            digits.append((str(int(range_low*10))))
            range_low = range_low*10
            range_high = range_high*10
            range_low = range_low % 1
            range_high = range_high % 1
        else:
            break
    return range_low,range_high,digits

def reset_ranges(counter_dict,range_low,range_high):
    diff = range_high - range_low
    for first_char in counter_dict.keys():
        for second_char in counter_dict[first_char].keys():
            high = 0
            low = range_low
            for prediction_char in sorted(counter_dict[first_char][second_char].keys()):
                    value = counter_dict[first_char][second_char][prediction_char]
                    per = value[1]
                    high = low + per * diff
                    value[2] = (low,high)
                    counter_dict[first_char][second_char][prediction_char] = value
                    low = high
                
def decode_from_dict(counter_dict,sorted_keys,value,genesis_chars,low,high):
    
    found = False

    keys = sorted_keys[genesis_chars[0]][genesis_chars[1]]
    high_len = len(keys) -1 
    low_len = 0

    while(low_len <= high_len):

        mid = (low_len + high_len)//2

        range_low,range_high = get_range(counter_dict,genesis_chars[0],genesis_chars[1],keys[mid],low,high)

        if value>=range_low and value<=range_high:
            return range_low,range_high, keys[mid]

        elif range_high<=value:
            low_len = mid + 1

        else:
            high_len = mid - 1 

    if not found:
        print('Not found... value = ',value)
        return -1,-1,None

def get_sorted_keys(counter_dict):
    sorted_keys = {}
    for first_char in sorted(counter_dict.keys()):
        sorted_keys[first_char] = {}
        for second_char in sorted(counter_dict[first_char].keys()):
            sorted_keys[first_char][second_char] = []
            for prediction_char in sorted(counter_dict[first_char][second_char].keys()):
                sorted_keys[first_char][second_char].append(prediction_char)
    
    return sorted_keys


def get_range(counter_dict,first_char,second_char,prediction_char,low,high):
    static_low,static_high = counter_dict[first_char][second_char][prediction_char][2]
    diff = high - low
    new_low = (static_low * diff) + low
    new_high = (static_high * diff) + low
    return new_low, new_high

# In[2]:


def uncompress(compression_files_dir):
    abs_path = os.path.abspath(compression_files_dir)
    
    with open(os.path.abspath(abs_path +'/'+'dictionary.pickle'),'rb') as file:
        counter_dict = pickle.load(file)

    for first_char in sorted(counter_dict.keys()):
        for second_char in sorted(counter_dict[first_char].keys()):
            second_char_count = sum([v for k,v in counter_dict[first_char][second_char].items()])
            for prediction_char in sorted(counter_dict[first_char][second_char].keys()):
                value = counter_dict[first_char][second_char][prediction_char]
                per = value/second_char_count
                counter_dict[first_char][second_char][prediction_char] = [value,per,(0,0)]

    with open(os.path.abspath(abs_path +'/'+'integer_value.pickle'), 'rb') as f:
        value_str = str(pickle.load(f))
    with open(os.path.abspath(abs_path +'/'+'genesis_chars.pickle'),'rb') as f:
        genesis_chars = pickle.load(f)
    with open(os.path.abspath(abs_path +'/'+'len_of_text'),'rb') as f:
        len_of_text = pickle.load(f)

    value = float('0.'+value_str[:19])
    #Reset ranges
    reset_ranges(counter_dict,0.0,1.0)
    sorted_keys = get_sorted_keys(counter_dict)

    count = 0
    output = [genesis_chars[0],genesis_chars[1]]
    range_low = 0.0
    range_high = 1.0
    print(len_of_text)
    for i in range(len_of_text):

        range_low,range_high,key = decode_from_dict(counter_dict,sorted_keys,value,genesis_chars,range_low,range_high)

        if range_low == range_high == -1:
            break
        output.append(key)
        genesis_chars = genesis_chars[1]+key
        
        range_low,range_high,ls = update_ranges(range_low,range_high)

        if ls:
            count += len(ls)
            value = float('0.'+value_str[count:count+19])

    output_str = ''.join(output)



    output_str = ''.join(output)

    with open(os.path.abspath(os.getcwd()+'/'+'output.txt'),'w',encoding='utf-8') as f:
        f.write(output_str)


# In[ ]:


if __name__ == '__main__':
    if (len(sys.argv)!= 2):
        print('Please give path to directory containing compression files!')
        exit()
    filepath = os.path.abspath(sys.argv[1])
    
    uncompress(filepath)

order2_c.py (Python)

#!/usr/bin/env python
# coding: utf-8

# In[3]:


import pickle
import os
import sys
from datetime import datetime


# In[ ]:

def update_ranges(range_low,range_high):
    digits = []
    while True:
        if int(range_low * 10) == int(range_high*10):
            digits.append((str(int(range_low*10))))
            range_low = range_low*10
            range_high = range_high*10
            range_low = range_low % 1
            range_high = range_high % 1
        else:
            break
    return range_low,range_high,digits

def reset_ranges(counter_dict,range_low,range_high):
    diff = range_high - range_low
    for first_char in counter_dict.keys():
        for second_char in counter_dict[first_char].keys():
            high = 0
            low = range_low
            for prediction_char in sorted(counter_dict[first_char][second_char].keys()):
                    value = counter_dict[first_char][second_char][prediction_char]
                    per = value[1]
                    high = low + per * diff
                    value[2] = (low,high)
                    counter_dict[first_char][second_char][prediction_char] = value
                    low = high

# In[4]:
def get_range(counter_dict,first_char,second_char,prediction_char,low,high):
    static_low,static_high = counter_dict[first_char][second_char][prediction_char][2]
    diff = high - low
    new_low = (static_low * diff) + low
    new_high = (static_high * diff) + low
    return new_low, new_high
    

def compress(filepath):
    
    try:
        with open(filepath,'r',encoding='utf-8') as f:
            text = f.read()
    except:
        print('Could not read the file!')
        return
    try:
        os.mkdir(os.path.abspath(os.getcwd()+'/'+'compression_files'))
    except:
        pass
        
    counter_dict = {}

    for i in range(len(text)-2):
        first_char = text[i]
        second_char = text[i+1]
        prediction_char = text[i+2]

        if first_char in counter_dict:
            if second_char in counter_dict[first_char]:
                if prediction_char in counter_dict[first_char][second_char]:
                    counter_dict[first_char][second_char][prediction_char] += 1
                else:
                    counter_dict[first_char][second_char][prediction_char] = 1
            else:
                counter_dict[first_char][second_char] = {prediction_char:1}
        else:
            counter_dict[first_char] = {second_char:{prediction_char:1}}

    #Save the dictionary
    with open(os.path.abspath(os.getcwd())+'/'+'compression_files'+'/'+'dictionary.pickle','wb') as file:
        pickle.dump(counter_dict,file,protocol=pickle.HIGHEST_PROTOCOL)

    for first_char in sorted(counter_dict.keys()):
        for second_char in sorted(counter_dict[first_char].keys()):
            second_char_count = sum([v for k,v in counter_dict[first_char][second_char].items()])
            for prediction_char in sorted(counter_dict[first_char][second_char].keys()):
                value = counter_dict[first_char][second_char][prediction_char]
                per = value/second_char_count
                counter_dict[first_char][second_char][prediction_char] = [value,per,(0,0)]
    
    value_ls = []
    genesis_chars = text[0] + text[1]

    reset_ranges(counter_dict,range_low=0.0,range_high=1.0)
    range_low = 0.0
    range_high = 1.0

    for i in range(len(text)-2):
        first_char = text[i]
        second_char = text[i+1]
        prediction_char = text[i+2]

        range_low,range_high = get_range(counter_dict,first_char,second_char,prediction_char,range_low,range_high)

        #update range
        range_low,range_high,ls = update_ranges(range_low,range_high)
        value_ls += ls

    value = (range_low + range_high)/2
    value_str = str(value)[2:4]
    value = '0.'+''.join(value_ls)+value_str
    tostore = int(value[2:])

    with open(os.path.abspath(os.getcwd())+'/'+'compression_files'+'/'+'integer_value.pickle', 'wb') as f:
        pickle.dump(tostore, f)
    with open(os.path.abspath(os.getcwd())+'/'+'compression_files'+'/'+'genesis_chars.pickle','wb') as f:
        pickle.dump(genesis_chars,f)
    with open(os.path.abspath(os.getcwd())+'/'+'compression_files'+'/'+'len_of_text','wb') as f:
        pickle.dump(len(text)-2,f)

    print('Compression successful!')


# In[5]:


if __name__ == '__main__':
    if (len(sys.argv)!= 2):
        print('Please give input file path! (or just name, if file in current directory)')
        exit()
    filepath = os.path.abspath(sys.argv[1])
    compress(filepath)

# In[ ]: