Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/jquery/77.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
koRpus包guess.lang函数_R - Fatal编程技术网

koRpus包guess.lang函数

koRpus包guess.lang函数,r,R,我有一个数据框,其中一个变量包含13000个不同语言的文本指令。我使用以下代码使用guess.lang函数检测语言。dataframe是ad,变量名是text j<-guess.lang(ad$text, udhr.path="D:/udhr_txt.zip",comp.length=10000,keep.udhr=TRUE,quiet=TRUE,in.mem=TRUE,format="obj") 我为lang.name属性获得的输出仅为英语。我得到的结果似乎是整个13000条评论的结果

我有一个数据框,其中一个变量包含13000个不同语言的文本指令。我使用以下代码使用guess.lang函数检测语言。dataframe是ad,变量名是text

j<-guess.lang(ad$text, udhr.path="D:/udhr_txt.zip",comp.length=10000,keep.udhr=TRUE,quiet=TRUE,in.mem=TRUE,format="obj")

我为lang.name属性获得的输出仅为英语。我得到的结果似乎是整个13000条评论的结果。如何获取每个13000条评论的检测语言?我是R语言的初学者,无法找到任何解决方案?

基本上就是这样工作的:

library(koRpus)
udhrpath <- "udhr_txt.zip"
txts <- c("Da die Anerkennung der angeborenen Würde und der gleichen und unveräußerlichen Rechte aller Mitglieder der Gemeinschaft der Menschen die Grundlage von Freiheit, Gerechtigkeit und Frieden in der Welt bildet,  da die Nichtanerkennung und Verachtung der Menschenrechte zu Akten der Barbarei geführt haben, die das Gewissen der Menschheit mit Empörung erfüllen, und da verkündet worden ist, daß einer Welt, in der die Menschen Rede- und Glaubensfreiheit und Freiheit von Furcht und Not genießen, das höchste Streben des Menschen gilt,  da es notwendig ist, die Menschenrechte durch die Herrschaft des Rechtes zu schützen, damit der Mensch nicht gezwungen wird, als letztes Mittel zum Aufstand gegen Tyrannei und Unterdrückung zu greifen,  da es notwendig ist, die Entwicklung freundschaftlicher Beziehungen zwischen den Nationen zu fördern,  da die Völker der Vereinten Nationen in der Charta ihren Glauben an die grundlegenden Menschenrechte, an die Würde und den Wert der menschlichen Person und an die Gleichberechtigung von Mann und Frau erneut bekräftigt und beschlossen haben, den sozialen Fortschritt und bessere Lebensbedingungen in größerer Freiheit zu fördern,  da die Mitgliedstaaten sich verpflichtet haben, in Zusammenarbeit mit den Vereinten Nationen auf die allgemeine Achtung und Einhaltung der Menschenrechte und Grundfreiheiten hinzuwirken,  da ein gemeinsames Verständnis dieser Rechte und Freiheiten von größter Wichtigkeit für die volle Erfüllung dieser Verpflichtung ist,  verkündet die Generalversammlung  diese Allgemeine Erklärung der Menschenrechte als das von allen Völkern und Nationen zu erreichende gemeinsame Ideal, damit jeder einzelne und alle Organe der Gesellschaft sich diese Erklärung stets gegenwärtig halten und sich bemühen, durch Unterricht und Erziehung die Achtung vor diesen Rechten und Freiheiten zu fördern und durch fortschreitende nationale und internationale Maßnahmen ihre allgemeine und tatsächliche Anerkennung und Einhaltung durch die Bevölkerung der Mitgliedstaaten selbst wie auch durch die Bevölkerung der ihrer Hoheitsgewalt unterstehenden Gebiete zu gewährleisten. ", 
          "Whereas recognition of the inherent dignity and of the equal and inalienable rights of all members of the human family is the foundation of freedom, justice and peace in the world,  Whereas disregard and contempt for human rights have resulted in barbarous acts which have outraged the conscience of mankind, and the advent of a world in which human beings shall enjoy freedom of speech and belief and freedom from fear and want has been proclaimed as the highest aspiration of the common people,  Whereas it is essential, if man is not to be compelled to have recourse, as a last resort, to rebellion against tyranny and oppression, that human rights should be protected by the rule of law,  Whereas it is essential to promote the development of friendly relations between nations,  Whereas the peoples of the United Nations have in the Charter reaffirmed their faith in fundamental human rights, in the dignity and worth of the human person and in the equal rights of men and women and have determined to promote social progress and better standards of life in larger freedom,  Whereas Member States have pledged themselves to achieve, in cooperation with the United Nations, the promotion of universal respect for and observance of human rights and fundamental freedoms,  Whereas a common understanding of these rights and freedoms is of the greatest importance for the full realization of this pledge,  Now, therefore,  The General Assembly,  Proclaims this Universal Declaration of Human Rights as a common standard of achievement for all peoples and all nations, to the end that every individual and every organ of society, keeping this Declaration constantly in mind, shall strive by teaching and education to promote respect for these rights and freedoms and by progressive measures, national and international, to secure their universal and effective recognition and observance, both among the peoples of Member States themselves and among the peoples of territories under their jurisdiction. ",
          "Considerato che il riconoscimento della dignità inerente a tutti i membri della famiglia umana e dei loro diritti, uguali ed inalienabili, costituisce il fondamento della libertà, della giustizia e della pace nel mondo;  Considerato che il disconoscimento e il disprezzo dei diritti umani hanno portato ad atti di barbarie che offendono la coscienza dell'umanità, e che l'avvento di un mondo in cui gli esseri umani godano della libertà di parola e di credo e della libertà dal timore e dal bisogno è stato proclamato come la più alta aspirazione dell'uomo;  Considerato che è indispensabile che i diritti umani siano protetti da norme giuridiche, se si vuole evitare che l'uomo sia costretto a ricorrere, come ultima istanza, alla ribellione contro la tirannia e l'oppressione;  Considerato che è indispensabile promuovere lo sviluppo di rapporti amichevoli tra le Nazioni;  Considerato che i popoli delle Nazioni Unite hanno riaffermato nello Statuto la loro fede nei diritti umani fondamentali, nella dignità e nel valore della persona umana, nell'uguaglianza dei diritti dell'uomo e della donna, ed hanno deciso di promuovere il progresso sociale e un miglior tenore di vita in una maggiore libertà;  Considerato che gli Stati membri si sono impegnati a perseguire, in cooperazione con le Nazioni Unite, il rispetto e l'osservanza universale dei diritti umani e delle libertà fondamentali;  Considerato che una concezione comune di questi diritti e di questa libertà è della massima importanza per la piena realizzazione di questi impegni;  L'ASSEMBLEA GENERALE  proclama  la presente dichiarazione universale dei diritti umani come ideale comune da raggiungersi da tutti i popoli e da tutte le Nazioni, al fine che ogni individuo ed ogni organo della società, avendo costantemente presente questa Dichiarazione, si sforzi di promuovere, con l'insegnamento e l'educazione, il rispetto di questi diritti e di queste libertà e di garantirne, mediante misure progressive di carattere nazionale e internazionale, l'universale ed effettivo riconoscimento e rispetto tanto fra i popoli degli stessi Stati membri, quanto fra quelli dei territori sottoposti alla loro giurisdizione.")
res <- lapply(txts, function(txt) guess.lang(txt, udhr.path = udhrpath, in.mem = TRUE, quiet = TRUE, format = "obj") )
sapply(res, function(x) x@lang)
# [1] "de-1901" "en"      "it" 

酷。:-如果它解决了你的问题,你可以检查答案,这样主题就结束了。