import os
import sys
sys.path.append(os.path.join(os.path.dirname(__file__), '../'))
import unittest
from vlite2 import VLite2


class TestVLite(unittest.TestCase):
    def setUp(self):
        self.vlite = VLite2()
        self.long_data = ['Manage Work 43\nagile engineering approach now more common than \never, where all team members are required to be \npresent in the meeting (not just the team lead), it is \nvery important for us to utilize meetings properly. \nBecause of the large number of attendees, meeting \ninefficiency wastes a lot of time for everyone.\nIn most cases, we can actually discuss a lot of \ninformation in 30 minutes. TED talk videos are a \ngreat example of how a lot of information can be \nshared in a short time. TED talks only last for 18 \nminutes (standard format for a TED presentation).\nFor example, there is a TED talk video by Dr Atul \nGawande of Harvard Medical School that discusses \nthe importance of checklists in avoiding mistakes. \nIn just 18 minutes, Dr Gawande provides a lot of \ninformation, with examples and supporting data, in \na very compelling manner.\nIn his talk Dr Gawande discusses two types of \nmistakes. The first type is an error of ignorance \nwhere we make a mistake because we know too \nlittle. This type of mistake can be cured through \ntraining. The second type is an error where we \ndo not properly use what we already know. \nDr Gawande reasons that the second type of mistakes \nare common because the volume and complexity of \nknowledge today is very large. For most of us, the \nvolume and complexity of knowledge exceeds our \nability to consistently deliver it correctly and safely. \nBy using proper checklists, we can dramatically \nreduce the instances of the second type of mistakes. \nDr Gawande mentions how he helped create a 2-', 'Notes\n1. John P. Kotter, The New Rules: How to Succeed in \nToday’s Post-Corporate World (Simon and Schuster, \n1995).\n2. Jim Collins, Good to Great: Why Some Companies \nMake the Leap...and Others Don’t (Harper Collins, \n2001).\n3. Thomas Friedman, The Lexus and the Olive Tree: \nUnderstanding Globalization (Picador, 2012).\n4. Peter Diamandis explains why we can look forward \nto abundance in our future in his inspiring TED \ntalk,  \nabundance_is_our_future.htmlhttp://www.ted.com/talks/peter_diamandis_\n5. http://articles.economictimes.indiatimes.com/2013- \n04-02/news/38218110_l_engineering-colleges- \nindia-big-draw\n6.  \nslide-show -1 -career-only - 10-percent-mbas- \nemployable/20130131 .htm# 1http://www.rediff.com/getahead/slide-show/\n7. Julie Bick, All I Really Need To Know In Business \nI Learned At Microsoft: Insider Strategies To Help \nYou Succeed (New York: Pocket Books, 1997), p. \n150.', 'XX Preface\nsoftware industry. However, some of the ideas may \nbe relevant for other industries.\nThis book is different in that I wrote, it as the \nactive CEO of MAQ Software. This is not a memoir \nor a reflection of someone long retired. I think that \nmany leaders can share their experiences to serve as \npositive role models.\n‘How long have you been working on the book?’ \na college student recently asked me when I handed \nhim a printed copy. Earnestly, I answered, ‘All my \nlife.’ While it took me only three months to write \nthe book, it’s taken a lot longer to learn and practice \nthe ideas inside.\nMany years ago Benjamin Franklin said, ‘Either \nwrite something worth reading, or do something \nworth writing.’ I hope that you do both.', 'Preface\n‘The best way to become acquainted with a subject \nis to write a hook about it. ’\n— BENJAMIN DISRAELI\nFormer British Prime Minister and novelist\nhy did I write the book?\nA few years ago, as I finished my company\nupdate to the new graduates, who had just joined, I \nwas optimistic about the prospects of the company \n(the 2008 economic crisis had not hit yet). Many \nof the new graduates were eager, motivated, and \nexcited to hear from me.\nAfter my discussion, one of the graduates cornered \nme and asked, ‘What is the secret to your success?’ \nI was speechless. I had never thought about that \nquestion. MAQ Software was a young company \ntrying to survive in a very competitive market. \nAlthough we were a successful company, I did not \nhave a ready answer for such a naive graduate \nwith such large expectations. She was serious and \nexpected something like a really thoughtful mantra. \nThe problem was that success is more than one tip.', '162 What I Did Not Learn at IIT\nCITE, SIGHT, SITE\n4 A good research paper will cite more than one \nauthority on a subject, (use as proof)\n❖ Amitabh Bachchan was in the moviegoers’ line \nof sight, (vision, act of seeing)\n4 Raj Ghat is the site of a memorial to Gandhi, \n(location)\nCOMPLEMENT, COMPLIMENT\n4 Riti’s shoes complement her dress, (completion)\n4 I complimented Riti on her shoes, (praise)\nDISCREET, DISCRETE\n4 He was discreet about his co-worker’s perfor\xad\nmance review, (carefully quiet)\n4 She provided two discrete examples, (separate, \ndistinct)\nFEWER, LESS\n4 Fewer people than last year voted, (fewer in \nnumber)\n4 Less money was donated than they expected, \n(less in amount)\nIMPLY, INFER\n4 The speaker implies the economy is growing, \n(suggests)\n4 The hearer infers that the speaker believes the \neconomy is growing, (gathers, concludes)']
        self.long_data_2 = ["28 \n One of the notable characteristics of legal science is its emphasis on definitions, classifications, and a \nprecise legal vocabulary. Scholars strive for the validity of concepts and classes, treating them as \nexpressio ns of scientific truth rather than conventional or utilitarian constructs  . \nLegal science seeks to be pure and value -free, focusing solely on legal phenomena and excluding influences \nfrom social sciences or historical context. It emphasizes legal values suc h as certainty in the law and \nexcludes considerations of justice or societal ends, which are seen as the domain of legal philosophy  . \nDespite criticism and various reactions, legal science continues to dominate legal scholarship in civil law \njurisdictions. It is deeply ingrained in legal education, textbooks, and the legal system itself. While the \ncommon law tradition has not fully embraced legal science, occasional trends towards its thinking have \nbeen observed . \nOverall, legal science represents a systemati c and highly abstract approach to studying and understanding \nthe law within the civil law tradition. It has had a profound influence on legal scholarship and the legal \nsystems of many countries . \n \nReading 7    \nשיעור שני  \nLegrone: how legrone views the purpos e of comparative law   ? \nLagron sees the benefits of comparative law – it helps us see our society in a better way  . \nEven the word judge means different things in different countries. If we wont have the understanding that \nthis things are different between c ountries, it will be very hard for us to communicate   . \n- According to lagron, we should look at the wider picture, not only the legal system, but the legal \nculture  . \n- LaGrone opens us to an external perspective. He says we should look at the legal system inside the \nbroader cultural, economical and social aspects . \n- Lagrone says no law is shaped by history. We have difference that changes overtime  . \n- Lagrone talks about  the idea of contingency. The law reflects the values of the society we live in   . \nKey aspects of the development of civil law tradition  : \nTradition was roughly speaking around the year 1000 it's really in this. That these three separate traditions \nof Roman law Canon law commercial law begin to develop in ways that lead to their eventual kind of \nconvergence and I think really really importantly it's at around exactly this time you know give or take the \nyear 1000 that we can begin to see the origins of what wi ll become the major European states right so the \nFrench capetian monarchy right begins in the late ten 10th century the holy Roman Empire which is where \nwe get modern Germany right that is typically dated to starting in 962 England in its modern form with the \nNorman conquest that takes place in 1066 and this is really crucial right in the west law and the state \nemerged at the same time and law is central to the project of state building in the west right and i think this \nis this is really key for understand ing law in the west  . \nRoman law: I mean as Roman law in its modern incarnation Roman law as we discovered after the fall of the \nRoman Empire right so the Roman Empire after surviving for like 5 centuries collapses around the 5th and \n6th centuries when we ha ve an invasion of various Germanic tribes right coming from the the the North \nEast and north and for another five centuries or so from the collapse of Rome we have the period of the \nearly Middle Ages that used to be called the dark ages that is no longer t he politically correct term right but", '110 \n the diminishing importance of religious obligations, and the regulation of family relationships by the state. \nNationalism played a role in the revolution, aiming to establish national legal systems that reflected national \nideals and unity.  \nWhile the revolution brought about significant changes and introduced important ideas, it also had some \nexaggerations and utopian aspirations. The legal systems in many civil law countries bear the influence of the \nfervent utopianism of t he French Revolution, including the emphasis on the separation of powers, the \nestablishment of administrative courts, and the distinction between public and private law.  \nOverall, the revolution had a profound impact on public law, the organization and admi nistration of legal \nsystems, and the principles and concepts embedded in the basic codes of civil law jurisdictions.  \nThe passage discusses the sources of law in civil law and common law traditions. In civil law systems, the \nprimary sources of law are statu tes enacted by the legislative power, regulations issued by administrative \nagencies, and custom. The legislative power holds a monopoly on lawmaking, and judicial decisions are not \nconsidered law. The passage also mentions the growing influence of constitu tionalism, with written \nconstitutions gaining importance as a source of law and constitutional courts exercising judicial review. In \ncontrast, common law systems rely on a combination of statutes, judicial decisions, and customary practices. \nThe distinctio n between civil law and common law systems cannot be simply reduced to the presence or absence \nof codes. The ideology behind codification in civil law systems is rooted in the French Revolution and seeks to \nestablish a new legal order by repealing prior la w and unifying diverse legal systems.  \nIn the common law world, judges are highly respected and influential figures who shape and interpret the law \nthrough their decisions. They are seen as culture heroes and their names are well -known. Judges in this system \nhave broad interpretative powers, including the ability to review administrative actions and declare legislation \nunconstitutional. Common law judges often have successful legal careers before being appointed or elected to \nthe bench, and their positi ons bring them respect, prestige, and public attention.  \nIn contrast, judges in the civil law world have a different role and status. They are considered civil servants and \nfunctionaries rather than culture heroes. Civil law judges are selected from the ran ks of the professional \njudiciary, typically through a state examination or attendance at a special school for judges. They rise in the \njudiciary based on demonstrated ability and seniority, and their salaries and working conditions are a focus of \ntheir pro fessional organization. Lateral entry into the judiciary is rare, and judges are primarily selected from \nwithin the judiciary itself.  \nThe different status of civil law judges can be traced back to the historical development of the civil law tradition, \nwher e judges were not prominent figures of the law and had limited power. With the establishment of rigid \nconstitutions and the introduction of judicial review in some civil law jurisdictions, the role of judges has \nevolved to include constitutional review. Ho wever, the traditional image of civil law judges as bureaucratic \ncivil servants performing mechanical functions still persists to some extent.  \nIn recent years, there has been a trend towards increased judicial scope and power in the civil law tradition. \nSpecial constitutional courts have been established in some jurisdictions, and ordinary judges can reject the \napplication of statutes if they consider them unconstitutional. Scholars and the media have noted a growing \njudicial protagonism in some civil law c ountries, and the role of judges is being reexamined and analyzed.', '109 \n of enacted propositions rather than practical knowledge. The idea of a common European legal system has been \npromoted by various individuals and institutions, with proposals for a European Code of Private Law and \nEuropean restatements of contr act law. However, the author challenges the notion of convergence, arguing that \nfocusing solely on rules and concepts overlooks the ephemeral and contingent nature of laws. Rules are seen as \nbrittle and lacking universal merit, while concepts are seen as p eremptory instruments that do not fully capture \nthe complexity of legal systems.  \nThe text argues that to understand societies and the legal cultures they have produced, one must move away \nfrom rules and concepts and focus on habits and customs. The author suggests that a synecdochic view of the \nlaw, where rules and concepts represent the whole, is insufficient. Instead, the focus should be on the cognitive \nstructure and epistemological foundations of a legal culture, referred to as the "legal mentality." Th e author \nemphasizes the importance of examining assumptions, attitudes, aspirations, and antipathies to uncover the \ndeep structures of legal rationality. The text further discusses the differences between common law and civil \nlaw mentalities and asserts th at these differences are irreducible at the epistemological level. The author argues \nagainst the idea of European legal integration, stating that the differences between legal mentalities make \nconvergence impossible. The text highlights the significance of  longue durée and the interiorization of culture \nin understanding legal mentalities. The author acknowledges the pluralistic nature of industrial societies and \naims to identify a representative common core within legal cultures. Overall, the text emphasize s the importance \nof cognitive structures and epistemological differences in studying legal cultures and rejects the notion of \nconvergence between common law and civil law traditions.  \n \nReading 6 – The Revolution  \nThe passage discusses the impact of a revolution that occurred in the West starting in 1776, which influenced \nthe development of public law in civil law jurisdictions. This revolution, encompassing events such as the \nAmerican and French revolutions, the Italian Risorgimento, and the liberation  movements in Latin America, \nbrought about a fundamental intellectual and social revolution. It challenged long -established ideas about \ngovernment and the individual and introduced new ways of thinking about humanity, society, the economy, and \nthe state.  \nThe revolution led to significant changes in public law and also influenced the form, application, and content \nof the basic codes derived from Roman and jus commune sources. One of the driving forces behind the \nrevolution was secular natural law, which emph asized the equality of all individuals and their natural rights to \nproperty, liberty, and life. The revolution also promoted the separation of governmental powers, particularly \nthe separation of legislative, executive, and judicial powers. This separation aimed to prevent the judiciary from \ninterfering in lawmaking and the execution of laws.  \nThe revolution had a different impact on public law in different regions. In France, for example, it targeted the \njudicial aristocracy due to their alignment with the l anded aristocracy and their blurred distinction between \napplying and making law. In contrast, the United States and England had a different judicial tradition, with \njudges often playing a progressive role in protecting individuals against abuse of power an d contributing to the \ncentralization of governmental power.  \nThe revolution was characterized by an emphasis on reason, individual rights, and the transition from feudalism \nto contract -based relationships. It also glorified the secular state, leading to the  abolition of feudal obligations,', '25 \n The text  : \nHe is talking about an evolution between the French code and the present, he is talking about Europe and \nthe US. He thinks that it is very common in 1900 that _______, it was an age that people that though about \nthe law in a positive way, the law was the law of the people. It\'s connected to normative point: he said they \nscrew us up, there is no way to see  the law in a positive way, to understand it you have to break. What came \nout of it? He will say that we can do comparative law for understanding the best solution for legal problems. \nWe supposed to help each other find the right answer, like there is one .  \nWhat is the law? What is the unit that he\'s is rules, legal rules. This fits the science model, formalistic   . \nHow do you think of law comparing that change over time? He\'s looking for progress, working with each \nother to get better answers   . \nIs that real ly the case? Who define what the best law is? There is different ideas and there are different \nproblems in the world . \nSummary    : \n       \n \nReading 5 – European legal systems are not converging  \nThe text discusses the convergence of European legal systems. It n otes that economic factors have led \nWestern European countries to pursue a supra -national legal order, resulting in the creation of the \nEuropean Community. While most of these countries follow the "civil law" tradition, the European \nCommunity\'s focus on ha rmonization and integration has led to the development of a complex network of \ninterconnected laws and regulations. The text suggests that a common European law, or "corpus juris \nEuropaeum," would likely consist of enacted propositions rather than practica l knowledge. The idea of a \ncommon European legal system has been promoted by various individuals and institutions, with proposals \nfor a European Code of Private Law and European restatements of contract law. However, the author \nchallenges the notion of con vergence, arguing that focusing solely on rules and concepts overlooks the \nephemeral and contingent nature of laws. Rules are seen as brittle and lacking universal merit, while \nconcepts are seen as peremptory instruments that do not fully capture the compl exity of legal systems  . \nThe text argues that to understand societies and the legal cultures they have produced, one must move \naway from rules and concepts and focus on habits and customs. The author suggests that a synecdochic \nview of the law, where rules and concepts represent the whole, is insufficient. Instead, the focus should be \non the cognitive structure and epistemological foundations of a legal culture, referred to as the "legal \nmentality." The author emphasizes the importance of examining ass umptions, attitudes, aspirations, and \nantipathies to uncover the deep structures of legal rationality. The text further discusses the differences \nbetween common law and civil law mentalities and asserts that these differences are irreducible at the \nepistem ological level. The author argues against the idea of European legal integration, stating that the \ndifferences between legal mentalities make convergence impossible. The text highlights the significance of \nlongue durée and the interiorization of culture in  understanding legal mentalities. The author acknowledges \nthe pluralistic nature of industrial societies and aims to identify a representative common core within legal \ncultures. Overall, the text emphasizes the importance of cognitive structures and episte mological \ndifferences in studying legal cultures and rejects the notion of convergence between common law and civil \nlaw traditions  .', '111 \n Overall, while common law judges are seen as central figures in shaping and interpreting the law, civil law \njudges traditionally have more limited roles and are viewed as functionaries. How ever, there are ongoing \nchanges and developments in the civil law tradition that are expanding the scope and power of judges.  \nLegal science, also known as systematic jurisprudence or conceptual jurisprudence, is a dominant school of \nthought within the civi l law tradition. It emerged in the 19th century and is primarily associated with German \nlegal scholars. Legal science emphasizes the scientific study of law and seeks to discover inherent principles \nand relationships within legal materials. It aims to crea te a systematic and coherent legal structure by developing \nabstract concepts and classifications.  \nThe scholars of legal science focused on the principles of Roman civil law, particularly as it existed in Germany, \nand produced highly systematic treatises ba sed on their study of the Digest of Justinian. Their work culminated \nin the promulgation of the German Civil Code in 1896, which had a significant influence on legal scholarship \nworldwide.  \nLegal science adopts a highly systematic and logical approach, simi lar to that of natural sciences. It employs \nformal logic and logical expansion to reason from specific cases and principles to broader principles and \ntheories. This process aims to create a general theory of law that is abstract and detached from concrete \nproblems.  \nOne of the notable characteristics of legal science is its emphasis on definitions, classifications, and a precise \nlegal vocabulary. Scholars strive for the validity of concepts and classes, treating them as expressions of \nscientific truth rather  than conventional or utilitarian constructs.  \nLegal science seeks to be pure and value -free, focusing solely on legal phenomena and excluding influences \nfrom social sciences or historical context. It emphasizes legal values such as certainty in the law and excludes \nconsiderations of justice or societal ends, which are seen as the domain of legal philosophy.  \nDespite criticism and various reactions, legal science continues to dominate legal scholarship in civil law \njurisdictions. It is deeply ingrained in legal education, textbooks, and the legal system itself. While the common \nlaw tradition has not fully embraced legal science, occasional trends towards its thinking have been observed.  \nOverall, legal science represents a systematic and highly abstract appr oach to studying and understanding the \nlaw within the civil law tradition. It has had a profound influence on legal scholarship and the legal systems of \nmany countries.  \n \n \nReading 8 - The Current State of Legal Education Reform in Latin America: A Critical Appraisal Juny \nMontoya  \nThe article discusses the current state of legal education reform in Latin America. It highlights the challenges \nof inequality and social exclusion in the region and the need for lawyers who are equipped to address these \nissues. Trad itional legal education is criticized for leaving lawyers ill -prepared for these challenges. The article \nexamines efforts to reform legal education in several Latin American countries, including Brazil, Chile, \nArgentina, Mexico, Colombia, and Venezuela. It  explores the characteristics of legal education in the region']

    def test_memorize(self):
        self.vlite.memorize(text=self.long_data_2)
        print("[test_memorize] memorized")
        self.vlite.remember(text="civil law")
        print("[test_memorize] remembered")
        self.vlite.remember(text="Overall, while common law judges are seen as central figures in shaping and interpreting the law, civil law judges traditionally have more limited roles and are viewed as functionaries. How ever, there are ongoing changes and developments in the civil law tradition that are expanding the scope and power of judges. Legal science, also known as systematic jurisprudence or conceptual jurisprudence, is a dominant school of thought within the civi l law tradition. It emerged in the 19th century and is primarily associated with German legal scholars. Legal science emphasizes the scientific study of law and seeks to discover inherent principles and relationships within legal materials. It aims to crea te a systematic and coherent legal structure by developing")
        print("[test_memorize] remembered 2")

    def test_autocut(self):
        self.vlite.memorize("Hello there")
        self.vlite.memorize("I am obi wan")
        self.vlite.memorize("Ray Del Vecchio")
        self.vlite.memorize("Ivan is cool")
        self.vlite.memorize("What's up")
        self.vlite.memorize("Testing these functions")
        self.vlite.memorize("Vectors are lit")
        self.vlite.memorize("Minecraft")
        print(self.vlite.remember('Star Wars', top_k=1, autocut=True))
        print("[test_autocut] with 1 cluster")
        print(self.vlite.remember('Star Wars', top_k=2, autocut=True))
        print("[test_autocut] with 2 clusters")
        print(self.vlite.remember('Star Wars', top_k=3, autocut=True, get_metadata=True, get_similarities=True))
        print("[test_autocut] with 3 clusters")


if __name__ == '__main__':
    unittest.main()