Uncategorized

Tregex Patterns

Posted on Updated on

Symbol Meaning
A << B A dominates B
A >> B A is dominated by B
A < B A immediately dominates B
A > B A is immediately dominated by B
A $ B A is a sister of B (and not equal to B)
A .. B A precedes B
A . B A immediately precedes B
A ,, B A follows B
A , B A immediately follows B
A <<, B B is a leftmost descendant of A
A <<- B B is a rightmost descendant of A
A >>, B A is a leftmost descendant of B
A >>- B A is a rightmost descendant of B
A <, B B is the first child of A
A >, B A is the first child of B
A <- B B is the last child of A
A >- B A is the last child of B
A <` B B is the last child of A
A >` B A is the last child of B
A <i B B is the ith child of A (i > 0)
A >i B A is the ith child of B (i > 0)
A <-i B B is the ith-to-last child of A (i > 0)
A >-i B A is the ith-to-last child of B (i > 0)
A <: B B is the only child of A
A >: B A is the only child of B
A <<: B A dominates B via an unbroken chain (length > 0) of unary local trees.
A >>: B A is dominated by B via an unbroken chain (length > 0) of unary local trees.
A $++ B A is a left sister of B (same as $.. for context-free trees)
A $– B A is a right sister of B (same as $,, for context-free trees)
A $+ B A is the immediate left sister of B (same as $. for context-free trees)
A $- B A is the immediate right sister of B (same as $, for context-free trees)
A $.. B A is a sister of B and precedes B
A $,, B A is a sister of B and follows B
A $. B A is a sister of B and immediately precedes B
A $, B A is a sister of B and immediately follows B
A <+(C) B A dominates B via an unbroken chain of (zero or more) nodes matching description C
A >+(C) B A is dominated by B via an unbroken chain of (zero or more) nodes matching description C
A .+(C) B A precedes B via an unbroken chain of (zero or more) nodes matching description C
A ,+(C) B A follows B via an unbroken chain of (zero or more) nodes matching description C
A <<# B B is a head of phrase A
A >># B A is a head of phrase B
A <# B B is the immediate head of phrase A
A ># B A is the immediate head of phrase B
A == B A and B are the same node
A <= B A and B are the same node or A is the parent of B
A : B [this is a pattern-segmenting operator that places no constraints on the relationship between A and B]
A <… { B ; C ; … } A has exactly B, C, etc as its subtree, with no other children.

Source: https://nlp.stanford.edu/nlp/javadoc/javanlp/edu/stanford/nlp/trees/tregex/TregexPattern.html

Advertisements

Amazon AWS Codedeploy and Jenkins

Posted on Updated on

Things to Note:

Assign new instance to an IAM Role required for codedeploy to work on that instance while creating the instance, you can’t assign an instance to a new role once it has been initiated

While using Jenkins Aws Codedeploy plugin for Jenkins, the symbolic links are not preserved when the files in the workspace directory are zipped so there may be some error.

To preserver symlinks what I did was

tar the required files and then allow Jenkins aws codedeploy to zip that tar file and deploy it on AWS, then on appspec.yaml file  I ran a post install script to untar the tar archive.

Magento 1.7 language selector issue

Posted on

Magento language switcher leads to a 404 page when store code is added to url and you try to switch language in category pages or product page with different url for different languages

There seems to be a problem in the Magento’s core.
The problem lies in the model file app/code/core/Mage/Core/Model/Url/Rewrite.php at line 252

The problem can be fixed by updating line 252 :
$targetUrl = $request->getBaseUrl(). ‘/’ . $this->getRequestPath();
with:
if (Mage::getStoreConfig(‘web/url/use_store’) && $storeCode = Mage::app()->getStore()->getCode()) {
$targetUrl = $request->getBaseUrl(). ‘/’ . Mage::app()->getStore()->getCode() . ‘/’ . $this->getRequestPath(); }
else
$targetUrl = $request->getBaseUrl(). ‘/’ . $this->getRequestPath();

The problem as you can see is that Magento core code forgets to include the store code in the url and that is what this line of code does; append store code to the resulting url.

This code is just to show you where the problem lies and I remind you, this is not the way to fix the problem. If you are a descent Magento programmer, create your own module and override the Core Rewrite Model in you own model and override only the rewrite function.

Cheers!!!
Thank you for reading. Hope this was useful to you.

Clear cache by code in Magento

Posted on

Here are a list of methods by which you can clear cache in Magento programatically

  1. Clear all cache files of Magento by the command: rm -rf var/cache/*
    <?php system(“rm -rf var/cache/*”); ?>
  2. Clear all frontend caches:
    Mage::app()->cleanCache();
  3. Clear cache by tag:
    $tags = array(“CONFIG”);
    Mage::app()->cleanCache($tags);
  4. Clear all caches:
    Mage::app()->getCacheInstance()->flush();

Magento restrict page to not logged in users.

Posted on

Place this code at the start of the controller function which displays your page.

if(!Mage::getSingleton('customer/session')->isLoggedIn()){ //check if user is logged in
Mage::getSingleton('customer/session')->setBeforeAuthUrl(Mage::helper('core/url')->getCurrentUrl()); //save requested URL for later redirection after login
Mage::getSingleton("core/session")->addError('You must be logged in to view this page.');
$this->_redirect("customer/account/login");//redirect user to login page
return;
}