Browse Source

Implement new parser for doctrines

pull/107/head
Angel Aviel Domaoan 4 years ago committed by Angel Aviel Domaoan
parent
commit
4da7152ec1
  1. 82
      app/models/doctrine.rb
  2. 11
      data/csvs/labor_new.csv
  3. 3
      db/seeds.rb

82
app/models/doctrine.rb

@ -9,7 +9,7 @@ class Doctrine < ApplicationRecord
has_many :annotations, dependent: :destroy has_many :annotations, dependent: :destroy
validates :content, :headnote, presence: true validates :content, presence: true
before_validation do before_validation do
self.content_fingerprint = Digest::SHA256.hexdigest(content) self.content_fingerprint = Digest::SHA256.hexdigest(content)
@ -82,7 +82,7 @@ class Doctrine < ApplicationRecord
record = self.find_or_initialize_by(headnote: headnote, content: ["<div>", content, "</div>"].join) record = self.find_or_initialize_by(headnote: headnote, content: ["<div>", content, "</div>"].join)
if record.save if record.save
record.library_subjects.find_or_create_by(library_id: 27) record.doctrine_subjects.find_or_create_by(subject_id: subject_id)
record.doctrine_jurisprudences.find_or_create_by(jurisprudence_id: doc_id) record.doctrine_jurisprudences.find_or_create_by(jurisprudence_id: doc_id)
else else
logger.info "[#{row_no}] - failed to save #{record.errors.inspect}" logger.info "[#{row_no}] - failed to save #{record.errors.inspect}"
@ -90,6 +90,84 @@ class Doctrine < ApplicationRecord
end end
end end
def self.parse_csv_file_new(parent_id, path)
::CSV.foreach(path).each_with_index do |data, index|
row_no = index + 1
subject_name = data[0].strip
headnote = ""
content = data[1].strip
doc_url = data[8].strip
# Annotations
annomark_name = (data[2] || "").strip
editor_note = (data[4] || "").strip
phil_rep = ""
doc_urls = (data[5] || "").strip.split("citing").map(&:strip)
if doc_urls.present?
anno_doc_url = doc_urls.first
citing_doc_url = doc_urls.count > 1 ? doc_urls.last : ""
end
next if [content, doc_url].any?(&:blank?)
parent = Cdao::Subject.find(parent_id)
subject = parent.descendants.find_or_initialize_by(name: subject_name)
if subject.new_record?
subject.save
subject.library_ids = [27]
end
logger = Logger.new(Rails.root.join("log/import.doctrines.log"))
if subject.blank?
logger.info "[#{row_no}] - no subject found"
next
end
subject_id = subject.id
doc_id = doc_url.split("?").first.split("/").map(&:strip).last
if anno_doc_url.present?
anno_doc_args = anno_doc_url.split("?").first.split("/").map(&:strip).last(2)
anno_doc_type = anno_doc_args.first.classify
anno_doc_id = anno_doc_args.last
annotation_document = Cdao::Document.find_by(doc_type: anno_doc_type, doc_id: anno_doc_id)
end
if citing_doc_url.present?
citing_doc_args = citing_doc_url.split("?").first.split("/").map(&:strip).last(2)
citing_doc_type = citing_doc_args.first.classify
citing_doc_id = citing_doc_args.last
citing_document = Cdao::Document.find_by(doc_type: citing_doc_type, doc_id: citing_doc_id)
end
record = self.find_or_initialize_by(headnote: headnote, content: ["<div>", content, "</div>"].join)
if record.save
record.doctrine_subjects.find_or_create_by(subject_id: subject_id)
record.doctrine_jurisprudences.find_or_create_by(jurisprudence_id: doc_id)
# Annotations
phil_rep = ""
annomark = Annomark.find_by(name: annomark_name)
annotation = record.annotations.new
annotation.annomark_ids = [annomark.id] if annomark.present?
annotation.document = annotation_document
annotation.phil_rep = phil_rep || annotation_document.phil_rep
annotation.editor_notes = editor_note
if annotation.save
annotation.add_document(citing_document) if citing_document.present?
end
else
logger.info "[#{row_no}] - failed to save #{record.errors.inspect}"
end
end
end
searchable do searchable do
text :content text :content

11
data/csvs/labor_new.csv

@ -0,0 +1,11 @@
"Termination of Employment","Dismissal from employment has two facets: first, the legality of the act of dismissal, which constitutes substantive due process; and second, the legality of the manner of dismissal, which constitutes procedural due process. The burden of proof rests upon the employer to show that the disciplinary action was made for lawful cause or that the termination of employment was valid. In administrative and quasi-judicial proceedings, the quantum of evidence required is substantial evidence or ""such relevant evidence as a reasonable mind might accept as adequate to support a conclusion."" Thus, unsubstantiated suspicions, accusations, and conclusions of the employer do not provide legal justification for dismissing the employee.","Cited","Maula v. Ximex Delivery Express, Inc., G.R. No. 207838, January 25, 2017, 804 Phil. 365, 378 citing NDC Tagum Foundation, Inc. v. Sumakote, G.R. No. 190644, June 13, 2016, 787 Phil. 67",,"https://wpd.cdasiaonline.com/jurisprudences/62487?s_params=hHdxqiEsRdBofyXmpFVw citing https://wpd.cdasiaonline.com/jurisprudences/61610?s_params=TiTLuZdyRLyDFB9CSPtz","Mariano v. G.V. Florida Transport","G.R. No. 240882 September 16, 2020","https://wpd.cdasiaonline.com/jurisprudences/70282?s_params=4beJ1VNtoSdW1VdNygC9"
"Termination of Employment","In cases where the employee's failure to work was occasioned neither by his abandonment nor by a termination, the rule is that the burden of economic loss is not rightfully shifted to the employer; each party must bear his own loss.","Cited","Leonardo v. National Labor Relations Commission, G.R. Nos. 125303 & 126937, June 16, 2000, 389 Phil. 118, 128",,"https://wpd.cdasiaonline.com/jurisprudences/6501?s_params=68o_JQF14-gaz_rzKskz","Toledo v. New Mega Concrete Product Construction Supplies","G.R. No. 235806 February 19, 2020","https://wpd.cdasiaonline.com/jurisprudences/69209?s_params=4A_BqAv9Gk_8sbxAR5wq"
"Termination of Employment","Moreover, the Court has held that where the employee's failure to work was occasioned neither by his abandonment nor by a termination, the burden of economic loss is not rightfully shifted to the employer. Each party must bear his own loss.","Cited","Exodus International Construction Corp. v. Biscocho, G.R. No. 166109, February 23, 2011, 659 Phil. 142, 159, citing Leonardo v. National Labor Relations Commission, G.R. Nos. 125303 & 126937, June 16, 2000, 389 Phil. 118, 128",,"https://wpd.cdasiaonline.com/jurisprudences/54258?s_params=c3g1chnyo9MhSVrzt4KH citing https://wpd.cdasiaonline.com/jurisprudences/6501?s_params=TyaSDxtZwX7H3YBNH2j1","Rodriguez v. Sintron Systems, Inc.","G.R. No. 240254 July 24, 2019","https://wpd.cdasiaonline.com/jurisprudences/67637?s_params=cs5QsxXP7GYobXPunpvm"
"Termination of Employment","In Dee Jay's Inn and Café v. Raneses, the Court ruled that ""[i]n a case where the employee was neither found to have been dismissed nor to have abandoned his/her work, the general course of action is for the Court to dismiss the complaint, direct the employee to return to work, and order the employer to accept the employee.""","Illustrative ","Dee Jay's Inn and Café v. Raneses, G.R. No. 191823, October 5, 2016",,"https://wpd.cdasiaonline.com/jurisprudences/62157?s_params=XsJpujp58cZdKeue851X","Symex Security Services, Inc. v. Rivera, Jr.","G.R. No. 202613 November 08, 2017","https://wpd.cdasiaonline.com/jurisprudences/63601?s_params=XAmPQttsCXshK-uax2Jy"
"Termination of Employment","Damages are recoverable in cases where the plaintiff suffers loss due to a breach of duty committed by the defendant. The plaintiff must prove two (2) things: first, that he or she suffered a loss; and second, that the defendant caused the loss by breaching a legal duty he or she owed to the plaintiff. Absent one (1) of these elements, the plaintiff is not considered to have been injured in contemplation of the law.",,,,,"De Peralta v. Philippine Commercial International Bank","G.R. No. 184440 July 03, 2017","https://wpd.cdasiaonline.com/jurisprudences/63050?s_params=p6gkWWzaxmGyXYZjRTdK"
"Termination of Employment","In the exercise of the right to terminate a contract without cause, one party need only to give the other prior written notice as provided in the contract.","Cited","Avon Cosmetics, Inc. v. Luna, G.R. No. 153674, December 20, 2006, 540 Phil. 389",,"https://wpd.cdasiaonline.com/jurisprudences/9686?s_params=zvHD55u2JpVsEog_Shbz","GBMLT Manpower Services, Inc. v. Malinao","G.R. No. 189262 July 06, 2015","https://wpd.cdasiaonline.com/jurisprudences/60038?s_params=5RCJBKyD4Esa7Y9Tp919"
"Termination of Employment","The Court said:] We had occasion to rule that stipulations providing that either party may terminate a contract even without cause are legitimate if exercised in good faith. Thus, while either party has the right to terminate the contract at will, it cannot not act purposely to injure the other.","Cited","Avon Cosmetics, Inc. v. Luna, G.R. No. 153674, December 20, 2006, 540 Phil. 389",,"https://wpd.cdasiaonline.com/jurisprudences/9686?s_params=zvHD55u2JpVsEog_Shbz","GBMLT Manpower Services, Inc. v. Malinao","G.R. No. 189262 July 06, 2015","https://wpd.cdasiaonline.com/jurisprudences/60038?s_params=5RCJBKyD4Esa7Y9Tp919"
"Termination of Employment","The Court said:] We had occasion to rule that stipulations providing that either party may terminate a contract even without cause are legitimate if exercised in good faith. Thus, while either party has the right to terminate the contract at will, it cannot not act purposely to injure the other.","Cited","Petrophil Corporation v. Court of Appeals, G.R. No. 122796, December 10, 2001, 423 Phil. 182",,"https://wpd.cdasiaonline.com/jurisprudences/2895?s_params=YFwWazSacL5UfvhXg66r","GBMLT Manpower Services, Inc. v. Malinao","G.R. No. 189262 July 06, 2015","https://wpd.cdasiaonline.com/jurisprudences/60038?s_params=5RCJBKyD4Esa7Y9Tp919"
"Termination of Employment","In Caltex Refinery Employees Association v. NLRC and in the subsequent case of Gutierrez v. Singer Sewing Machine Company, [the Court] held that ""[e]ven when there exist some rules agreed upon between the employer and employee on the subject of dismissal, . . . the same cannot preclude the State from inquiring on whether [their] rigid application would work too harshly on the employee."" This Court will not hesitate to disregard a penalty that is manifestly disproportionate to the infraction committed.","Illustrative ","Gutierrez v. Singer Sewing Machine Co., G.R. No. 140982, September 23, 2003, 458 Phil. 401, 413",,"https://wpd.cdasiaonline.com/jurisprudences/7830?s_params=WG68QECZuNxgkGr4MtY1","Cavite Apparel, Inc. v. Marquez","G.R. No. 172044 February 06, 2013","https://wpd.cdasiaonline.com/jurisprudences/56692?s_params=ANP-zjpocvDSek8SCexA"
"Termination of Employment","In Caltex Refinery Employees Association v. NLRC and in the subsequent case of Gutierrez v. Singer Sewing Machine Company, [the Court] held that ""[e]ven when there exist some rules agreed upon between the employer and employee on the subject of dismissal, . . . the same cannot preclude the State from inquiring on whether [their] rigid application would work too harshly on the employee."" This Court will not hesitate to disregard a penalty that is manifestly disproportionate to the infraction committed.","Illustrative ","Caltex Refinery Employees Association v. National Labor Relations Commission, G.R. No. 102993, July 14, 1995, 316 Phil. 335, 343-344",,"https://wpd.cdasiaonline.com/jurisprudences/15276?s_params=dGs8Vpnrdwac6phzMDCx","Cavite Apparel, Inc. v. Marquez","G.R. No. 172044 February 06, 2013","https://wpd.cdasiaonline.com/jurisprudences/56692?s_params=ANP-zjpocvDSek8SCexA"
"Termination of Employment","Withholding of payment by the employer does not mean that the employer may renege on its obligation to pay employees their wages, termination payments, and due benefits. The employees' benefits are also not being reduced. It is only subjected to the condition that the employees return properties properly belonging to the employer. This is only consistent with the equitable principle that ""no one shall be unjustly enriched or benefited at the expense of another.""",,"Civil Code, Art. 2142",,"https://wpd.cdasiaonline.com/laws/2602?s_params=K4rmHmXNgmyPAUvZsyar","Milan v. National Labor Relations Commission","G.R. No. 202961 February 04, 2015","https://wpd.cdasiaonline.com/jurisprudences/59484?s_params=UnRs4_ZqJ-ykTVyzWbxj"
1 Termination of Employment Dismissal from employment has two facets: first, the legality of the act of dismissal, which constitutes substantive due process; and second, the legality of the manner of dismissal, which constitutes procedural due process. The burden of proof rests upon the employer to show that the disciplinary action was made for lawful cause or that the termination of employment was valid. In administrative and quasi-judicial proceedings, the quantum of evidence required is substantial evidence or "such relevant evidence as a reasonable mind might accept as adequate to support a conclusion." Thus, unsubstantiated suspicions, accusations, and conclusions of the employer do not provide legal justification for dismissing the employee. Cited Maula v. Ximex Delivery Express, Inc., G.R. No. 207838, January 25, 2017, 804 Phil. 365, 378 citing NDC Tagum Foundation, Inc. v. Sumakote, G.R. No. 190644, June 13, 2016, 787 Phil. 67 https://wpd.cdasiaonline.com/jurisprudences/62487?s_params=hHdxqiEsRdBofyXmpFVw citing https://wpd.cdasiaonline.com/jurisprudences/61610?s_params=TiTLuZdyRLyDFB9CSPtz Mariano v. G.V. Florida Transport G.R. No. 240882 September 16, 2020 https://wpd.cdasiaonline.com/jurisprudences/70282?s_params=4beJ1VNtoSdW1VdNygC9
2 Termination of Employment In cases where the employee's failure to work was occasioned neither by his abandonment nor by a termination, the rule is that the burden of economic loss is not rightfully shifted to the employer; each party must bear his own loss. Cited Leonardo v. National Labor Relations Commission, G.R. Nos. 125303 & 126937, June 16, 2000, 389 Phil. 118, 128 https://wpd.cdasiaonline.com/jurisprudences/6501?s_params=68o_JQF14-gaz_rzKskz Toledo v. New Mega Concrete Product Construction Supplies G.R. No. 235806 February 19, 2020 https://wpd.cdasiaonline.com/jurisprudences/69209?s_params=4A_BqAv9Gk_8sbxAR5wq
3 Termination of Employment Moreover, the Court has held that where the employee's failure to work was occasioned neither by his abandonment nor by a termination, the burden of economic loss is not rightfully shifted to the employer. Each party must bear his own loss. Cited Exodus International Construction Corp. v. Biscocho, G.R. No. 166109, February 23, 2011, 659 Phil. 142, 159, citing Leonardo v. National Labor Relations Commission, G.R. Nos. 125303 & 126937, June 16, 2000, 389 Phil. 118, 128 https://wpd.cdasiaonline.com/jurisprudences/54258?s_params=c3g1chnyo9MhSVrzt4KH citing https://wpd.cdasiaonline.com/jurisprudences/6501?s_params=TyaSDxtZwX7H3YBNH2j1 Rodriguez v. Sintron Systems, Inc. G.R. No. 240254 July 24, 2019 https://wpd.cdasiaonline.com/jurisprudences/67637?s_params=cs5QsxXP7GYobXPunpvm
4 Termination of Employment In Dee Jay's Inn and Café v. Raneses, the Court ruled that "[i]n a case where the employee was neither found to have been dismissed nor to have abandoned his/her work, the general course of action is for the Court to dismiss the complaint, direct the employee to return to work, and order the employer to accept the employee." Illustrative Dee Jay's Inn and Café v. Raneses, G.R. No. 191823, October 5, 2016 https://wpd.cdasiaonline.com/jurisprudences/62157?s_params=XsJpujp58cZdKeue851X Symex Security Services, Inc. v. Rivera, Jr. G.R. No. 202613 November 08, 2017 https://wpd.cdasiaonline.com/jurisprudences/63601?s_params=XAmPQttsCXshK-uax2Jy
5 Termination of Employment Damages are recoverable in cases where the plaintiff suffers loss due to a breach of duty committed by the defendant. The plaintiff must prove two (2) things: first, that he or she suffered a loss; and second, that the defendant caused the loss by breaching a legal duty he or she owed to the plaintiff. Absent one (1) of these elements, the plaintiff is not considered to have been injured in contemplation of the law. De Peralta v. Philippine Commercial International Bank G.R. No. 184440 July 03, 2017 https://wpd.cdasiaonline.com/jurisprudences/63050?s_params=p6gkWWzaxmGyXYZjRTdK
6 Termination of Employment In the exercise of the right to terminate a contract without cause, one party need only to give the other prior written notice as provided in the contract. Cited Avon Cosmetics, Inc. v. Luna, G.R. No. 153674, December 20, 2006, 540 Phil. 389 https://wpd.cdasiaonline.com/jurisprudences/9686?s_params=zvHD55u2JpVsEog_Shbz GBMLT Manpower Services, Inc. v. Malinao G.R. No. 189262 July 06, 2015 https://wpd.cdasiaonline.com/jurisprudences/60038?s_params=5RCJBKyD4Esa7Y9Tp919
7 Termination of Employment The Court said:] We had occasion to rule that stipulations providing that either party may terminate a contract even without cause are legitimate if exercised in good faith. Thus, while either party has the right to terminate the contract at will, it cannot not act purposely to injure the other. Cited Avon Cosmetics, Inc. v. Luna, G.R. No. 153674, December 20, 2006, 540 Phil. 389 https://wpd.cdasiaonline.com/jurisprudences/9686?s_params=zvHD55u2JpVsEog_Shbz GBMLT Manpower Services, Inc. v. Malinao G.R. No. 189262 July 06, 2015 https://wpd.cdasiaonline.com/jurisprudences/60038?s_params=5RCJBKyD4Esa7Y9Tp919
8 Termination of Employment The Court said:] We had occasion to rule that stipulations providing that either party may terminate a contract even without cause are legitimate if exercised in good faith. Thus, while either party has the right to terminate the contract at will, it cannot not act purposely to injure the other. Cited Petrophil Corporation v. Court of Appeals, G.R. No. 122796, December 10, 2001, 423 Phil. 182 https://wpd.cdasiaonline.com/jurisprudences/2895?s_params=YFwWazSacL5UfvhXg66r GBMLT Manpower Services, Inc. v. Malinao G.R. No. 189262 July 06, 2015 https://wpd.cdasiaonline.com/jurisprudences/60038?s_params=5RCJBKyD4Esa7Y9Tp919
9 Termination of Employment In Caltex Refinery Employees Association v. NLRC and in the subsequent case of Gutierrez v. Singer Sewing Machine Company, [the Court] held that "[e]ven when there exist some rules agreed upon between the employer and employee on the subject of dismissal, . . . the same cannot preclude the State from inquiring on whether [their] rigid application would work too harshly on the employee." This Court will not hesitate to disregard a penalty that is manifestly disproportionate to the infraction committed. Illustrative Gutierrez v. Singer Sewing Machine Co., G.R. No. 140982, September 23, 2003, 458 Phil. 401, 413 https://wpd.cdasiaonline.com/jurisprudences/7830?s_params=WG68QECZuNxgkGr4MtY1 Cavite Apparel, Inc. v. Marquez G.R. No. 172044 February 06, 2013 https://wpd.cdasiaonline.com/jurisprudences/56692?s_params=ANP-zjpocvDSek8SCexA
10 Termination of Employment In Caltex Refinery Employees Association v. NLRC and in the subsequent case of Gutierrez v. Singer Sewing Machine Company, [the Court] held that "[e]ven when there exist some rules agreed upon between the employer and employee on the subject of dismissal, . . . the same cannot preclude the State from inquiring on whether [their] rigid application would work too harshly on the employee." This Court will not hesitate to disregard a penalty that is manifestly disproportionate to the infraction committed. Illustrative Caltex Refinery Employees Association v. National Labor Relations Commission, G.R. No. 102993, July 14, 1995, 316 Phil. 335, 343-344 https://wpd.cdasiaonline.com/jurisprudences/15276?s_params=dGs8Vpnrdwac6phzMDCx Cavite Apparel, Inc. v. Marquez G.R. No. 172044 February 06, 2013 https://wpd.cdasiaonline.com/jurisprudences/56692?s_params=ANP-zjpocvDSek8SCexA
11 Termination of Employment Withholding of payment by the employer does not mean that the employer may renege on its obligation to pay employees their wages, termination payments, and due benefits. The employees' benefits are also not being reduced. It is only subjected to the condition that the employees return properties properly belonging to the employer. This is only consistent with the equitable principle that "no one shall be unjustly enriched or benefited at the expense of another." Civil Code, Art. 2142 https://wpd.cdasiaonline.com/laws/2602?s_params=K4rmHmXNgmyPAUvZsyar Milan v. National Labor Relations Commission G.R. No. 202961 February 04, 2015 https://wpd.cdasiaonline.com/jurisprudences/59484?s_params=UnRs4_ZqJ-ykTVyzWbxj

3
db/seeds.rb

@ -74,3 +74,6 @@ Cdao::Subject.parse_csv_file(Rails.root.join("data/csvs/legal.csv"))
Doctrine.parse_csv_file(1421, Rails.root.join("data/csvs/doctrines.csv")) Doctrine.parse_csv_file(1421, Rails.root.join("data/csvs/doctrines.csv"))
Doctrine.parse_csv_file(1495, Rails.root.join("data/csvs/doctrines2.csv")) Doctrine.parse_csv_file(1495, Rails.root.join("data/csvs/doctrines2.csv"))
# 339
Doctrine.parse_csv_file_new(9, Rails.root.join("data/csvs/labor_new.csv"))

Loading…
Cancel
Save